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 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "sync/internal_api/public/activation_context.h" |
10 #include "base/sequenced_task_runner.h" | |
11 #include "sync/base/sync_export.h" | |
12 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
13 #include "sync/internal_api/public/non_blocking_sync_common.h" | |
14 | 11 |
15 namespace syncer_v2 { | 12 namespace syncer_v2 { |
16 class ModelTypeProcessor; | |
17 | |
18 // An interface of the core parts of sync. | 13 // An interface of the core parts of sync. |
19 // | 14 // |
20 // In theory, this is the component that provides off-thread sync types with | 15 // In theory, this is the component that provides off-thread sync types with |
21 // functionality to schedule and execute communication with the sync server. In | 16 // functionality to schedule and execute communication with the sync server. In |
22 // practice, this class delegates most of the responsibilty of implemeting this | 17 // practice, this class delegates most of the responsibilty of implemeting this |
23 // functionality to other classes, and most of the interface is exposed not | 18 // functionality to other classes, and most of the interface is exposed not |
24 // directly here but instead through a per-ModelType class that this class helps | 19 // directly here but instead through a per-ModelType class that this class helps |
25 // instantiate. | 20 // instantiate. |
26 class SYNC_EXPORT_PRIVATE SyncContext { | 21 class SYNC_EXPORT_PRIVATE SyncContext { |
27 public: | 22 public: |
28 SyncContext(); | 23 SyncContext(); |
29 virtual ~SyncContext(); | 24 virtual ~SyncContext(); |
30 | 25 |
31 // Initializes the connection between the sync context on the sync thread and | 26 // Initializes the connection between the sync context on the sync thread and |
32 // a proxy for the specified non-blocking sync type that lives on the data | 27 // a proxy for the specified non-blocking sync type that lives on the data |
33 // type's thread. | 28 // type's thread. |
34 virtual void ConnectSyncTypeToWorker( | 29 virtual void ConnectSyncTypeToWorker( |
35 syncer::ModelType type, | 30 syncer::ModelType type, |
36 const DataTypeState& data_type_state, | 31 scoped_ptr<ActivationContext> activation_context) = 0; |
pavely
2015/09/25 18:22:39
nit: When using scoped_ptr it is enough to forward
stanisc
2015/09/26 00:16:01
I wanted to avoid having to include activation_con
| |
37 const UpdateResponseDataList& saved_pending_updates, | |
38 const scoped_refptr<base::SequencedTaskRunner>& datatype_task_runner, | |
39 const base::WeakPtr<ModelTypeProcessor>& type_processor) = 0; | |
40 | 32 |
41 // Disconnects the syncer from the model and stops syncing the type. | 33 // Disconnects the syncer from the model and stops syncing the type. |
42 // | 34 // |
43 // By the time this is called, the model thread should have already | 35 // By the time this is called, the model thread should have already |
44 // invalidated the WeakPtr it sent to us in the connect request. Any | 36 // invalidated the WeakPtr it sent to us in the connect request. Any |
45 // messages sent to that ModelTypeProcessor will not be recived. | 37 // messages sent to that ModelTypeProcessor will not be recived. |
46 // | 38 // |
47 // This is the sync thread's chance to clear state associated with the type. | 39 // This is the sync thread's chance to clear state associated with the type. |
48 // It also causes the syncer to stop requesting updates for this type, and to | 40 // It also causes the syncer to stop requesting updates for this type, and to |
49 // abort any in-progress commit requests. | 41 // abort any in-progress commit requests. |
50 virtual void DisconnectSyncWorker(syncer::ModelType type) = 0; | 42 virtual void DisconnectSyncWorker(syncer::ModelType type) = 0; |
51 }; | 43 }; |
52 | 44 |
53 } // namespace syncer | 45 } // namespace syncer_v2 |
54 | 46 |
55 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ | 47 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_CONTEXT_H_ |
OLD | NEW |