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

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

Issue 1285443002: move V2 classes in chrome/engine to syncer_v2 namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/test/engine/injectable_sync_context_proxy.h" 5 #include "sync/test/engine/injectable_sync_context_proxy.h"
6 6
7 #include "sync/engine/model_type_sync_proxy_impl.h" 7 #include "sync/engine/model_type_sync_proxy_impl.h"
8 #include "sync/engine/model_type_sync_worker.h" 8 #include "sync/engine/model_type_sync_worker.h"
9 9
10 namespace syncer { 10 namespace syncer_v2 {
11 11
12 InjectableSyncContextProxy::InjectableSyncContextProxy( 12 InjectableSyncContextProxy::InjectableSyncContextProxy(
13 ModelTypeSyncWorker* worker) 13 ModelTypeSyncWorker* worker)
14 : is_worker_connected_(false), worker_(worker) { 14 : is_worker_connected_(false), worker_(worker) {
15 } 15 }
16 16
17 InjectableSyncContextProxy::~InjectableSyncContextProxy() { 17 InjectableSyncContextProxy::~InjectableSyncContextProxy() {
18 } 18 }
19 19
20 void InjectableSyncContextProxy::ConnectTypeToSync( 20 void InjectableSyncContextProxy::ConnectTypeToSync(
21 syncer::ModelType type, 21 syncer::ModelType type,
22 const syncer_v2::DataTypeState& data_type_state, 22 const DataTypeState& data_type_state,
23 const syncer_v2::UpdateResponseDataList& response_list, 23 const UpdateResponseDataList& response_list,
24 const base::WeakPtr<syncer::ModelTypeSyncProxyImpl>& type_sync_proxy) { 24 const base::WeakPtr<ModelTypeSyncProxyImpl>& type_sync_proxy) {
25 // This class is allowed to participate in only one connection. 25 // This class is allowed to participate in only one connection.
26 DCHECK(!is_worker_connected_); 26 DCHECK(!is_worker_connected_);
27 is_worker_connected_ = true; 27 is_worker_connected_ = true;
28 28
29 // Hands off ownership of our member to the type_sync_proxy, while keeping 29 // Hands off ownership of our member to the type_sync_proxy, while keeping
30 // an unsafe pointer to it. This is why we can only connect once. 30 // an unsafe pointer to it. This is why we can only connect once.
31 scoped_ptr<ModelTypeSyncWorker> worker(worker_); 31 scoped_ptr<ModelTypeSyncWorker> worker(worker_);
32 32
33 type_sync_proxy->OnConnect(worker.Pass()); 33 type_sync_proxy->OnConnect(worker.Pass());
34 } 34 }
35 35
36 void InjectableSyncContextProxy::Disconnect(syncer::ModelType type) { 36 void InjectableSyncContextProxy::Disconnect(syncer::ModelType type) {
37 // This should delete the worker, but we don't own it. 37 // This should delete the worker, but we don't own it.
38 worker_ = NULL; 38 worker_ = NULL;
39 } 39 }
40 40
41 scoped_ptr<syncer_v2::SyncContextProxy> InjectableSyncContextProxy::Clone() 41 scoped_ptr<SyncContextProxy> InjectableSyncContextProxy::Clone() const {
42 const {
43 // This confuses ownership. We trust that our callers are well-behaved. 42 // This confuses ownership. We trust that our callers are well-behaved.
44 return scoped_ptr<syncer_v2::SyncContextProxy>( 43 return scoped_ptr<SyncContextProxy>(new InjectableSyncContextProxy(worker_));
45 new InjectableSyncContextProxy(worker_));
46 } 44 }
47 45
48 ModelTypeSyncWorker* InjectableSyncContextProxy::GetWorker() { 46 ModelTypeSyncWorker* InjectableSyncContextProxy::GetWorker() {
49 return worker_; 47 return worker_;
50 } 48 }
51 49
52 } // namespace syncer 50 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/engine/injectable_sync_context_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