#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/chrome_signin_client_factory.h"
+#include "chrome/browser/sync/glue/invalidation_helper.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/invalidation/invalidation_service.h"
+#include "components/invalidation/object_id_invalidation_map.h"
#include "components/network_time/network_time_tracker.h"
+#include "components/signin/core/browser/signin_client.h"
#include "components/sync_driver/sync_frontend.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/browser_thread.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"
// Helper macros to log with the syncer thread name; useful when there
// are multiple syncers involved.
}
void SyncBackendHostImpl::Initialize(
- SyncFrontend* frontend,
+ sync_driver::SyncFrontend* frontend,
scoped_ptr<base::Thread> sync_thread,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& sync_service_url,
InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE;
}
+ SigninClient* signin_client =
+ ChromeSigninClientFactory::GetForProfile(profile_);
+ DCHECK(signin_client);
+ std::string signin_scoped_device_id =
+ signin_client->GetSigninScopedDeviceId();
+
scoped_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
registrar_->sync_thread()->message_loop(),
registrar_.get(),
scoped_ptr<InternalComponentsFactory>(
new syncer::InternalComponentsFactoryImpl(factory_switches)).Pass(),
unrecoverable_error_handler.Pass(),
- report_unrecoverable_error_function));
+ report_unrecoverable_error_function,
+ signin_scoped_device_id));
InitCore(init_opts.Pass());
}
notification_registrar_.RemoveAll();
// Stop non-blocking sync types from sending any more requests to the syncer.
- sync_core_proxy_.reset();
+ sync_context_proxy_.reset();
DCHECK(registrar_->sync_thread()->IsRunning());
core_->ShutdownOnUIThread();
}
-scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(ShutdownOption option) {
+scoped_ptr<base::Thread> SyncBackendHostImpl::Shutdown(
+ syncer::ShutdownReason reason) {
// StopSyncingForShutdown() (which nulls out |frontend_|) should be
// called first.
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);
+ bool sync_thread_claimed = (reason != syncer::BROWSER_SHUTDOWN);
if (invalidation_handler_registered_) {
- if (sync_disabled) {
+ if (reason == syncer::DISABLE_SYNC) {
UnregisterInvalidationIds();
}
invalidator_->UnregisterInvalidationHandler(this);
registrar_->sync_thread()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&SyncBackendHostCore::DoShutdown,
- core_.get(), sync_disabled));
+ core_.get(), reason));
core_ = NULL;
// Worker cleanup.
// backend because configuration requests are never aborted; they are retried
// until they succeed or the backend is shut down.
- syncer::ModelTypeSet previous_types = registrar_->GetLastConfiguredTypes();
-
syncer::ModelTypeSet disabled_types =
GetDataTypesInState(DISABLED, config_state_map);
syncer::ModelTypeSet fatal_types =
GetDataTypesInState(CRYPTO, config_state_map);
syncer::ModelTypeSet unready_types =
GetDataTypesInState(UNREADY, config_state_map);
- disabled_types.PutAll(fatal_types);
- // TODO(zea): These types won't be fully purged if they are subsequently
- // disabled by the user. Fix that. See crbug.com/386778
+ disabled_types.PutAll(fatal_types);
disabled_types.PutAll(crypto_types);
disabled_types.PutAll(unready_types);
syncer::ModelTypeSet current_types = registrar_->GetLastConfiguredTypes();
syncer::ModelTypeSet types_to_purge =
- syncer::Difference(previous_types, current_types);
+ syncer::Difference(syncer::ModelTypeSet::All(), current_types);
syncer::ModelTypeSet inactive_types =
GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map);
types_to_purge.RemoveAll(inactive_types);
void SyncBackendHostImpl::ActivateDataType(
syncer::ModelType type, syncer::ModelSafeGroup group,
- ChangeProcessor* change_processor) {
+ sync_driver::ChangeProcessor* change_processor) {
registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
}
return core_->sync_manager()->GetUserShare();
}
-scoped_ptr<syncer::SyncCoreProxy> SyncBackendHostImpl::GetSyncCoreProxy() {
- return sync_core_proxy_.get() ?
- scoped_ptr<syncer::SyncCoreProxy>(sync_core_proxy_->Clone()) :
- scoped_ptr<syncer::SyncCoreProxy>();
+scoped_ptr<syncer::SyncContextProxy>
+SyncBackendHostImpl::GetSyncContextProxy() {
+ return sync_context_proxy_.get() ? scoped_ptr<syncer::SyncContextProxy>(
+ sync_context_proxy_->Clone())
+ : scoped_ptr<syncer::SyncContextProxy>();
}
SyncBackendHostImpl::Status SyncBackendHostImpl::GetDetailedStatus() {
const syncer::WeakHandle<syncer::JsBackend> js_backend,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>
debug_info_listener,
- syncer::SyncCoreProxy* sync_core_proxy) {
+ syncer::SyncContextProxy* sync_context_proxy,
+ const std::string& cache_guid) {
DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
- if (sync_core_proxy)
- sync_core_proxy_ = sync_core_proxy->Clone();
+ if (sync_context_proxy)
+ sync_context_proxy_ = sync_context_proxy->Clone();
if (!frontend_)
return;
AddExperimentalTypes();
frontend_->OnBackendInitialized(js_backend,
debug_info_listener,
+ cache_guid,
true);
}
frontend_->OnBackendInitialized(
syncer::WeakHandle<syncer::JsBackend>(),
syncer::WeakHandle<syncer::DataTypeDebugInfoListener>(),
+ "",
false);
}