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

Side by Side Diff: sync/sessions/sync_session_context.h

Issue 72403003: sync: Per-type update application (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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. A context is accessible via 6 // components specific to a SyncSession. Unlike the SyncSession, the context
7 // a SyncSession so that session SyncerCommands and parts of the engine have 7 // can be reused across several sync cycles.
8 // a convenient way to access other parts. In this way it can be thought of as 8 //
9 // the surrounding environment for the SyncSession. The components of this 9 // The context does not take ownership of its pointer members. It's up to
10 // environment are either valid or not valid for the entire context lifetime, 10 // the surrounding classes to ensure those members remain valid while the
11 // or they are valid for explicitly scoped periods of time by using Scoped 11 // context is in use.
12 // installation utilities found below. This means that the context assumes no
13 // ownership whatsoever of any object that was not created by the context
14 // itself.
15 // 12 //
16 // It can only be used from the SyncerThread. 13 // It can only be used from the SyncerThread.
17 14
18 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 15 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
19 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 16 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
20 17
21 #include <map> 18 #include <map>
22 #include <string> 19 #include <string>
23 #include <vector> 20 #include <vector>
24 21
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 60
64 ~SyncSessionContext(); 61 ~SyncSessionContext();
65 62
66 ServerConnectionManager* connection_manager() { 63 ServerConnectionManager* connection_manager() {
67 return connection_manager_; 64 return connection_manager_;
68 } 65 }
69 syncable::Directory* directory() { 66 syncable::Directory* directory() {
70 return directory_; 67 return directory_;
71 } 68 }
72 69
73 const ModelSafeRoutingInfo& routing_info() const { 70 ModelTypeSet enabled_types() const {
74 return routing_info_; 71 return enabled_types_;
75 } 72 }
76 73
77 void set_routing_info(const ModelSafeRoutingInfo& routing_info); 74 void set_routing_info(const ModelSafeRoutingInfo& routing_info);
78 75
79 UpdateHandlerMap* update_handler_map() { 76 UpdateHandlerMap* update_handler_map() {
80 return &update_handler_map_; 77 return &update_handler_map_;
81 } 78 }
82 79
83 CommitContributorMap* commit_contributor_map() { 80 CommitContributorMap* commit_contributor_map() {
84 return &commit_contributor_map_; 81 return &commit_contributor_map_;
85 } 82 }
86 83
87 const std::vector<scoped_refptr<ModelSafeWorker> >& workers() const {
88 return workers_;
89 }
90
91 ExtensionsActivity* extensions_activity() { 84 ExtensionsActivity* extensions_activity() {
92 return extensions_activity_.get(); 85 return extensions_activity_.get();
93 } 86 }
94 87
95 DebugInfoGetter* debug_info_getter() { 88 DebugInfoGetter* debug_info_getter() {
96 return debug_info_getter_; 89 return debug_info_getter_;
97 } 90 }
98 91
99 // Talk notification status. 92 // Talk notification status.
100 void set_notifications_enabled(bool enabled) { 93 void set_notifications_enabled(bool enabled) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Rather than force clients to set and null-out various context members, we 145 // Rather than force clients to set and null-out various context members, we
153 // extend our encapsulation boundary to scoped helpers that take care of this 146 // extend our encapsulation boundary to scoped helpers that take care of this
154 // once they are allocated. See definitions of these below. 147 // once they are allocated. See definitions of these below.
155 friend class TestScopedSessionEventListener; 148 friend class TestScopedSessionEventListener;
156 149
157 ObserverList<SyncEngineEventListener> listeners_; 150 ObserverList<SyncEngineEventListener> listeners_;
158 151
159 ServerConnectionManager* const connection_manager_; 152 ServerConnectionManager* const connection_manager_;
160 syncable::Directory* const directory_; 153 syncable::Directory* const directory_;
161 154
162 // A cached copy of SyncBackendRegistrar's routing info. 155 // The set of enabled types. Derrived from the routing info set with
163 // Must be updated manually when SBR's state is modified. 156 // set_routing_info().
164 ModelSafeRoutingInfo routing_info_; 157 ModelTypeSet enabled_types_;
165 158
166 // A map of 'update handlers', one for each enabled type. 159 // A map of 'update handlers', one for each enabled type.
167 // This must be kept in sync with the routing info. Our temporary solution to 160 // This must be kept in sync with the routing info. Our temporary solution to
168 // that problem is to initialize this map in set_routing_info(). 161 // that problem is to initialize this map in set_routing_info().
169 UpdateHandlerMap update_handler_map_; 162 UpdateHandlerMap update_handler_map_;
170 163
171 // Deleter for the |update_handler_map_|. 164 // Deleter for the |update_handler_map_|.
172 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_; 165 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
173 166
174 // A map of 'commit contributors', one for each enabled type. 167 // A map of 'commit contributors', one for each enabled type.
175 // This must be kept in sync with the routing info. Our temporary solution to 168 // This must be kept in sync with the routing info. Our temporary solution to
176 // that problem is to initialize this map in set_routing_info(). 169 // that problem is to initialize this map in set_routing_info().
177 CommitContributorMap commit_contributor_map_; 170 CommitContributorMap commit_contributor_map_;
178 171
179 // Deleter for the |commit_contributor_map_|. 172 // Deleter for the |commit_contributor_map_|.
180 STLValueDeleter<CommitContributorMap> commit_contributor_deleter_; 173 STLValueDeleter<CommitContributorMap> commit_contributor_deleter_;
181 174
182 // The set of ModelSafeWorkers. Used to execute tasks of various threads. 175 // The set of ModelSafeWorkers. Used to execute tasks of various threads.
183 std::vector<scoped_refptr<ModelSafeWorker> > workers_; 176 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_;
184 177
185 // We use this to stuff extensions activity into CommitMessages so the server 178 // We use this to stuff extensions activity into CommitMessages so the server
186 // can correlate commit traffic with extension-related bookmark mutations. 179 // can correlate commit traffic with extension-related bookmark mutations.
187 scoped_refptr<ExtensionsActivity> extensions_activity_; 180 scoped_refptr<ExtensionsActivity> extensions_activity_;
188 181
189 // Kept up to date with talk events to determine whether notifications are 182 // Kept up to date with talk events to determine whether notifications are
190 // enabled. True only if the notification channel is authorized and open. 183 // enabled. True only if the notification channel is authorized and open.
191 bool notifications_enabled_; 184 bool notifications_enabled_;
192 185
193 // The name of the account being synced. 186 // The name of the account being synced.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // enable the pre-commit update avoidance experiment described above. 218 // enable the pre-commit update avoidance experiment described above.
226 const bool client_enabled_pre_commit_update_avoidance_; 219 const bool client_enabled_pre_commit_update_avoidance_;
227 220
228 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); 221 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext);
229 }; 222 };
230 223
231 } // namespace sessions 224 } // namespace sessions
232 } // namespace syncer 225 } // namespace syncer
233 226
234 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 227 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698