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> | 19 #include <vector> |
21 | 20 |
22 #include "base/stl_util.h" | |
23 #include "sync/base/sync_export.h" | 21 #include "sync/base/sync_export.h" |
24 #include "sync/engine/sync_directory_commit_contributor.h" | 22 #include "sync/engine/committer_list.h" |
25 #include "sync/engine/sync_directory_update_handler.h" | |
26 #include "sync/engine/sync_engine_event.h" | 23 #include "sync/engine/sync_engine_event.h" |
27 #include "sync/engine/syncer_types.h" | |
28 #include "sync/engine/traffic_recorder.h" | 24 #include "sync/engine/traffic_recorder.h" |
| 25 #include "sync/engine/updater_list.h" |
29 #include "sync/internal_api/public/engine/model_safe_worker.h" | 26 #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" | 27 #include "sync/sessions/debug_info_getter.h" |
32 | 28 |
33 namespace syncer { | 29 namespace syncer { |
34 | 30 |
35 class ExtensionsActivity; | 31 class ExtensionsActivity; |
36 class ServerConnectionManager; | 32 class ServerConnectionManager; |
37 | 33 |
38 namespace syncable { | 34 namespace syncable { |
39 class Directory; | 35 class Directory; |
40 } | 36 } |
(...skipping 23 matching lines...) Expand all Loading... |
64 return connection_manager_; | 60 return connection_manager_; |
65 } | 61 } |
66 syncable::Directory* directory() { | 62 syncable::Directory* directory() { |
67 return directory_; | 63 return directory_; |
68 } | 64 } |
69 | 65 |
70 ModelTypeSet enabled_types() const { | 66 ModelTypeSet enabled_types() const { |
71 return enabled_types_; | 67 return enabled_types_; |
72 } | 68 } |
73 | 69 |
74 void set_routing_info(const ModelSafeRoutingInfo& routing_info); | 70 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); |
75 | |
76 UpdateHandlerMap* update_handler_map() { | |
77 return &update_handler_map_; | |
78 } | |
79 | |
80 CommitContributorMap* commit_contributor_map() { | |
81 return &commit_contributor_map_; | |
82 } | |
83 | 71 |
84 ExtensionsActivity* extensions_activity() { | 72 ExtensionsActivity* extensions_activity() { |
85 return extensions_activity_.get(); | 73 return extensions_activity_.get(); |
86 } | 74 } |
87 | 75 |
88 DebugInfoGetter* debug_info_getter() { | 76 DebugInfoGetter* debug_info_getter() { |
89 return debug_info_getter_; | 77 return debug_info_getter_; |
90 } | 78 } |
91 | 79 |
92 // Talk notification status. | 80 // Talk notification status. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 122 |
135 bool ShouldFetchUpdatesBeforeCommit() const { | 123 bool ShouldFetchUpdatesBeforeCommit() const { |
136 return !(server_enabled_pre_commit_update_avoidance_ || | 124 return !(server_enabled_pre_commit_update_avoidance_ || |
137 client_enabled_pre_commit_update_avoidance_); | 125 client_enabled_pre_commit_update_avoidance_); |
138 } | 126 } |
139 | 127 |
140 void set_server_enabled_pre_commit_update_avoidance(bool value) { | 128 void set_server_enabled_pre_commit_update_avoidance(bool value) { |
141 server_enabled_pre_commit_update_avoidance_ = value; | 129 server_enabled_pre_commit_update_avoidance_ = value; |
142 } | 130 } |
143 | 131 |
| 132 UpdaterList* updater_list() { |
| 133 return &updater_list_; |
| 134 } |
| 135 |
| 136 CommitterList* committer_list() { |
| 137 return &committer_list_; |
| 138 } |
| 139 |
144 private: | 140 private: |
145 // Rather than force clients to set and null-out various context members, we | 141 // Rather than force clients to set and null-out various context members, we |
146 // extend our encapsulation boundary to scoped helpers that take care of this | 142 // extend our encapsulation boundary to scoped helpers that take care of this |
147 // once they are allocated. See definitions of these below. | 143 // once they are allocated. See definitions of these below. |
148 friend class TestScopedSessionEventListener; | 144 friend class TestScopedSessionEventListener; |
149 | 145 |
150 ObserverList<SyncEngineEventListener> listeners_; | 146 ObserverList<SyncEngineEventListener> listeners_; |
151 | 147 |
152 ServerConnectionManager* const connection_manager_; | 148 ServerConnectionManager* const connection_manager_; |
153 syncable::Directory* const directory_; | 149 syncable::Directory* const directory_; |
154 | 150 |
155 // The set of enabled types. Derrived from the routing info set with | 151 // The set of enabled types. Derrived from the routing info set with |
156 // set_routing_info(). | 152 // set_routing_info(). |
157 ModelTypeSet enabled_types_; | 153 ModelTypeSet enabled_types_; |
158 | 154 |
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. | 155 // The set of ModelSafeWorkers. Used to execute tasks of various threads. |
176 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_; | 156 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
177 | 157 |
178 // We use this to stuff extensions activity into CommitMessages so the server | 158 // We use this to stuff extensions activity into CommitMessages so the server |
179 // can correlate commit traffic with extension-related bookmark mutations. | 159 // can correlate commit traffic with extension-related bookmark mutations. |
180 scoped_refptr<ExtensionsActivity> extensions_activity_; | 160 scoped_refptr<ExtensionsActivity> extensions_activity_; |
181 | 161 |
182 // Kept up to date with talk events to determine whether notifications are | 162 // Kept up to date with talk events to determine whether notifications are |
183 // enabled. True only if the notification channel is authorized and open. | 163 // enabled. True only if the notification channel is authorized and open. |
184 bool notifications_enabled_; | 164 bool notifications_enabled_; |
185 | 165 |
186 // The name of the account being synced. | 166 // The name of the account being synced. |
(...skipping 24 matching lines...) Expand all Loading... |
211 | 191 |
212 // Flag to enable or disable the no pre-commit GetUpdates experiment. When | 192 // Flag to enable or disable the no pre-commit GetUpdates experiment. When |
213 // this flag is set to false, the syncer has the option of not performing at | 193 // this flag is set to false, the syncer has the option of not performing at |
214 // GetUpdates request when there is nothing to fetch. | 194 // GetUpdates request when there is nothing to fetch. |
215 bool server_enabled_pre_commit_update_avoidance_; | 195 bool server_enabled_pre_commit_update_avoidance_; |
216 | 196 |
217 // If true, indicates that we've been passed a command-line flag to force | 197 // If true, indicates that we've been passed a command-line flag to force |
218 // enable the pre-commit update avoidance experiment described above. | 198 // enable the pre-commit update avoidance experiment described above. |
219 const bool client_enabled_pre_commit_update_avoidance_; | 199 const bool client_enabled_pre_commit_update_avoidance_; |
220 | 200 |
| 201 // Classes to manage the types hooked up to receive and commit sync data. |
| 202 UpdaterList updater_list_; |
| 203 CommitterList committer_list_; |
| 204 |
221 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 205 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
222 }; | 206 }; |
223 | 207 |
224 } // namespace sessions | 208 } // namespace sessions |
225 } // namespace syncer | 209 } // namespace syncer |
226 | 210 |
227 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 211 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |