summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 00:26:55 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 00:26:55 +0000
commitfdf4e2506a6dc6fc6d102e72c58511aa1bcfd9ac (patch)
treee0d26487de15eebc1e602318d1ccf84e1e07c8bd /sync
parentc423cb934ddb53672b4d1b15ede1bece0a715fee (diff)
downloadchromium_src-fdf4e2506a6dc6fc6d102e72c58511aa1bcfd9ac.zip
chromium_src-fdf4e2506a6dc6fc6d102e72c58511aa1bcfd9ac.tar.gz
chromium_src-fdf4e2506a6dc6fc6d102e72c58511aa1bcfd9ac.tar.bz2
[Sync] Add support for automatic enabling of syncing tab favicons.
We add the sync_tab_favicons field to the nigori node and add support for automatically enabling the feature when we receive a new nigori node. Once we do enable the feature, the browser will only start writing favicons after the next restart. BUG=92728 TEST=using python testserver to enable sync tab favicons, then restarting. Review URL: http://codereview.chromium.org/10235013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/sync_manager.cc14
-rw-r--r--sync/internal_api/sync_manager.h7
-rw-r--r--sync/protocol/nigori_specifics.proto3
-rw-r--r--sync/protocol/proto_value_conversions.cc1
-rw-r--r--sync/sync.gyp1
-rw-r--r--sync/util/experiments.h32
6 files changed, 51 insertions, 7 deletions
diff --git a/sync/internal_api/sync_manager.cc b/sync/internal_api/sync_manager.cc
index d7d8c8a..f33fefa 100644
--- a/sync/internal_api/sync_manager.cc
+++ b/sync/internal_api/sync_manager.cc
@@ -52,6 +52,7 @@
#include "sync/syncable/model_type_payload_map.h"
#include "sync/syncable/syncable.h"
#include "sync/util/cryptographer.h"
+#include "sync/util/experiments.h"
#include "sync/util/get_session_name.h"
#include "sync/util/time.h"
@@ -2478,7 +2479,7 @@ syncable::ModelTypeSet SyncManager::GetEncryptedDataTypesForTest() const {
return GetEncryptedTypes(&trans);
}
-bool SyncManager::ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add)
+bool SyncManager::ReceivedExperiment(browser_sync::Experiments* experiments)
const {
ReadTransaction trans(FROM_HERE, GetUserShare());
ReadNode node(&trans);
@@ -2486,11 +2487,16 @@ bool SyncManager::ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add)
DVLOG(1) << "Couldn't find Nigori node.";
return false;
}
+ bool found_experiment = false;
if (node.GetNigoriSpecifics().sync_tabs()) {
- to_add->Put(syncable::SESSIONS);
- return true;
+ experiments->sync_tabs = true;
+ found_experiment = true;
+ }
+ if (node.GetNigoriSpecifics().sync_tab_favicons()) {
+ experiments->sync_tab_favicons = true;
+ found_experiment = true;
}
- return false;
+ return found_experiment;
}
bool SyncManager::HasUnsyncedItems() const {
diff --git a/sync/internal_api/sync_manager.h b/sync/internal_api/sync_manager.h
index 8288164..cfc05a0 100644
--- a/sync/internal_api/sync_manager.h
+++ b/sync/internal_api/sync_manager.h
@@ -25,6 +25,7 @@
namespace browser_sync {
class Encryptor;
+struct Experiments;
class ExtensionsActivityMonitor;
class JsBackend;
class JsEventHandler;
@@ -591,10 +592,10 @@ class SyncManager {
// Note: opens a transaction. May be called from any thread.
syncable::ModelTypeSet GetEncryptedDataTypesForTest() const;
- // Reads the nigori node to determine if any experimental types should be
- // enabled.
+ // Reads the nigori node to determine if any experimental features should
+ // be enabled.
// Note: opens a transaction. May be called on any thread.
- bool ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) const;
+ bool ReceivedExperiment(browser_sync::Experiments* experiments) const;
// Uses a read-only transaction to determine if the directory being synced has
// any remaining unsynced items. May be called on any thread.
diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto
index 50f5014..8a0effd 100644
--- a/sync/protocol/nigori_specifics.proto
+++ b/sync/protocol/nigori_specifics.proto
@@ -90,5 +90,8 @@ message NigoriSpecifics {
// User device information. Contains information about each device that has a
// sync-enabled Chrome browser connected to the user account.
repeated DeviceInformation device_information = 28;
+
+ // Enable syncing favicons as part of tab sync.
+ optional bool sync_tab_favicons = 29;
}
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 70b3ea1..cb4b1e33 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -310,6 +310,7 @@ DictionaryValue* NigoriSpecificsToValue(
SET_BOOL(sync_tabs);
SET_BOOL(encrypt_everything);
SET_REP(device_information, DeviceInformationToValue);
+ SET_BOOL(sync_tab_favicons);
return value;
}
diff --git a/sync/sync.gyp b/sync/sync.gyp
index 81c05f9..bc6c263 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -157,6 +157,7 @@
'util/data_type_histogram.h',
'util/encryptor.h',
'util/enum_set.h',
+ 'util/experiments.h',
'util/extensions_activity_monitor.cc',
'util/extensions_activity_monitor.h',
'util/get_session_name.cc',
diff --git a/sync/util/experiments.h b/sync/util/experiments.h
new file mode 100644
index 0000000..7cd77af
--- /dev/null
+++ b/sync/util/experiments.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_UTIL_EXPERIMENTS_
+#define SYNC_UTIL_EXPERIMENTS_
+#pragma once
+
+#include "sync/syncable/model_type.h"
+
+namespace browser_sync {
+
+// A structure to hold the enable status of experimental sync features.
+struct Experiments {
+ Experiments() : sync_tabs(false), sync_tab_favicons(false) {}
+
+ bool Matches(const Experiments& rhs) {
+ return (sync_tabs == rhs.sync_tabs) &&
+ (sync_tab_favicons == rhs.sync_tab_favicons);
+ }
+
+ // Enable the tab sync (SESSIONS) datatype.
+ bool sync_tabs;
+
+ // Enable syncing of favicons within tab sync (only has an effect if tab sync
+ // is already enabled). This takes effect on the next restart.
+ bool sync_tab_favicons;
+};
+
+}
+
+#endif // SYNC_UTIL_EXPERIMENTS_