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

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: Rebase and fix compile 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..68dcfae9b0f69880a1cbb7259a0f2de7cb5f56d2
--- /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_,
+ initial_sync_data,
+ sync_processor_);
+}
+
+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
« no previous file with comments | « chrome/browser/sync/glue/syncable_service_adapter.h ('k') | chrome/browser/sync/profile_sync_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698