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

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

Issue 19309002: sync: Add pre-commit update avoidance mode + flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 7 years, 5 months 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
« no previous file with comments | « sync/sessions/nudge_tracker_unittest.cc ('k') | sync/sessions/sync_session_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. A context is accessible via
7 // a SyncSession so that session SyncerCommands and parts of the engine have 7 // a SyncSession so that session SyncerCommands and parts of the engine have
8 // a convenient way to access other parts. In this way it can be thought of as 8 // a convenient way to access other parts. In this way it can be thought of as
9 // the surrounding environment for the SyncSession. The components of this 9 // the surrounding environment for the SyncSession. The components of this
10 // environment are either valid or not valid for the entire context lifetime, 10 // environment are either valid or not valid for the entire context lifetime,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 class SYNC_EXPORT_PRIVATE SyncSessionContext { 48 class SYNC_EXPORT_PRIVATE SyncSessionContext {
49 public: 49 public:
50 SyncSessionContext(ServerConnectionManager* connection_manager, 50 SyncSessionContext(ServerConnectionManager* connection_manager,
51 syncable::Directory* directory, 51 syncable::Directory* directory,
52 const std::vector<ModelSafeWorker*>& workers, 52 const std::vector<ModelSafeWorker*>& workers,
53 ExtensionsActivityMonitor* extensions_activity_monitor, 53 ExtensionsActivityMonitor* extensions_activity_monitor,
54 const std::vector<SyncEngineEventListener*>& listeners, 54 const std::vector<SyncEngineEventListener*>& listeners,
55 DebugInfoGetter* debug_info_getter, 55 DebugInfoGetter* debug_info_getter,
56 TrafficRecorder* traffic_recorder, 56 TrafficRecorder* traffic_recorder,
57 bool keystore_encryption_enabled, 57 bool keystore_encryption_enabled,
58 bool client_enabled_pre_commit_update_avoidance,
58 const std::string& invalidator_client_id); 59 const std::string& invalidator_client_id);
59 60
60 ~SyncSessionContext(); 61 ~SyncSessionContext();
61 62
62 ServerConnectionManager* connection_manager() { 63 ServerConnectionManager* connection_manager() {
63 return connection_manager_; 64 return connection_manager_;
64 } 65 }
65 syncable::Directory* directory() { 66 syncable::Directory* directory() {
66 return directory_; 67 return directory_;
67 } 68 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 const sync_pb::ClientStatus& client_status() const { 125 const sync_pb::ClientStatus& client_status() const {
125 return client_status_; 126 return client_status_;
126 } 127 }
127 128
128 const std::string& invalidator_client_id() const { 129 const std::string& invalidator_client_id() const {
129 return invalidator_client_id_; 130 return invalidator_client_id_;
130 } 131 }
131 132
133 bool ShouldFetchUpdatesBeforeCommit() const {
134 return !(server_enabled_pre_commit_update_avoidance_ ||
135 client_enabled_pre_commit_update_avoidance_);
136 }
137
138 void set_server_enabled_pre_commit_update_avoidance(bool value) {
139 server_enabled_pre_commit_update_avoidance_ = value;
140 }
141
132 private: 142 private:
133 // Rather than force clients to set and null-out various context members, we 143 // Rather than force clients to set and null-out various context members, we
134 // extend our encapsulation boundary to scoped helpers that take care of this 144 // extend our encapsulation boundary to scoped helpers that take care of this
135 // once they are allocated. See definitions of these below. 145 // once they are allocated. See definitions of these below.
136 friend class TestScopedSessionEventListener; 146 friend class TestScopedSessionEventListener;
137 147
138 ObserverList<SyncEngineEventListener> listeners_; 148 ObserverList<SyncEngineEventListener> listeners_;
139 149
140 ServerConnectionManager* const connection_manager_; 150 ServerConnectionManager* const connection_manager_;
141 syncable::Directory* const directory_; 151 syncable::Directory* const directory_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // we should attempt performing keystore encryption related work, false if 184 // we should attempt performing keystore encryption related work, false if
175 // the experiment is not enabled. 185 // the experiment is not enabled.
176 bool keystore_encryption_enabled_; 186 bool keystore_encryption_enabled_;
177 187
178 // This is a copy of the identifier the that the invalidations client used to 188 // This is a copy of the identifier the that the invalidations client used to
179 // register itself with the invalidations server during startup. We need to 189 // register itself with the invalidations server during startup. We need to
180 // provide this to the sync server when we make changes to enable it to 190 // provide this to the sync server when we make changes to enable it to
181 // prevent us from receiving notifications of changes we make ourselves. 191 // prevent us from receiving notifications of changes we make ourselves.
182 const std::string invalidator_client_id_; 192 const std::string invalidator_client_id_;
183 193
194 // Flag to enable or disable the no pre-commit GetUpdates experiment. When
195 // this flag is set to false, the syncer has the option of not performing at
196 // GetUpdates request when there is nothing to fetch.
197 bool server_enabled_pre_commit_update_avoidance_;
198
199 // If true, indicates that we've been passed a command-line flag to force
200 // enable the pre-commit update avoidance experiment described above.
201 const bool client_enabled_pre_commit_update_avoidance_;
202
184 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); 203 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext);
185 }; 204 };
186 205
187 } // namespace sessions 206 } // namespace sessions
188 } // namespace syncer 207 } // namespace syncer
189 208
190 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ 209 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_
OLDNEW
« no previous file with comments | « sync/sessions/nudge_tracker_unittest.cc ('k') | sync/sessions/sync_session_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698