Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2707)

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 74653002: sync: Add --enable-sync-sessions-v2 and necessary plumbing to use SessionsSyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_mock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 710fb757315f96d0b9ed9466ba5c5bc6e3c52388..5173ed7c0d765c02a5209aa955e2c9a8cf9a43cc 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -40,6 +40,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"
@@ -47,6 +48,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"
@@ -191,6 +193,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() {
@@ -349,18 +356,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_) {
@@ -397,7 +438,7 @@ ScopedVector<browser_sync::DeviceInfo>
return devices.Pass();
}
-std::string ProfileSyncService::GetLocalDeviceGUID() const {
+std::string ProfileSyncService::GetLocalSyncCacheGUID() const {
if (backend_) {
browser_sync::SyncedDeviceTracker* device_tracker =
backend_->GetSyncedDeviceTracker();
@@ -1020,7 +1061,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
@@ -1028,7 +1069,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();
@@ -2197,6 +2238,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()) {}
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698