OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // SyncSessionContext encapsulates the contextual information and engine | 5 // SyncSessionContext encapsulates the contextual information and engine |
6 // components specific to a SyncSession. Unlike the SyncSession, the context | 6 // components specific to a SyncSession. Unlike the SyncSession, the context |
7 // can be reused across several sync cycles. | 7 // can be reused across several sync cycles. |
8 // | 8 // |
9 // The context does not take ownership of its pointer members. It's up to | 9 // The context does not take ownership of its pointer members. It's up to |
10 // the surrounding classes to ensure those members remain valid while the | 10 // the surrounding classes to ensure those members remain valid while the |
11 // context is in use. | 11 // context is in use. |
12 // | 12 // |
13 // It can only be used from the SyncerThread. | 13 // It can only be used from the SyncerThread. |
14 | 14 |
15 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 15 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
16 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 16 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
17 | 17 |
18 #include <map> | |
19 #include <string> | 18 #include <string> |
20 #include <vector> | |
21 | 19 |
22 #include "base/stl_util.h" | |
23 #include "sync/base/sync_export.h" | 20 #include "sync/base/sync_export.h" |
24 #include "sync/engine/sync_directory_commit_contributor.h" | 21 #include "sync/engine/model_type_registry.h" |
25 #include "sync/engine/sync_directory_update_handler.h" | |
26 #include "sync/engine/sync_engine_event.h" | 22 #include "sync/engine/sync_engine_event.h" |
27 #include "sync/engine/syncer_types.h" | |
28 #include "sync/engine/traffic_recorder.h" | 23 #include "sync/engine/traffic_recorder.h" |
29 #include "sync/internal_api/public/engine/model_safe_worker.h" | |
30 #include "sync/protocol/sync.pb.h" | |
31 #include "sync/sessions/debug_info_getter.h" | 24 #include "sync/sessions/debug_info_getter.h" |
32 | 25 |
33 namespace syncer { | 26 namespace syncer { |
34 | 27 |
35 class ExtensionsActivity; | 28 class ExtensionsActivity; |
29 class ModelTypeRegistry; | |
36 class ServerConnectionManager; | 30 class ServerConnectionManager; |
37 | 31 |
38 namespace syncable { | 32 namespace syncable { |
39 class Directory; | 33 class Directory; |
40 } | 34 } |
41 | 35 |
42 // Default number of items a client can commit in a single message. | 36 // Default number of items a client can commit in a single message. |
43 static const int kDefaultMaxCommitBatchSize = 25; | 37 static const int kDefaultMaxCommitBatchSize = 25; |
44 | 38 |
45 namespace sessions { | 39 namespace sessions { |
46 class TestScopedSessionEventListener; | 40 class TestScopedSessionEventListener; |
47 | 41 |
48 class SYNC_EXPORT_PRIVATE SyncSessionContext { | 42 class SYNC_EXPORT_PRIVATE SyncSessionContext { |
49 public: | 43 public: |
50 SyncSessionContext(ServerConnectionManager* connection_manager, | 44 SyncSessionContext(ServerConnectionManager* connection_manager, |
51 syncable::Directory* directory, | 45 syncable::Directory* directory, |
52 const std::vector<ModelSafeWorker*>& workers, | |
53 ExtensionsActivity* extensions_activity, | 46 ExtensionsActivity* extensions_activity, |
54 const std::vector<SyncEngineEventListener*>& listeners, | 47 const std::vector<SyncEngineEventListener*>& listeners, |
55 DebugInfoGetter* debug_info_getter, | 48 DebugInfoGetter* debug_info_getter, |
56 TrafficRecorder* traffic_recorder, | 49 TrafficRecorder* traffic_recorder, |
50 ModelTypeRegistry* model_type_registry, | |
57 bool keystore_encryption_enabled, | 51 bool keystore_encryption_enabled, |
58 bool client_enabled_pre_commit_update_avoidance, | 52 bool client_enabled_pre_commit_update_avoidance, |
59 const std::string& invalidator_client_id); | 53 const std::string& invalidator_client_id); |
60 | 54 |
61 ~SyncSessionContext(); | 55 ~SyncSessionContext(); |
62 | 56 |
63 ServerConnectionManager* connection_manager() { | 57 ServerConnectionManager* connection_manager() { |
64 return connection_manager_; | 58 return connection_manager_; |
65 } | 59 } |
66 syncable::Directory* directory() { | 60 syncable::Directory* directory() { |
67 return directory_; | 61 return directory_; |
68 } | 62 } |
69 | 63 |
70 ModelTypeSet enabled_types() const { | 64 ModelTypeSet enabled_types() const { |
71 return enabled_types_; | 65 return enabled_types_; |
72 } | 66 } |
73 | 67 |
74 void set_routing_info(const ModelSafeRoutingInfo& routing_info); | 68 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); |
75 | 69 |
76 UpdateHandlerMap* update_handler_map() { | 70 UpdaterList* GetUpdaterList(); |
77 return &update_handler_map_; | 71 CommitterList* GetCommitterList(); |
78 } | |
79 | |
80 CommitContributorMap* commit_contributor_map() { | |
81 return &commit_contributor_map_; | |
82 } | |
83 | 72 |
84 ExtensionsActivity* extensions_activity() { | 73 ExtensionsActivity* extensions_activity() { |
85 return extensions_activity_.get(); | 74 return extensions_activity_.get(); |
86 } | 75 } |
87 | 76 |
88 DebugInfoGetter* debug_info_getter() { | 77 DebugInfoGetter* debug_info_getter() { |
89 return debug_info_getter_; | 78 return debug_info_getter_; |
90 } | 79 } |
91 | 80 |
92 // Talk notification status. | 81 // Talk notification status. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 138 |
150 ObserverList<SyncEngineEventListener> listeners_; | 139 ObserverList<SyncEngineEventListener> listeners_; |
151 | 140 |
152 ServerConnectionManager* const connection_manager_; | 141 ServerConnectionManager* const connection_manager_; |
153 syncable::Directory* const directory_; | 142 syncable::Directory* const directory_; |
154 | 143 |
155 // The set of enabled types. Derrived from the routing info set with | 144 // The set of enabled types. Derrived from the routing info set with |
156 // set_routing_info(). | 145 // set_routing_info(). |
157 ModelTypeSet enabled_types_; | 146 ModelTypeSet enabled_types_; |
158 | 147 |
159 // A map of 'update handlers', one for each enabled type. | |
160 // This must be kept in sync with the routing info. Our temporary solution to | |
161 // that problem is to initialize this map in set_routing_info(). | |
162 UpdateHandlerMap update_handler_map_; | |
163 | |
164 // Deleter for the |update_handler_map_|. | |
165 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_; | |
166 | |
167 // A map of 'commit contributors', one for each enabled type. | |
168 // This must be kept in sync with the routing info. Our temporary solution to | |
169 // that problem is to initialize this map in set_routing_info(). | |
170 CommitContributorMap commit_contributor_map_; | |
171 | |
172 // Deleter for the |commit_contributor_map_|. | |
173 STLValueDeleter<CommitContributorMap> commit_contributor_deleter_; | |
174 | |
175 // The set of ModelSafeWorkers. Used to execute tasks of various threads. | |
176 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_; | |
177 | |
178 // We use this to stuff extensions activity into CommitMessages so the server | 148 // We use this to stuff extensions activity into CommitMessages so the server |
179 // can correlate commit traffic with extension-related bookmark mutations. | 149 // can correlate commit traffic with extension-related bookmark mutations. |
180 scoped_refptr<ExtensionsActivity> extensions_activity_; | 150 scoped_refptr<ExtensionsActivity> extensions_activity_; |
181 | 151 |
182 // Kept up to date with talk events to determine whether notifications are | 152 // Kept up to date with talk events to determine whether notifications are |
183 // enabled. True only if the notification channel is authorized and open. | 153 // enabled. True only if the notification channel is authorized and open. |
184 bool notifications_enabled_; | 154 bool notifications_enabled_; |
185 | 155 |
186 // The name of the account being synced. | 156 // The name of the account being synced. |
187 std::string account_name_; | 157 std::string account_name_; |
188 | 158 |
189 // The server limits the number of items a client can commit in one batch. | 159 // The server limits the number of items a client can commit in one batch. |
190 int max_commit_batch_size_; | 160 int max_commit_batch_size_; |
191 | 161 |
192 // We use this to get debug info to send to the server for debugging | 162 // We use this to get debug info to send to the server for debugging |
193 // client behavior on server side. | 163 // client behavior on server side. |
194 DebugInfoGetter* const debug_info_getter_; | 164 DebugInfoGetter* const debug_info_getter_; |
195 | 165 |
196 TrafficRecorder* traffic_recorder_; | 166 TrafficRecorder* traffic_recorder_; |
197 | 167 |
168 ModelTypeRegistry* model_type_registry_; | |
169 | |
170 scoped_ptr<CommitterList> committer_list_; | |
171 scoped_ptr<UpdaterList> updater_list_; | |
tim (not reviewing)
2014/01/14 20:26:46
In the sessions/engine approach this patch is shoo
rlarocque
2014/01/15 01:16:47
Done, I think.
| |
172 | |
198 // Satus information to be sent up to the server. | 173 // Satus information to be sent up to the server. |
199 sync_pb::ClientStatus client_status_; | 174 sync_pb::ClientStatus client_status_; |
200 | 175 |
201 // Temporary variable while keystore encryption is behind a flag. True if | 176 // Temporary variable while keystore encryption is behind a flag. True if |
202 // we should attempt performing keystore encryption related work, false if | 177 // we should attempt performing keystore encryption related work, false if |
203 // the experiment is not enabled. | 178 // the experiment is not enabled. |
204 bool keystore_encryption_enabled_; | 179 bool keystore_encryption_enabled_; |
205 | 180 |
206 // This is a copy of the identifier the that the invalidations client used to | 181 // This is a copy of the identifier the that the invalidations client used to |
207 // register itself with the invalidations server during startup. We need to | 182 // register itself with the invalidations server during startup. We need to |
(...skipping 10 matching lines...) Expand all Loading... | |
218 // enable the pre-commit update avoidance experiment described above. | 193 // enable the pre-commit update avoidance experiment described above. |
219 const bool client_enabled_pre_commit_update_avoidance_; | 194 const bool client_enabled_pre_commit_update_avoidance_; |
220 | 195 |
221 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 196 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
222 }; | 197 }; |
223 | 198 |
224 } // namespace sessions | 199 } // namespace sessions |
225 } // namespace syncer | 200 } // namespace syncer |
226 | 201 |
227 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 202 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |