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

Unified Diff: sync/test/engine/injectable_sync_core_proxy.cc

Issue 318193002: sync: Refactor NonBlockingTypeProcessor tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disallow copy and assign Created 6 years, 6 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: sync/test/engine/injectable_sync_core_proxy.cc
diff --git a/sync/test/engine/injectable_sync_core_proxy.cc b/sync/test/engine/injectable_sync_core_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ac96ca4cd3ee7362008c23c73fe0219492b1816c
--- /dev/null
+++ b/sync/test/engine/injectable_sync_core_proxy.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 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 "sync/test/engine/injectable_sync_core_proxy.h"
+
+#include "sync/engine/non_blocking_type_processor.h"
+#include "sync/engine/non_blocking_type_processor_core_interface.h"
+
+namespace syncer {
+
+InjectableSyncCoreProxy::InjectableSyncCoreProxy(
+ NonBlockingTypeProcessorCoreInterface* core)
+ : is_core_connected_(false), processor_core_(core) {
+}
+
+InjectableSyncCoreProxy::~InjectableSyncCoreProxy() {
+}
+
+void InjectableSyncCoreProxy::ConnectTypeToCore(
+ syncer::ModelType type,
+ const DataTypeState& data_type_state,
+ base::WeakPtr<syncer::NonBlockingTypeProcessor> type_processor) {
+ // This class is allowed to participate in only one connection.
+ DCHECK(!is_core_connected_);
+ is_core_connected_ = true;
+
+ // Hands off ownership of our member to the type_processor, while keeping
+ // an unsafe pointer to it. This is why we can only connect once.
+ scoped_ptr<NonBlockingTypeProcessorCoreInterface> core(processor_core_);
+
+ type_processor->OnConnect(core.Pass());
+}
+
+void InjectableSyncCoreProxy::Disconnect(syncer::ModelType type) {
+ // This mock object is not meant for connect and disconnect tests.
+ NOTREACHED() << "Not implemented";
+}
+
+scoped_ptr<SyncCoreProxy> InjectableSyncCoreProxy::Clone() const {
+ // This confuses ownership. We trust that our callers are well-behaved.
+ return scoped_ptr<SyncCoreProxy>(
+ new InjectableSyncCoreProxy(processor_core_));
+}
+
+NonBlockingTypeProcessorCoreInterface*
+InjectableSyncCoreProxy::GetProcessorCore() {
+ return processor_core_;
+}
+
+} // namespace syncer
« no previous file with comments | « sync/test/engine/injectable_sync_core_proxy.h ('k') | sync/test/engine/mock_non_blocking_type_processor_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698