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

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

Issue 1368683003: USS SyncContextProxy / data type activation refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/commit_queue.h" 7 #include "sync/engine/commit_queue.h"
8 #include "sync/engine/model_type_processor_impl.h" 8 #include "sync/engine/model_type_processor_impl.h"
9 9
10 namespace syncer_v2 { 10 namespace syncer_v2 {
11 11
12 InjectableSyncContextProxy::InjectableSyncContextProxy( 12 InjectableSyncContextProxy::InjectableSyncContextProxy(
13 CommitQueue* queue) 13 CommitQueue* queue)
14 : is_worker_connected_(false), queue_(queue) { 14 : is_worker_connected_(false), queue_(queue) {
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 DataTypeState& data_type_state, 22 scoped_ptr<ActivationContext> activation_context) {
23 const UpdateResponseDataList& response_list,
24 const base::WeakPtr<ModelTypeProcessor>& type_processor) {
25 // This class is allowed to participate in only one connection. 23 // This class is allowed to participate in only one connection.
26 DCHECK(!is_worker_connected_); 24 DCHECK(!is_worker_connected_);
27 is_worker_connected_ = true; 25 is_worker_connected_ = true;
28 26
29 // Hands off ownership of our member to the type_processor, while keeping 27 // Hands off ownership of our member to the type_processor, while keeping
30 // an unsafe pointer to it. This is why we can only connect once. 28 // an unsafe pointer to it. This is why we can only connect once.
31 scoped_ptr<CommitQueue> queue(queue_); 29 scoped_ptr<CommitQueue> queue(queue_);
32 30
33 type_processor->OnConnect(queue.Pass()); 31 activation_context->type_processor->OnConnect(queue.Pass());
34 } 32 }
35 33
36 void InjectableSyncContextProxy::Disconnect(syncer::ModelType type) { 34 void InjectableSyncContextProxy::Disconnect(syncer::ModelType type) {
37 // This should delete the queue, but we don't own it. 35 // This should delete the queue, but we don't own it.
38 queue_ = NULL; 36 queue_ = NULL;
39 } 37 }
40 38
41 scoped_ptr<SyncContextProxy> InjectableSyncContextProxy::Clone() const { 39 scoped_ptr<SyncContextProxy> InjectableSyncContextProxy::Clone() const {
42 // This confuses ownership. We trust that our callers are well-behaved. 40 // This confuses ownership. We trust that our callers are well-behaved.
43 return scoped_ptr<SyncContextProxy>(new InjectableSyncContextProxy(queue_)); 41 return scoped_ptr<SyncContextProxy>(new InjectableSyncContextProxy(queue_));
44 } 42 }
45 43
46 CommitQueue* InjectableSyncContextProxy::GetQueue() { 44 CommitQueue* InjectableSyncContextProxy::GetQueue() {
47 return queue_; 45 return queue_;
48 } 46 }
49 47
50 } // namespace syncer 48 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698