| Index: chrome/browser/sync/profile_sync_service.cc
|
| diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
|
| index 856ada2d8186a9953071e6e60945348052456144..11bf260c7134b38c12cad30748c5cec2e5c02898 100644
|
| --- a/chrome/browser/sync/profile_sync_service.cc
|
| +++ b/chrome/browser/sync/profile_sync_service.cc
|
| @@ -42,6 +42,7 @@
|
| #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
|
| #include "chrome/browser/sync/glue/data_type_controller.h"
|
| #include "chrome/browser/sync/glue/device_info.h"
|
| +#include "chrome/browser/sync/glue/favicon_cache.h"
|
| #include "chrome/browser/sync/glue/session_data_type_controller.h"
|
| #include "chrome/browser/sync/glue/session_model_associator.h"
|
| #include "chrome/browser/sync/glue/sync_backend_host.h"
|
| @@ -49,6 +50,7 @@
|
| #include "chrome/browser/sync/glue/synced_device_tracker.h"
|
| #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
|
| #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
|
| +#include "chrome/browser/sync/sessions2/sessions_sync_manager.h"
|
| #include "chrome/browser/sync/sync_global_error.h"
|
| #include "chrome/browser/sync/user_selectable_sync_type.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -193,6 +195,11 @@ ProfileSyncService::ProfileSyncService(
|
| channel == chrome::VersionInfo::CHANNEL_BETA) {
|
| sync_service_url_ = GURL(kSyncServerUrl);
|
| }
|
| +
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableSyncSessionsV2)) {
|
| + sessions_sync_manager_.reset(new SessionsSyncManager(profile, this));
|
| + }
|
| }
|
|
|
| ProfileSyncService::~ProfileSyncService() {
|
| @@ -358,18 +365,52 @@ void ProfileSyncService::RegisterDataTypeController(
|
| }
|
|
|
| browser_sync::SessionModelAssociator*
|
| - ProfileSyncService::GetSessionModelAssociator() {
|
| + ProfileSyncService::GetSessionModelAssociatorDeprecated() {
|
| if (data_type_controllers_.find(syncer::SESSIONS) ==
|
| data_type_controllers_.end() ||
|
| data_type_controllers_.find(syncer::SESSIONS)->second->state() !=
|
| DataTypeController::RUNNING) {
|
| return NULL;
|
| }
|
| +
|
| + // If we're using sessions V2, there's no model associator.
|
| + if (sessions_sync_manager_.get())
|
| + return NULL;
|
| +
|
| return static_cast<browser_sync::SessionDataTypeController*>(
|
| data_type_controllers_.find(
|
| syncer::SESSIONS)->second.get())->GetModelAssociator();
|
| }
|
|
|
| +browser_sync::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() {
|
| + if (data_type_controllers_.find(syncer::SESSIONS) ==
|
| + data_type_controllers_.end() ||
|
| + data_type_controllers_.find(syncer::SESSIONS)->second->state() !=
|
| + DataTypeController::RUNNING) {
|
| + return NULL;
|
| + }
|
| +
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableSyncSessionsV2)) {
|
| + return sessions_sync_manager_.get();
|
| + } else {
|
| + return GetSessionModelAssociatorDeprecated();
|
| + }
|
| +}
|
| +
|
| +browser_sync::FaviconCache* ProfileSyncService::GetFaviconCache() {
|
| + // TODO(tim): Clean this up (or remove) once there's only one implementation.
|
| + // Bug 98892.
|
| + if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableSyncSessionsV2)) {
|
| + return sessions_sync_manager_->GetFaviconCache();
|
| + } else if (GetSessionModelAssociatorDeprecated()) {
|
| + return GetSessionModelAssociatorDeprecated()->GetFaviconCache();
|
| + } else {
|
| + return NULL;
|
| + }
|
| +}
|
| +
|
| scoped_ptr<browser_sync::DeviceInfo>
|
| ProfileSyncService::GetLocalDeviceInfo() const {
|
| if (backend_) {
|
| @@ -1029,7 +1070,7 @@ void ProfileSyncService::OnBackendInitialized(
|
|
|
| void ProfileSyncService::OnSyncCycleCompleted() {
|
| UpdateLastSyncedTime();
|
| - if (GetSessionModelAssociator()) {
|
| + if (GetSessionModelAssociatorDeprecated()) {
|
| // Trigger garbage collection of old sessions now that we've downloaded
|
| // any new session data. TODO(zea): Have this be a notification the session
|
| // model associator listens too. Also consider somehow plumbing the current
|
| @@ -1037,7 +1078,7 @@ void ProfileSyncService::OnSyncCycleCompleted() {
|
| // rely on the local clock, which may be off significantly.
|
| base::MessageLoop::current()->PostTask(FROM_HERE,
|
| base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions,
|
| - GetSessionModelAssociator()->AsWeakPtr()));
|
| + GetSessionModelAssociatorDeprecated()->AsWeakPtr()));
|
| }
|
| DVLOG(2) << "Notifying observers sync cycle completed";
|
| NotifySyncCycleCompleted();
|
| @@ -2206,6 +2247,10 @@ WeakHandle<syncer::JsEventHandler> ProfileSyncService::GetJsEventHandler() {
|
| return MakeWeakHandle(sync_js_controller_.AsWeakPtr());
|
| }
|
|
|
| +syncer::SyncableService* ProfileSyncService::GetSessionsSyncableService() {
|
| + return sessions_sync_manager_.get();
|
| +}
|
| +
|
| ProfileSyncService::SyncTokenStatus::SyncTokenStatus()
|
| : connection_status(syncer::CONNECTION_NOT_ATTEMPTED),
|
| last_get_token_error(GoogleServiceAuthError::AuthErrorNone()) {}
|
|
|