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

Unified Diff: chrome/browser/sync/internal_api/sync_manager.cc

Issue 7767013: Add logic to flip Nigori bit to instruct other clients to sync tabs. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix CHECK on startup Created 9 years, 4 months 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
Index: chrome/browser/sync/internal_api/sync_manager.cc
diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc
index fc49f35e7c9165ddd5f1986462877df93bdd4829..065f0bd0abfe90471b9916135a80cd8aa941f16c 100644
--- a/chrome/browser/sync/internal_api/sync_manager.cc
+++ b/chrome/browser/sync/internal_api/sync_manager.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "base/base64.h"
+#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/string_number_conversions.h"
#include "base/values.h"
@@ -42,6 +43,7 @@
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/util/cryptographer.h"
#include "chrome/browser/sync/weak_handle.h"
+#include "chrome/common/chrome_switches.h"
#include "net/base/network_change_notifier.h"
using std::string;
@@ -236,6 +238,10 @@ class SyncManager::SyncInternal
// Called when the user disables or enables a sync type.
void UpdateEnabledTypes();
+ // Conditionally sets the flag in the Nigori node which instructs other
+ // clients to start syncing tabs.
+ void MaybeSetSyncTabsInNigoriNode(const syncable::ModelTypeSet enabled_types);
+
// Tell the sync engine to start the syncing process.
void StartSyncingNormally();
@@ -657,6 +663,11 @@ void SyncManager::UpdateEnabledTypes() {
data_->UpdateEnabledTypes();
}
+void SyncManager::MaybeSetSyncTabsInNigoriNode(
+ const syncable::ModelTypeSet enabled_types) {
+ data_->MaybeSetSyncTabsInNigoriNode(enabled_types);
+}
+
bool SyncManager::InitialSyncEndedForAllEnabledTypes() {
return data_->InitialSyncEndedForAllEnabledTypes();
}
@@ -943,6 +954,30 @@ void SyncManager::SyncInternal::UpdateEnabledTypes() {
enabled_types.insert(it->first);
}
sync_notifier_->UpdateEnabledTypes(enabled_types);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSyncSessionsForOtherClients)) {
+ MaybeSetSyncTabsInNigoriNode(enabled_types);
+ }
+}
+
+void SyncManager::SyncInternal::MaybeSetSyncTabsInNigoriNode(
+ const syncable::ModelTypeSet enabled_types) {
+ // The initialized_ check is to ensure that we don't CHECK in GetUserShare
+ // when this is called on start-up. It's ok to ignore that case, since
+ // presumably this would've run when the user originally enabled sessions.
+ if (initialized_ && enabled_types.count(syncable::SESSIONS) > 0) {
+ WriteTransaction trans(FROM_HERE, GetUserShare());
+ WriteNode node(&trans);
+ if (!node.InitByTagLookup(kNigoriTag)) {
+ NOTREACHED() << "Unable to set 'sync_tabs' bit because Nigori node not "
+ << "found.";
+ return;
+ }
+
+ sync_pb::NigoriSpecifics specifics(node.GetNigoriSpecifics());
+ specifics.set_sync_tabs(true);
+ node.SetNigoriSpecifics(specifics);
+ }
}
void SyncManager::SyncInternal::RaiseAuthNeededEvent() {
« no previous file with comments | « chrome/browser/sync/internal_api/sync_manager.h ('k') | chrome/browser/sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698