summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 18:48:44 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 18:48:44 +0000
commit26f49f700754e8866a7cda03ad8bbb1c0e187c52 (patch)
treecd30f614924a198940f2091d512061b4c98222e2
parentd9370c5e765f63cada0d14ccc676c01cb05f1846 (diff)
downloadchromium_src-26f49f700754e8866a7cda03ad8bbb1c0e187c52.zip
chromium_src-26f49f700754e8866a7cda03ad8bbb1c0e187c52.tar.gz
chromium_src-26f49f700754e8866a7cda03ad8bbb1c0e187c52.tar.bz2
[Sync] Merge 68568: Remove SyncBackendHost::UpdateEnabledTypes()
Use SyncBackendHost::ConfigureDataTypes() instead and make SyncManager reload enabled types from ModelSafeRoutingInfo. The tests don't make sense in the M11 code, so sadly they had to be left out. BUG=76268 TEST= Review URL: http://codereview.chromium.org/6717007 git-svn-id: svn://svn.chromium.org/chrome/branches/696/src@79428 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/engine/syncapi.cc29
-rw-r--r--chrome/browser/sync/engine/syncapi.h7
-rw-r--r--chrome/browser/sync/glue/data_type_manager_impl.cc2
-rw-r--r--chrome/browser/sync/glue/data_type_manager_impl_unittest.cc4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc18
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h9
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_mock.h1
7 files changed, 29 insertions, 41 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 416df24..ff256db 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -1159,9 +1159,8 @@ class SyncManager::SyncInternal
// Update tokens that we're using in Sync. Email must stay the same.
void UpdateCredentials(const SyncCredentials& credentials);
- // Update the set of enabled sync types. Usually called when the user disables
- // or enables a sync type.
- void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
+ // Called when the user disables or enables a sync type.
+ void UpdateEnabledTypes();
// Tell the sync engine to start the syncing process.
void StartSyncing();
@@ -1521,8 +1520,6 @@ class SyncManager::SyncInternal
// actually communicating with the server).
bool setup_for_test_mode_;
- syncable::ModelTypeSet enabled_types_;
-
ScopedRunnableMethodFactory<SyncManager::SyncInternal> method_factory_;
sync_notifier::ServerNotifierThread* server_notifier_thread_;
@@ -1567,8 +1564,8 @@ void SyncManager::UpdateCredentials(const SyncCredentials& credentials) {
data_->UpdateCredentials(credentials);
}
-void SyncManager::UpdateEnabledTypes(const syncable::ModelTypeSet& types) {
- data_->UpdateEnabledTypes(types);
+void SyncManager::UpdateEnabledTypes() {
+ data_->UpdateEnabledTypes();
}
@@ -1874,13 +1871,17 @@ void SyncManager::SyncInternal::UpdateCredentials(
sync_manager_->RequestNudge();
}
-void SyncManager::SyncInternal::UpdateEnabledTypes(
- const syncable::ModelTypeSet& types) {
+void SyncManager::SyncInternal::UpdateEnabledTypes() {
DCHECK_EQ(MessageLoop::current(), core_message_loop_);
-
- enabled_types_ = types;
+ ModelSafeRoutingInfo routes;
+ registrar_->GetModelSafeRoutingInfo(&routes);
+ syncable::ModelTypeSet enabled_types;
+ for (ModelSafeRoutingInfo::const_iterator it = routes.begin();
+ it != routes.end(); ++it) {
+ enabled_types.insert(it->first);
+ }
if (server_notifier_thread_ != NULL) {
- server_notifier_thread_->UpdateEnabledTypes(types);
+ server_notifier_thread_->UpdateEnabledTypes(enabled_types);
}
}
@@ -1911,7 +1912,7 @@ void SyncManager::SyncInternal::InitializeTalkMediator() {
// Since we may be initialized more than once, make sure that any
// newly created server notifier thread has the latest enabled types.
- server_notifier_thread_->UpdateEnabledTypes(enabled_types_);
+ UpdateEnabledTypes();
} else {
notifier::MediatorThread* mediator_thread =
new notifier::MediatorThreadImpl(notifier_options_);
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 3629793..e38566e 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -884,9 +884,8 @@ class SyncManager {
// Update tokens that we're using in Sync. Email must stay the same.
void UpdateCredentials(const SyncCredentials& credentials);
- // Update the set of enabled sync types. Usually called when the user disables
- // or enables a sync type.
- void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
+ // Called when the user disables or enables a sync type.
+ void UpdateEnabledTypes();
// Start the SyncerThread.
// TODO(tim): With the new impl, this would mean starting "NORMAL" operation.
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc
index a1ef08f..57c8b9b 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl.cc
@@ -84,8 +84,6 @@ void DataTypeManagerImpl::Configure(const TypeSet& desired_types) {
return;
}
- backend_->UpdateEnabledTypes(desired_types);
-
last_requested_types_ = desired_types;
// Add any data type controllers into the needs_start_ list that are
// currently NOT_RUNNING or STOPPING.
diff --git a/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc b/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
index b1608d6..dfb0881 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -139,7 +139,6 @@ class DataTypeManagerImplTest : public testing::Test {
}
void SetBackendExpectations(int times) {
- EXPECT_CALL(backend_, UpdateEnabledTypes(_)).Times(times);
EXPECT_CALL(backend_, ConfigureDataTypes(_, _, _)).Times(times);
EXPECT_CALL(backend_, StartSyncingWithServer()).Times(times);
EXPECT_CALL(backend_, RequestPause()).Times(times);
@@ -159,7 +158,6 @@ TEST_F(DataTypeManagerImplTest, NoControllers) {
DataTypeManagerImpl dtm(&backend_, controllers_);
SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK);
- EXPECT_CALL(backend_, UpdateEnabledTypes(_));
dtm.Configure(types_);
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm.state());
dtm.Stop();
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index e079f8e..4f60d75 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -211,14 +211,6 @@ void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
credentials));
}
-void SyncBackendHost::UpdateEnabledTypes(
- const syncable::ModelTypeSet& types) {
- core_thread_.message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(core_.get(),
- &SyncBackendHost::Core::DoUpdateEnabledTypes,
- types));
-}
-
void SyncBackendHost::StartSyncingWithServer() {
core_thread_.message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoStartSyncing));
@@ -415,6 +407,11 @@ void SyncBackendHost::ConfigureDataTypes(
// complete, the configure_ready_task_ is run via an
// OnInitializationComplete notification.
ScheduleSyncEventForConfigChange(deleted_type, added_types);
+
+ // Notify the SyncManager about the new types.
+ core_thread_.message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(core_.get(),
+ &SyncBackendHost::Core::DoUpdateEnabledTypes));
}
void SyncBackendHost::ScheduleSyncEventForConfigChange(bool deleted_type,
@@ -728,10 +725,9 @@ void SyncBackendHost::Core::DoUpdateCredentials(
syncapi_->UpdateCredentials(credentials);
}
-void SyncBackendHost::Core::DoUpdateEnabledTypes(
- const syncable::ModelTypeSet& types) {
+void SyncBackendHost::Core::DoUpdateEnabledTypes() {
DCHECK(MessageLoop::current() == host_->core_thread_.message_loop());
- syncapi_->UpdateEnabledTypes(types);
+ syncapi_->UpdateEnabledTypes();
}
void SyncBackendHost::Core::DoStartSyncing() {
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index a822994..2815595 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -134,8 +134,6 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
// Called from |frontend_loop| to update SyncCredentials.
void UpdateCredentials(const sync_api::SyncCredentials& credentials);
- virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
-
// This starts the SyncerThread running a Syncer object to communicate with
// sync servers. Until this is called, no changes will leave or enter this
// browser from the cloud / sync servers.
@@ -337,9 +335,8 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
// update on behalf of SyncBackendHost::UpdateCredentials
void DoUpdateCredentials(const sync_api::SyncCredentials& credentials);
- // Update the set of enabled sync types. Usually called when the user disables
- // or enables a sync type.
- void DoUpdateEnabledTypes(const syncable::ModelTypeSet& types);
+ // Called when the user disables or enables a sync type.
+ void DoUpdateEnabledTypes();
// Called on the SyncBackendHost core_thread_ to tell the syncapi to start
// syncing (generally after initialization and authentication).
diff --git a/chrome/browser/sync/glue/sync_backend_host_mock.h b/chrome/browser/sync/glue/sync_backend_host_mock.h
index 12c6df1..16f2594 100644
--- a/chrome/browser/sync/glue/sync_backend_host_mock.h
+++ b/chrome/browser/sync/glue/sync_backend_host_mock.h
@@ -27,7 +27,6 @@ class SyncBackendHostMock : public SyncBackendHost {
MOCK_METHOD0(RequestPause, bool());
MOCK_METHOD0(RequestResume, bool());
MOCK_METHOD0(StartSyncingWithServer, void());
- MOCK_METHOD1(UpdateEnabledTypes, void(const syncable::ModelTypeSet&));
};
} // namespace browser_sync