diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 01:46:05 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-12 01:46:05 +0000 |
commit | 9508f239f64b85fa913df6f7518c231b6bf7e78c (patch) | |
tree | efcce01fd3f4db7d015cd126fbe8e98dd68a6e36 /sync/internal_api/test | |
parent | d9615f5d7d3bb74864ff8d7750221fdbb1ee48b2 (diff) | |
download | chromium_src-9508f239f64b85fa913df6f7518c231b6bf7e78c.zip chromium_src-9508f239f64b85fa913df6f7518c231b6bf7e78c.tar.gz chromium_src-9508f239f64b85fa913df6f7518c231b6bf7e78c.tar.bz2 |
sync: Add interface for SyncCoreProxy
Defines an interface for SyncCoreProxy. This will be used for testing.
The SyncCoreProxy is a natural boundary for tests. To its clients, it
represents the sync thread and all of its functionality. By allowing it
to be overloaded in tests, we can stub out all of the sync thread
functionality so we can better test the parts that communicate with it.
This required some fairly large changes. In order to allow it to be
used as an interface, the SyncCoreProxy could no longer be stored on the
stack and copied around everywhere. The objects that call its virtual
functions must manage it as a pointer or reference, rather than
a concrete object.
For now, ownership is settled by having one or two elements on each
thread hold a scoped_ptr to their own copy of it. The SyncCoreProxy is
passed around as a pointer, and ownership is not transferred in these
calls. Objects that want to keep their own private copy can make use of
the Clone() method and store the resulting copy in a scoped_ptr.
BUG=351005
Review URL: https://codereview.chromium.org/225863006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/test')
-rw-r--r-- | sync/internal_api/test/fake_sync_manager.cc | 4 | ||||
-rw-r--r-- | sync/internal_api/test/null_sync_core_proxy.cc | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc index 9f1abb8..c7873a8 100644 --- a/sync/internal_api/test/fake_sync_manager.cc +++ b/sync/internal_api/test/fake_sync_manager.cc @@ -218,8 +218,8 @@ UserShare* FakeSyncManager::GetUserShare() { return test_user_share_.user_share(); } -base::WeakPtr<syncer::SyncCore> FakeSyncManager::GetSyncCore() { - return base::WeakPtr<syncer::SyncCore>(); +syncer::SyncCoreProxy* FakeSyncManager::GetSyncCoreProxy() { + return &null_sync_core_proxy_; } const std::string FakeSyncManager::cache_guid() { diff --git a/sync/internal_api/test/null_sync_core_proxy.cc b/sync/internal_api/test/null_sync_core_proxy.cc new file mode 100644 index 0000000..866e68b --- /dev/null +++ b/sync/internal_api/test/null_sync_core_proxy.cc @@ -0,0 +1,23 @@ +// 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/internal_api/public/test/null_sync_core_proxy.h" + +namespace syncer { + +NullSyncCoreProxy::NullSyncCoreProxy() {} + +NullSyncCoreProxy::~NullSyncCoreProxy() {} + +void NullSyncCoreProxy::ConnectTypeToCore( + syncer::ModelType type, + base::WeakPtr<NonBlockingTypeProcessor> processor) { + NOTREACHED() << "NullSyncCoreProxy is not meant to be used"; +} + +scoped_ptr<SyncCoreProxy> NullSyncCoreProxy::Clone() { + return scoped_ptr<SyncCoreProxy>(new NullSyncCoreProxy()); +} + +} // namespace syncer |