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

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

Issue 6995008: Implement new SyncAPI and convert Preferences to it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Foward Declare++ Created 9 years, 7 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/syncable_service_adapter.cc
diff --git a/chrome/browser/sync/glue/syncable_service_adapter.cc b/chrome/browser/sync/glue/syncable_service_adapter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8775badf2de4b9df6a205aca84df3793529a9d32
--- /dev/null
+++ b/chrome/browser/sync/glue/syncable_service_adapter.cc
@@ -0,0 +1,63 @@
+// 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.
+
+#include "chrome/browser/sync/glue/syncable_service_adapter.h"
+
+#include "chrome/browser/sync/api/syncable_service.h"
+#include "chrome/browser/sync/api/sync_data.h"
+#include "chrome/browser/sync/glue/generic_change_processor.h"
+
+namespace browser_sync {
+
+SyncableServiceAdapter::SyncableServiceAdapter(
+ syncable::ModelType type,
+ SyncableService* service,
+ GenericChangeProcessor* sync_processor)
+ : syncing_(false),
+ type_(type),
+ service_(service),
+ sync_processor_(sync_processor) {
+}
+
+SyncableServiceAdapter::~SyncableServiceAdapter() {
+ if (syncing_) {
+ NOTREACHED();
+ LOG(ERROR) << "SyncableServiceAdapter for "
+ << syncable::ModelTypeToString(type_) << " destroyed before "
+ << "without being shut down properly.";
+ service_->StopSyncing(type_);
+ }
+}
+
+bool SyncableServiceAdapter::AssociateModels() {
+ syncing_ = true;
+ SyncDataList initial_sync_data;
+ if (!sync_processor_->GetSyncDataForType(type_, &initial_sync_data)) {
+ return false;
+ }
+ return service_->MergeDataAndStartSyncing(type_,
+ sync_processor_,
+ initial_sync_data);
+}
+
+bool SyncableServiceAdapter::DisassociateModels() {
+ service_->StopSyncing(type_);
+ syncing_ = false;
+ return true;
+}
+
+bool SyncableServiceAdapter::SyncModelHasUserCreatedNodes(bool* has_nodes) {
+ return sync_processor_->SyncModelHasUserCreatedNodes(type_, has_nodes);
+}
+
+void SyncableServiceAdapter::AbortAssociation() {
+ service_->StopSyncing(type_);
+ syncing_ = false;
+}
+
+bool SyncableServiceAdapter::CryptoReadyIfNecessary() {
+ return sync_processor_->CryptoReadyIfNecessary(type_);
+}
+
+} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698