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

Unified Diff: chrome/browser/sync/glue/sync_backend_registrar.cc

Issue 7926001: [Sync] Move change-related methods out of SyncManager::Observer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 3 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/glue/sync_backend_registrar.cc
diff --git a/chrome/browser/sync/glue/sync_backend_registrar.cc b/chrome/browser/sync/glue/sync_backend_registrar.cc
index 5edf2b7e2435ffaebb9dbc77625e84b15a746f35..7f1ea459c807c015f81c7bb8fa038fdf4541db61 100644
--- a/chrome/browser/sync/glue/sync_backend_registrar.cc
+++ b/chrome/browser/sync/glue/sync_backend_registrar.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
#include <algorithm>
+#include <cstddef>
#include "base/compiler_specific.h"
#include "base/logging.h"
@@ -198,26 +199,40 @@ void SyncBackendRegistrar::DeactivateDataType(syncable::ModelType type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::AutoLock lock(lock_);
ChangeProcessor* change_processor = GetProcessorUnsafe(type);
- if (change_processor) {
+ if (change_processor)
change_processor->Stop();
- }
+
routing_info_.erase(type);
ignore_result(processors_.erase(type));
DCHECK(!GetProcessorUnsafe(type));
}
-ChangeProcessor* SyncBackendRegistrar::GetProcessor(
- syncable::ModelType type) {
- base::AutoLock lock(lock_);
- ChangeProcessor* processor = GetProcessorUnsafe(type);
- if (!processor) {
- return NULL;
- }
- // We can only check if |processor| exists, as otherwise the type is
- // mapped to GROUP_PASSIVE.
- CHECK(IsCurrentThreadSafeForModel(type));
- CHECK(processor->IsRunning());
- return processor;
+bool SyncBackendRegistrar::IsTypeActivatedForTest(
+ syncable::ModelType type) const {
+ return GetProcessor(type) != NULL;
+}
+
+void SyncBackendRegistrar::OnChangesApplied(
+ syncable::ModelType model_type,
+ const sync_api::BaseTransaction* trans,
+ const sync_api::ImmutableChangeRecordList& changes) {
+ ChangeProcessor* processor = GetProcessor(model_type);
+ if (!processor)
+ return;
+
+ processor->ApplyChangesFromSyncModel(trans, changes);
+}
+
+void SyncBackendRegistrar::OnChangesComplete(
+ syncable::ModelType model_type) {
+ ChangeProcessor* processor = GetProcessor(model_type);
+ if (!processor)
+ return;
+
+ // This call just notifies the processor that it can commit; it
+ // already buffered any changes it plans to makes so needs no
+ // further information.
+ processor->CommitChangesFromSyncModel();
}
void SyncBackendRegistrar::GetWorkers(
@@ -237,8 +252,22 @@ void SyncBackendRegistrar::GetModelSafeRoutingInfo(
out->swap(copy);
}
+ChangeProcessor* SyncBackendRegistrar::GetProcessor(
+ syncable::ModelType type) const {
+ base::AutoLock lock(lock_);
+ ChangeProcessor* processor = GetProcessorUnsafe(type);
+ if (!processor)
+ return NULL;
+
+ // We can only check if |processor| exists, as otherwise the type is
+ // mapped to GROUP_PASSIVE.
+ CHECK(IsCurrentThreadSafeForModel(type));
+ CHECK(processor->IsRunning());
+ return processor;
+}
+
ChangeProcessor* SyncBackendRegistrar::GetProcessorUnsafe(
- syncable::ModelType type) {
+ syncable::ModelType type) const {
lock_.AssertAcquired();
std::map<syncable::ModelType, ChangeProcessor*>::const_iterator it =
processors_.find(type);
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar.h ('k') | chrome/browser/sync/glue/sync_backend_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698