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

Side by Side Diff: sync/test/engine/injectable_sync_core_proxy.cc

Issue 351523003: sync: Mass rename of non-blocking sync classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const ref some smart pointers Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sync/test/engine/injectable_sync_core_proxy.h"
6
7 #include "sync/engine/non_blocking_type_processor.h"
8 #include "sync/engine/non_blocking_type_processor_core_interface.h"
9
10 namespace syncer {
11
12 InjectableSyncCoreProxy::InjectableSyncCoreProxy(
13 NonBlockingTypeProcessorCoreInterface* core)
14 : is_core_connected_(false), processor_core_(core) {
15 }
16
17 InjectableSyncCoreProxy::~InjectableSyncCoreProxy() {
18 }
19
20 void InjectableSyncCoreProxy::ConnectTypeToCore(
21 syncer::ModelType type,
22 const DataTypeState& data_type_state,
23 base::WeakPtr<syncer::NonBlockingTypeProcessor> type_processor) {
24 // This class is allowed to participate in only one connection.
25 DCHECK(!is_core_connected_);
26 is_core_connected_ = true;
27
28 // Hands off ownership of our member to the type_processor, while keeping
29 // an unsafe pointer to it. This is why we can only connect once.
30 scoped_ptr<NonBlockingTypeProcessorCoreInterface> core(processor_core_);
31
32 type_processor->OnConnect(core.Pass());
33 }
34
35 void InjectableSyncCoreProxy::Disconnect(syncer::ModelType type) {
36 // This should delete the core, but we don't own it.
37 processor_core_ = NULL;
38 }
39
40 scoped_ptr<SyncCoreProxy> InjectableSyncCoreProxy::Clone() const {
41 // This confuses ownership. We trust that our callers are well-behaved.
42 return scoped_ptr<SyncCoreProxy>(
43 new InjectableSyncCoreProxy(processor_core_));
44 }
45
46 NonBlockingTypeProcessorCoreInterface*
47 InjectableSyncCoreProxy::GetProcessorCore() {
48 return processor_core_;
49 }
50
51 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/engine/injectable_sync_core_proxy.h ('k') | sync/test/engine/mock_model_type_sync_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698