OLD | NEW |
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/internal_api/sync_context_proxy_impl.h" | 5 #include "sync/internal_api/sync_context_proxy_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "sync/internal_api/public/activation_context.h" |
11 #include "sync/internal_api/public/non_blocking_sync_common.h" | |
12 #include "sync/internal_api/public/sync_context.h" | 11 #include "sync/internal_api/public/sync_context.h" |
13 | 12 |
14 namespace syncer_v2 { | 13 namespace syncer_v2 { |
15 | 14 |
16 SyncContextProxyImpl::SyncContextProxyImpl( | 15 SyncContextProxyImpl::SyncContextProxyImpl( |
17 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner, | 16 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner, |
18 const base::WeakPtr<SyncContext>& sync_context) | 17 const base::WeakPtr<SyncContext>& sync_context) |
19 : sync_task_runner_(sync_task_runner), sync_context_(sync_context) { | 18 : sync_task_runner_(sync_task_runner), sync_context_(sync_context) { |
20 } | 19 } |
21 | 20 |
22 SyncContextProxyImpl::~SyncContextProxyImpl() { | 21 SyncContextProxyImpl::~SyncContextProxyImpl() { |
23 } | 22 } |
24 | 23 |
25 void SyncContextProxyImpl::ConnectTypeToSync( | 24 void SyncContextProxyImpl::ConnectTypeToSync( |
26 syncer::ModelType type, | 25 syncer::ModelType type, |
27 const DataTypeState& data_type_state, | 26 scoped_ptr<ActivationContext> activation_context) { |
28 const UpdateResponseDataList& saved_pending_updates, | |
29 const base::WeakPtr<ModelTypeProcessor>& type_processor) { | |
30 VLOG(1) << "ConnectTypeToSync: " << ModelTypeToString(type); | 27 VLOG(1) << "ConnectTypeToSync: " << ModelTypeToString(type); |
31 sync_task_runner_->PostTask(FROM_HERE, | 28 sync_task_runner_->PostTask( |
32 base::Bind(&SyncContext::ConnectSyncTypeToWorker, | 29 FROM_HERE, |
33 sync_context_, | 30 base::Bind(&SyncContext::ConnectSyncTypeToWorker, sync_context_, type, |
34 type, | 31 base::Passed(&activation_context))); |
35 data_type_state, | |
36 saved_pending_updates, | |
37 base::ThreadTaskRunnerHandle::Get(), | |
38 type_processor)); | |
39 } | 32 } |
40 | 33 |
41 void SyncContextProxyImpl::Disconnect(syncer::ModelType type) { | 34 void SyncContextProxyImpl::Disconnect(syncer::ModelType type) { |
42 sync_task_runner_->PostTask( | 35 sync_task_runner_->PostTask( |
43 FROM_HERE, | 36 FROM_HERE, |
44 base::Bind(&SyncContext::DisconnectSyncWorker, sync_context_, type)); | 37 base::Bind(&SyncContext::DisconnectSyncWorker, sync_context_, type)); |
45 } | 38 } |
46 | 39 |
47 scoped_ptr<SyncContextProxy> SyncContextProxyImpl::Clone() const { | 40 scoped_ptr<SyncContextProxy> SyncContextProxyImpl::Clone() const { |
48 return scoped_ptr<SyncContextProxy>( | 41 return scoped_ptr<SyncContextProxy>( |
49 new SyncContextProxyImpl(sync_task_runner_, sync_context_)); | 42 new SyncContextProxyImpl(sync_task_runner_, sync_context_)); |
50 } | 43 } |
51 | 44 |
52 } // namespace syncer | 45 } // namespace syncer |
OLD | NEW |