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

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: Fix bug in async encryption, sync to head 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..5b7b74fb39a66045c9abe0bb0cd61537eb22e0cc 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"
@@ -206,18 +207,32 @@ void SyncBackendRegistrar::DeactivateDataType(syncable::ModelType 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;
tim (not reviewing) 2011/09/20 16:04:59 nit / consistency - I'm seeing braceless single-li
akalin 2011/09/20 21:14:42 Done.
+ }
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698