This source file includes following definitions.
- weak_ptr_factory_
- Initialize
- UpdateCredentials
- StartSyncingWithServer
- SetEncryptionPassphrase
- SetDecryptionPassphrase
- StopSyncingForShutdown
- Shutdown
- UnregisterInvalidationIds
- ConfigureDataTypes
- EnableEncryptEverything
- ActivateDataType
- DeactivateDataType
- GetUserShare
- GetSyncCoreProxy
- GetDetailedStatus
- GetLastSessionSnapshot
- HasUnsyncedItems
- IsNigoriEnabled
- GetPassphraseType
- GetExplicitPassphraseTime
- IsCryptographerReady
- GetModelSafeRoutingInfo
- GetSyncedDeviceTracker
- RequestBufferedProtocolEventsAndEnableForwarding
- DisableProtocolEventForwarding
- InitCore
- RequestConfigureSyncer
- FinishConfigureDataTypesOnFrontendLoop
- Observe
- AddExperimentalTypes
- HandleControlTypesDownloadRetry
- HandleInitializationSuccessOnFrontendLoop
- HandleInitializationFailureOnFrontendLoop
- HandleSyncCycleCompletedOnFrontendLoop
- RetryConfigurationOnFrontendLoop
- PersistEncryptionBootstrapToken
- HandleActionableErrorEventOnFrontendLoop
- HandleMigrationRequestedOnFrontendLoop
- OnInvalidatorStateChange
- OnIncomingInvalidation
- GetOwnerName
- CheckPassphraseAgainstCachedPendingKeys
- NotifyPassphraseRequired
- NotifyPassphraseAccepted
- NotifyEncryptedTypesChanged
- NotifyEncryptionComplete
- HandlePassphraseTypeChangedOnFrontendLoop
- HandleConnectionStatusChangeOnFrontendLoop
- HandleProtocolEventOnFrontendLoop
- GetSyncLoopForTesting
#include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/invalidation/invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/network_time/network_time_tracker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_backend_host_core.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
#include "chrome/common/chrome_switches.h"
#include "components/sync_driver/sync_frontend.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "sync/internal_api/public/base_transaction.h"
#include "sync/internal_api/public/events/protocol_event.h"
#include "sync/internal_api/public/http_bridge.h"
#include "sync/internal_api/public/internal_components_factory.h"
#include "sync/internal_api/public/internal_components_factory_impl.h"
#include "sync/internal_api/public/network_resources.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/internal_api/public/sync_manager_factory.h"
#include "sync/internal_api/public/util/experiments.h"
#include "sync/internal_api/public/util/sync_string_conversions.h"
#include "sync/notifier/object_id_invalidation_map.h"
#define SLOG(severity) LOG(severity) << name_ << ": "
#define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
using syncer::InternalComponentsFactory;
static const base::FilePath::CharType kSyncDataFolderName[] =
FILE_PATH_LITERAL("Sync Data");
namespace browser_sync {
SyncBackendHostImpl::SyncBackendHostImpl(
const std::string& name,
Profile* profile,
const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs)
: frontend_loop_(base::MessageLoop::current()),
profile_(profile),
name_(name),
initialized_(false),
sync_prefs_(sync_prefs),
frontend_(NULL),
cached_passphrase_type_(syncer::IMPLICIT_PASSPHRASE),
invalidator_(
invalidation::InvalidationServiceFactory::GetForProfile(profile)),
invalidation_handler_registered_(false),
weak_ptr_factory_(this) {
CHECK(invalidator_);
core_ = new SyncBackendHostCore(
name_,
profile_->GetPath().Append(kSyncDataFolderName),
sync_prefs_->HasSyncSetupCompleted(),
weak_ptr_factory_.GetWeakPtr());
}
SyncBackendHostImpl::~SyncBackendHostImpl() {
DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor.";
DCHECK(!registrar_.get());
}
void SyncBackendHostImpl::Initialize(
SyncFrontend* frontend,
scoped_ptr<base::Thread> sync_thread,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& sync_service_url,
const syncer::SyncCredentials& credentials,
bool delete_sync_data_folder,
scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
syncer::ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
syncer::NetworkResources* network_resources) {
registrar_.reset(new browser_sync::SyncBackendRegistrar(name_,
profile_,
sync_thread.Pass()));
CHECK(registrar_->sync_thread());
frontend_ = frontend;
DCHECK(frontend);
syncer::ModelSafeRoutingInfo routing_info;
std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers;
registrar_->GetModelSafeRoutingInfo(&routing_info);
registrar_->GetWorkers(&workers);
InternalComponentsFactory::Switches factory_switches = {
InternalComponentsFactory::ENCRYPTION_KEYSTORE,
InternalComponentsFactory::BACKOFF_NORMAL
};
CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) {
factory_switches.backoff_override =
InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE;
}
if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) {
factory_switches.pre_commit_updates_policy =
InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE;
}
scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
registrar_->sync_thread()->message_loop(),
registrar_.get(),
routing_info,
workers,
extensions_activity_monitor_.GetExtensionsActivity(),
event_handler,
sync_service_url,
network_resources->GetHttpPostProviderFactory(
make_scoped_refptr(profile_->GetRequestContext()),
NetworkTimeTracker::BuildNotifierUpdateCallback(),
core_->GetRequestContextCancelationSignal()),
credentials,
invalidator_->GetInvalidatorClientId(),
sync_manager_factory.Pass(),
delete_sync_data_folder,
sync_prefs_->GetEncryptionBootstrapToken(),
sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
scoped_ptr<InternalComponentsFactory>(
new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(),
unrecoverable_error_handler.Pass(),
report_unrecoverable_error_function));
InitCore(init_opts.Pass());
}
void SyncBackendHostImpl::UpdateCredentials(
const syncer::SyncCredentials& credentials) {
DCHECK(registrar_->sync_thread()->IsRunning());
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoUpdateCredentials,
core_.get(),
credentials));
}
void SyncBackendHostImpl::StartSyncingWithServer() {
SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called.";
syncer::ModelSafeRoutingInfo routing_info;
registrar_->GetModelSafeRoutingInfo(&routing_info);
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoStartSyncing,
core_.get(), routing_info));
}
void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase,
bool is_explicit) {
DCHECK(registrar_->sync_thread()->IsRunning());
if (!IsNigoriEnabled()) {
NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori"
" is disabled.";
return;
}
DCHECK(!passphrase.empty());
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
DCHECK(cached_passphrase_type_ == syncer::KEYSTORE_PASSPHRASE ||
cached_passphrase_type_ == syncer::IMPLICIT_PASSPHRASE);
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase,
core_.get(),
passphrase, is_explicit));
}
bool SyncBackendHostImpl::SetDecryptionPassphrase(
const std::string& passphrase) {
if (!IsNigoriEnabled()) {
NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori"
" is disabled.";
return false;
}
DCHECK(!passphrase.empty());
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
DCHECK(cached_pending_keys_.has_blob());
if (!CheckPassphraseAgainstCachedPendingKeys(passphrase))
return false;
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase,
core_.get(),
passphrase));
NotifyPassphraseAccepted();
return true;
}
void SyncBackendHostImpl::StopSyncingForShutdown() {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
frontend_ = NULL;
notification_registrar_.RemoveAll();
sync_core_proxy_.reset();
DCHECK(registrar_->sync_thread()->IsRunning());
registrar_->RequestWorkerStopOnUIThread();
core_->ShutdownOnUIThread();
}
scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(ShutdownOption option) {
DCHECK(!frontend_);
DCHECK(registrar_->sync_thread()->IsRunning());
bool sync_disabled = (option == DISABLE_AND_CLAIM_THREAD);
bool sync_thread_claimed =
(option == DISABLE_AND_CLAIM_THREAD || option == STOP_AND_CLAIM_THREAD);
if (invalidation_handler_registered_) {
if (sync_disabled) {
UnregisterInvalidationIds();
}
invalidator_->UnregisterInvalidationHandler(this);
invalidator_ = NULL;
}
invalidation_handler_registered_ = false;
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&SyncBackendHostCore::DoShutdown,
core_.get(), sync_disabled));
core_ = NULL;
SyncBackendRegistrar* detached_registrar = registrar_.release();
detached_registrar->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&SyncBackendRegistrar::Shutdown,
base::Unretained(detached_registrar)));
if (sync_thread_claimed)
return detached_registrar->ReleaseSyncThread();
else
return scoped_ptr<base::Thread>();
}
void SyncBackendHostImpl::UnregisterInvalidationIds() {
if (invalidation_handler_registered_) {
invalidator_->UpdateRegisteredInvalidationIds(
this,
syncer::ObjectIdSet());
}
}
void SyncBackendHostImpl::ConfigureDataTypes(
syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet,
syncer::ModelTypeSet)>& ready_task,
const base::Callback<void()>& retry_callback) {
syncer::ModelTypeSet previous_types = registrar_->GetLastConfiguredTypes();
syncer::ModelTypeSet disabled_types =
GetDataTypesInState(DISABLED, config_state_map);
syncer::ModelTypeSet fatal_types =
GetDataTypesInState(FATAL, config_state_map);
syncer::ModelTypeSet crypto_types =
GetDataTypesInState(CRYPTO, config_state_map);
disabled_types.PutAll(fatal_types);
disabled_types.PutAll(crypto_types);
syncer::ModelTypeSet active_types =
GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map);
syncer::ModelTypeSet clean_first_types =
GetDataTypesInState(CONFIGURE_CLEAN, config_state_map);
syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes(
syncer::Union(active_types, clean_first_types),
disabled_types);
types_to_download.PutAll(clean_first_types);
types_to_download.RemoveAll(syncer::ProxyTypes());
if (!types_to_download.Empty())
types_to_download.Put(syncer::NIGORI);
syncer::ModelSafeRoutingInfo routing_info;
registrar_->GetModelSafeRoutingInfo(&routing_info);
syncer::ModelTypeSet current_types = registrar_->GetLastConfiguredTypes();
syncer::ModelTypeSet types_to_purge =
syncer::Difference(previous_types, current_types);
syncer::ModelTypeSet inactive_types =
GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map);
types_to_purge.RemoveAll(inactive_types);
fatal_types.RetainAll(types_to_purge);
syncer::ModelTypeSet unapply_types =
syncer::Union(crypto_types, clean_first_types);
unapply_types.RetainAll(types_to_purge);
DCHECK(syncer::Intersection(current_types, fatal_types).Empty());
DCHECK(syncer::Intersection(current_types, crypto_types).Empty());
DCHECK(current_types.HasAll(types_to_download));
SDVLOG(1) << "Types "
<< syncer::ModelTypeSetToString(types_to_download)
<< " added; calling DoConfigureSyncer";
RequestConfigureSyncer(reason,
types_to_download,
types_to_purge,
fatal_types,
unapply_types,
inactive_types,
routing_info,
ready_task,
retry_callback);
}
void SyncBackendHostImpl::EnableEncryptEverything() {
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything,
core_.get()));
}
void SyncBackendHostImpl::ActivateDataType(
syncer::ModelType type, syncer::ModelSafeGroup group,
ChangeProcessor* change_processor) {
registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
}
void SyncBackendHostImpl::DeactivateDataType(syncer::ModelType type) {
registrar_->DeactivateDataType(type);
}
syncer::UserShare* SyncBackendHostImpl::GetUserShare() const {
return core_->sync_manager()->GetUserShare();
}
syncer::SyncCoreProxy SyncBackendHostImpl::GetSyncCoreProxy() {
return *sync_core_proxy_.get();
}
SyncBackendHostImpl::Status SyncBackendHostImpl::GetDetailedStatus() {
DCHECK(initialized());
return core_->sync_manager()->GetDetailedStatus();
}
syncer::sessions::SyncSessionSnapshot
SyncBackendHostImpl::GetLastSessionSnapshot() const {
return last_snapshot_;
}
bool SyncBackendHostImpl::HasUnsyncedItems() const {
DCHECK(initialized());
return core_->sync_manager()->HasUnsyncedItems();
}
bool SyncBackendHostImpl::IsNigoriEnabled() const {
return registrar_.get() && registrar_->IsNigoriEnabled();
}
syncer::PassphraseType SyncBackendHostImpl::GetPassphraseType() const {
return cached_passphrase_type_;
}
base::Time SyncBackendHostImpl::GetExplicitPassphraseTime() const {
return cached_explicit_passphrase_time_;
}
bool SyncBackendHostImpl::IsCryptographerReady(
const syncer::BaseTransaction* trans) const {
return initialized() && trans->GetCryptographer()->is_ready();
}
void SyncBackendHostImpl::GetModelSafeRoutingInfo(
syncer::ModelSafeRoutingInfo* out) const {
if (initialized()) {
CHECK(registrar_.get());
registrar_->GetModelSafeRoutingInfo(out);
} else {
NOTREACHED();
}
}
SyncedDeviceTracker* SyncBackendHostImpl::GetSyncedDeviceTracker() const {
if (!initialized())
return NULL;
return core_->synced_device_tracker();
}
void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
DCHECK(initialized());
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(
&SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding,
core_));
}
void SyncBackendHostImpl::DisableProtocolEventForwarding() {
DCHECK(initialized());
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(
&SyncBackendHostCore::DisableProtocolEventForwarding,
core_));
}
void SyncBackendHostImpl::InitCore(scoped_ptr<DoInitializeOptions> options) {
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoInitialize,
core_.get(), base::Passed(&options)));
}
void SyncBackendHostImpl::RequestConfigureSyncer(
syncer::ConfigureReason reason,
syncer::ModelTypeSet to_download,
syncer::ModelTypeSet to_purge,
syncer::ModelTypeSet to_journal,
syncer::ModelTypeSet to_unapply,
syncer::ModelTypeSet to_ignore,
const syncer::ModelSafeRoutingInfo& routing_info,
const base::Callback<void(syncer::ModelTypeSet,
syncer::ModelTypeSet)>& ready_task,
const base::Closure& retry_callback) {
DoConfigureSyncerTypes config_types;
config_types.to_download = to_download;
config_types.to_purge = to_purge;
config_types.to_journal = to_journal;
config_types.to_unapply = to_unapply;
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoConfigureSyncer,
core_.get(),
reason,
config_types,
routing_info,
ready_task,
retry_callback));
}
void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop(
const syncer::ModelTypeSet enabled_types,
const syncer::ModelTypeSet succeeded_configuration_types,
const syncer::ModelTypeSet failed_configuration_types,
const base::Callback<void(syncer::ModelTypeSet,
syncer::ModelTypeSet)>& ready_task) {
if (!frontend_)
return;
invalidator_->UpdateRegisteredInvalidationIds(
this,
ModelTypeSetToObjectIdSet(enabled_types));
if (!ready_task.is_null())
ready_task.Run(succeeded_configuration_types, failed_configuration_types);
}
void SyncBackendHostImpl::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK_EQ(type, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL);
content::Details<const syncer::ModelTypeSet> state_details(details);
const syncer::ModelTypeSet& types = *(state_details.ptr());
registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types));
}
void SyncBackendHostImpl::AddExperimentalTypes() {
CHECK(initialized());
syncer::Experiments experiments;
if (core_->sync_manager()->ReceivedExperiment(&experiments))
frontend_->OnExperimentsChanged(experiments);
}
void SyncBackendHostImpl::HandleControlTypesDownloadRetry() {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
if (!frontend_)
return;
frontend_->OnSyncConfigureRetry();
}
void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop(
const syncer::WeakHandle<syncer::JsBackend> js_backend,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>
debug_info_listener,
syncer::SyncCoreProxy sync_core_proxy) {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
if (!frontend_)
return;
initialized_ = true;
sync_core_proxy_.reset(new syncer::SyncCoreProxy(sync_core_proxy));
invalidator_->RegisterInvalidationHandler(this);
invalidation_handler_registered_ = true;
OnInvalidatorStateChange(invalidator_->GetInvalidatorState());
notification_registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
content::Source<Profile>(profile_));
AddExperimentalTypes();
frontend_->OnBackendInitialized(js_backend,
debug_info_listener,
true);
}
void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
if (!frontend_)
return;
frontend_->OnBackendInitialized(
syncer::WeakHandle<syncer::JsBackend>(),
syncer::WeakHandle<syncer::DataTypeDebugInfoListener>(),
false);
}
void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop(
const syncer::sessions::SyncSessionSnapshot& snapshot) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
last_snapshot_ = snapshot;
SDVLOG(1) << "Got snapshot " << snapshot.ToString();
if (initialized())
AddExperimentalTypes();
if (initialized())
frontend_->OnSyncCycleCompleted();
}
void SyncBackendHostImpl::RetryConfigurationOnFrontendLoop(
const base::Closure& retry_callback) {
SDVLOG(1) << "Failed to complete configuration, informing of retry.";
retry_callback.Run();
}
void SyncBackendHostImpl::PersistEncryptionBootstrapToken(
const std::string& token,
syncer::BootstrapTokenType token_type) {
CHECK(sync_prefs_.get());
DCHECK(!token.empty());
if (token_type == syncer::PASSPHRASE_BOOTSTRAP_TOKEN)
sync_prefs_->SetEncryptionBootstrapToken(token);
else
sync_prefs_->SetKeystoreEncryptionBootstrapToken(token);
}
void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop(
const syncer::SyncProtocolError& sync_error) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
frontend_->OnActionableError(sync_error);
}
void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop(
syncer::ModelTypeSet types) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
frontend_->OnMigrationNeededForTypes(types);
}
void SyncBackendHostImpl::OnInvalidatorStateChange(
syncer::InvalidatorState state) {
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange,
core_.get(),
state));
}
void SyncBackendHostImpl::OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) {
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation,
core_.get(),
invalidation_map));
}
std::string SyncBackendHostImpl::GetOwnerName() const {
return "SyncBackendHostImpl";
}
bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys(
const std::string& passphrase) const {
DCHECK(cached_pending_keys_.has_blob());
DCHECK(!passphrase.empty());
syncer::Nigori nigori;
nigori.InitByDerivation("localhost", "dummy", passphrase);
std::string plaintext;
bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext);
DVLOG_IF(1, result) << "Passphrase failed to decrypt pending keys.";
return result;
}
void SyncBackendHostImpl::NotifyPassphraseRequired(
syncer::PassphraseRequiredReason reason,
sync_pb::EncryptedData pending_keys) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
cached_pending_keys_ = pending_keys;
frontend_->OnPassphraseRequired(reason, pending_keys);
}
void SyncBackendHostImpl::NotifyPassphraseAccepted() {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
cached_pending_keys_.clear_blob();
frontend_->OnPassphraseAccepted();
}
void SyncBackendHostImpl::NotifyEncryptedTypesChanged(
syncer::ModelTypeSet encrypted_types,
bool encrypt_everything) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
frontend_->OnEncryptedTypesChanged(
encrypted_types, encrypt_everything);
}
void SyncBackendHostImpl::NotifyEncryptionComplete() {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
frontend_->OnEncryptionComplete();
}
void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop(
syncer::PassphraseType type,
base::Time explicit_passphrase_time) {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
DVLOG(1) << "Passphrase type changed to "
<< syncer::PassphraseTypeToString(type);
cached_passphrase_type_ = type;
cached_explicit_passphrase_time_ = explicit_passphrase_time;
}
void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop(
syncer::ConnectionStatus status) {
if (!frontend_)
return;
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
DVLOG(1) << "Connection status changed: "
<< syncer::ConnectionStatusToString(status);
frontend_->OnConnectionStatusChange(status);
}
void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop(
syncer::ProtocolEvent* event) {
scoped_ptr<syncer::ProtocolEvent> scoped_event(event);
if (!frontend_)
return;
frontend_->OnProtocolEvent(*scoped_event);
}
base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() {
return registrar_->sync_thread()->message_loop();
}
}
#undef SDVLOG
#undef SLOG