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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SyncFrontend() {} 55 SyncFrontend() {}
56 56
57 // The backend has completed initialization and it is now ready to 57 // The backend has completed initialization and it is now ready to
58 // accept and process changes. If success is false, initialization 58 // accept and process changes. If success is false, initialization
59 // wasn't able to be completed and should be retried. 59 // wasn't able to be completed and should be retried.
60 // 60 //
61 // |js_backend| is what about:sync interacts with; it's different 61 // |js_backend| is what about:sync interacts with; it's different
62 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It 62 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It
63 // is initialized only if |success| is true. 63 // is initialized only if |success| is true.
64 virtual void OnBackendInitialized( 64 virtual void OnBackendInitialized(
65 const csync::WeakHandle<csync::JsBackend>& js_backend, bool success) = 0; 65 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
66 bool success) = 0;
66 67
67 // The backend queried the server recently and received some updates. 68 // The backend queried the server recently and received some updates.
68 virtual void OnSyncCycleCompleted() = 0; 69 virtual void OnSyncCycleCompleted() = 0;
69 70
70 // Configure ran into some kind of error. But it is scheduled to be 71 // Configure ran into some kind of error. But it is scheduled to be
71 // retried. 72 // retried.
72 virtual void OnSyncConfigureRetry() = 0; 73 virtual void OnSyncConfigureRetry() = 0;
73 74
74 // The status of the connection to the sync server has changed. 75 // The status of the connection to the sync server has changed.
75 virtual void OnConnectionStatusChange( 76 virtual void OnConnectionStatusChange(
76 csync::ConnectionStatus status) = 0; 77 syncer::ConnectionStatus status) = 0;
77 78
78 // We are no longer permitted to communicate with the server. Sync should 79 // We are no longer permitted to communicate with the server. Sync should
79 // be disabled and state cleaned up at once. 80 // be disabled and state cleaned up at once.
80 virtual void OnStopSyncingPermanently() = 0; 81 virtual void OnStopSyncingPermanently() = 0;
81 82
82 // The syncer requires a passphrase to decrypt sensitive updates. This is 83 // The syncer requires a passphrase to decrypt sensitive updates. This is
83 // called when the first sensitive data type is setup by the user and anytime 84 // called when the first sensitive data type is setup by the user and anytime
84 // the passphrase is changed by another synced client. |reason| denotes why 85 // the passphrase is changed by another synced client. |reason| denotes why
85 // the passphrase was required. |pending_keys| is a copy of the 86 // the passphrase was required. |pending_keys| is a copy of the
86 // cryptographer's pending keys to be passed on to the frontend in order to 87 // cryptographer's pending keys to be passed on to the frontend in order to
87 // be cached. 88 // be cached.
88 virtual void OnPassphraseRequired( 89 virtual void OnPassphraseRequired(
89 csync::PassphraseRequiredReason reason, 90 syncer::PassphraseRequiredReason reason,
90 const sync_pb::EncryptedData& pending_keys) = 0; 91 const sync_pb::EncryptedData& pending_keys) = 0;
91 92
92 // Called when the passphrase provided by the user is 93 // Called when the passphrase provided by the user is
93 // accepted. After this is called, updates to sensitive nodes are 94 // accepted. After this is called, updates to sensitive nodes are
94 // encrypted using the accepted passphrase. 95 // encrypted using the accepted passphrase.
95 virtual void OnPassphraseAccepted() = 0; 96 virtual void OnPassphraseAccepted() = 0;
96 97
97 // Called when the set of encrypted types or the encrypt everything 98 // Called when the set of encrypted types or the encrypt everything
98 // flag has been changed. Note that encryption isn't complete until 99 // flag has been changed. Note that encryption isn't complete until
99 // the OnEncryptionComplete() notification has been sent (see 100 // the OnEncryptionComplete() notification has been sent (see
100 // below). 101 // below).
101 // 102 //
102 // |encrypted_types| will always be a superset of 103 // |encrypted_types| will always be a superset of
103 // csync::Cryptographer::SensitiveTypes(). If |encrypt_everything| is 104 // syncer::Cryptographer::SensitiveTypes(). If |encrypt_everything| is
104 // true, |encrypted_types| will be the set of all known types. 105 // true, |encrypted_types| will be the set of all known types.
105 // 106 //
106 // Until this function is called, observers can assume that the set 107 // Until this function is called, observers can assume that the set
107 // of encrypted types is csync::Cryptographer::SensitiveTypes() and that 108 // of encrypted types is syncer::Cryptographer::SensitiveTypes() and that
108 // the encrypt everything flag is false. 109 // the encrypt everything flag is false.
109 virtual void OnEncryptedTypesChanged( 110 virtual void OnEncryptedTypesChanged(
110 syncable::ModelTypeSet encrypted_types, 111 syncable::ModelTypeSet encrypted_types,
111 bool encrypt_everything) = 0; 112 bool encrypt_everything) = 0;
112 113
113 // Called after we finish encrypting the current set of encrypted 114 // Called after we finish encrypting the current set of encrypted
114 // types. 115 // types.
115 virtual void OnEncryptionComplete() = 0; 116 virtual void OnEncryptionComplete() = 0;
116 117
117 // Called to perform migration of |types|. 118 // Called to perform migration of |types|.
118 virtual void OnMigrationNeededForTypes( 119 virtual void OnMigrationNeededForTypes(
119 syncable::ModelTypeSet types) = 0; 120 syncable::ModelTypeSet types) = 0;
120 121
121 // Inform the Frontend that new datatypes are available for registration. 122 // Inform the Frontend that new datatypes are available for registration.
122 virtual void OnExperimentsChanged( 123 virtual void OnExperimentsChanged(
123 const csync::Experiments& experiments) = 0; 124 const syncer::Experiments& experiments) = 0;
124 125
125 // Called when the sync cycle returns there is an user actionable error. 126 // Called when the sync cycle returns there is an user actionable error.
126 virtual void OnActionableError( 127 virtual void OnActionableError(
127 const csync::SyncProtocolError& error) = 0; 128 const syncer::SyncProtocolError& error) = 0;
128 129
129 protected: 130 protected:
130 // Don't delete through SyncFrontend interface. 131 // Don't delete through SyncFrontend interface.
131 virtual ~SyncFrontend() { 132 virtual ~SyncFrontend() {
132 } 133 }
133 private: 134 private:
134 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); 135 DISALLOW_COPY_AND_ASSIGN(SyncFrontend);
135 }; 136 };
136 137
137 // A UI-thread safe API into the sync backend that "hosts" the top-level 138 // A UI-thread safe API into the sync backend that "hosts" the top-level
138 // syncapi element, the SyncManager, on its own thread. This class handles 139 // syncapi element, the SyncManager, on its own thread. This class handles
139 // dispatch of potentially blocking calls to appropriate threads and ensures 140 // dispatch of potentially blocking calls to appropriate threads and ensures
140 // that the SyncFrontend is only accessed on the UI loop. 141 // that the SyncFrontend is only accessed on the UI loop.
141 class SyncBackendHost : public BackendDataTypeConfigurer { 142 class SyncBackendHost : public BackendDataTypeConfigurer {
142 public: 143 public:
143 typedef csync::SyncStatus Status; 144 typedef syncer::SyncStatus Status;
144 145
145 // Create a SyncBackendHost with a reference to the |frontend| that 146 // Create a SyncBackendHost with a reference to the |frontend| that
146 // it serves and communicates to via the SyncFrontend interface (on 147 // it serves and communicates to via the SyncFrontend interface (on
147 // the same thread it used to call the constructor). Must outlive 148 // the same thread it used to call the constructor). Must outlive
148 // |sync_prefs| and |invalidator_storage|. 149 // |sync_prefs| and |invalidator_storage|.
149 SyncBackendHost( 150 SyncBackendHost(
150 const std::string& name, 151 const std::string& name,
151 Profile* profile, 152 Profile* profile,
152 const base::WeakPtr<SyncPrefs>& sync_prefs, 153 const base::WeakPtr<SyncPrefs>& sync_prefs,
153 // TODO(tim): Temporary, remove when bug 124137 finished. 154 // TODO(tim): Temporary, remove when bug 124137 finished.
154 const base::WeakPtr<InvalidatorStorage>& invalidator_storage); 155 const base::WeakPtr<InvalidatorStorage>& invalidator_storage);
155 156
156 // For testing. 157 // For testing.
157 // TODO(skrul): Extract an interface so this is not needed. 158 // TODO(skrul): Extract an interface so this is not needed.
158 explicit SyncBackendHost(Profile* profile); 159 explicit SyncBackendHost(Profile* profile);
159 virtual ~SyncBackendHost(); 160 virtual ~SyncBackendHost();
160 161
161 // Called on |frontend_loop_| to kick off asynchronous initialization. 162 // Called on |frontend_loop_| to kick off asynchronous initialization.
162 // As a fallback when no cached auth information is available, try to 163 // As a fallback when no cached auth information is available, try to
163 // bootstrap authentication using |lsid|, if it isn't empty. 164 // bootstrap authentication using |lsid|, if it isn't empty.
164 // Optionally delete the Sync Data folder (if it's corrupt). 165 // Optionally delete the Sync Data folder (if it's corrupt).
165 // |report_unrecoverable_error_function| can be NULL. 166 // |report_unrecoverable_error_function| can be NULL.
166 // Note: |unrecoverable_error_handler| may be invoked from any thread. 167 // Note: |unrecoverable_error_handler| may be invoked from any thread.
167 void Initialize(SyncFrontend* frontend, 168 void Initialize(
168 const csync::WeakHandle<csync::JsEventHandler>& event_handler, 169 SyncFrontend* frontend,
169 const GURL& service_url, 170 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
170 syncable::ModelTypeSet initial_types, 171 const GURL& service_url,
171 const csync::SyncCredentials& credentials, 172 syncable::ModelTypeSet initial_types,
172 bool delete_sync_data_folder, 173 const syncer::SyncCredentials& credentials,
173 csync::UnrecoverableErrorHandler* unrecoverable_error_handler, 174 bool delete_sync_data_folder,
174 csync::ReportUnrecoverableErrorFunction 175 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
175 report_unrecoverable_error_function); 176 syncer::ReportUnrecoverableErrorFunction
177 report_unrecoverable_error_function);
176 178
177 // Called from |frontend_loop| to update SyncCredentials. 179 // Called from |frontend_loop| to update SyncCredentials.
178 void UpdateCredentials(const csync::SyncCredentials& credentials); 180 void UpdateCredentials(const syncer::SyncCredentials& credentials);
179 181
180 // This starts the SyncerThread running a Syncer object to communicate with 182 // This starts the SyncerThread running a Syncer object to communicate with
181 // sync servers. Until this is called, no changes will leave or enter this 183 // sync servers. Until this is called, no changes will leave or enter this
182 // browser from the cloud / sync servers. 184 // browser from the cloud / sync servers.
183 // Called on |frontend_loop_|. 185 // Called on |frontend_loop_|.
184 virtual void StartSyncingWithServer(); 186 virtual void StartSyncingWithServer();
185 187
186 // Called on |frontend_loop_| to asynchronously set a new passphrase for 188 // Called on |frontend_loop_| to asynchronously set a new passphrase for
187 // encryption. Note that it is an error to call SetEncryptionPassphrase under 189 // encryption. Note that it is an error to call SetEncryptionPassphrase under
188 // the following circumstances: 190 // the following circumstances:
(...skipping 25 matching lines...) Expand all
214 // |sync_disabled| indicates if syncing is being disabled or not. 216 // |sync_disabled| indicates if syncing is being disabled or not.
215 // See the implementation and Core::DoShutdown for details. 217 // See the implementation and Core::DoShutdown for details.
216 // Must be called *after* StopSyncingForShutdown. 218 // Must be called *after* StopSyncingForShutdown.
217 void Shutdown(bool sync_disabled); 219 void Shutdown(bool sync_disabled);
218 220
219 // Changes the set of data types that are currently being synced. 221 // Changes the set of data types that are currently being synced.
220 // The ready_task will be run when configuration is done with the 222 // The ready_task will be run when configuration is done with the
221 // set of all types that failed configuration (i.e., if its argument 223 // set of all types that failed configuration (i.e., if its argument
222 // is non-empty, then an error was encountered). 224 // is non-empty, then an error was encountered).
223 virtual void ConfigureDataTypes( 225 virtual void ConfigureDataTypes(
224 csync::ConfigureReason reason, 226 syncer::ConfigureReason reason,
225 syncable::ModelTypeSet types_to_add, 227 syncable::ModelTypeSet types_to_add,
226 syncable::ModelTypeSet types_to_remove, 228 syncable::ModelTypeSet types_to_remove,
227 NigoriState nigori_state, 229 NigoriState nigori_state,
228 base::Callback<void(syncable::ModelTypeSet)> ready_task, 230 base::Callback<void(syncable::ModelTypeSet)> ready_task,
229 base::Callback<void()> retry_callback) OVERRIDE; 231 base::Callback<void()> retry_callback) OVERRIDE;
230 232
231 // Makes an asynchronous call to syncer to switch to config mode. When done 233 // Makes an asynchronous call to syncer to switch to config mode. When done
232 // syncer will call us back on FinishConfigureDataTypes. 234 // syncer will call us back on FinishConfigureDataTypes.
233 virtual void StartConfiguration(const base::Closure& callback); 235 virtual void StartConfiguration(const base::Closure& callback);
234 236
235 // Turns on encryption of all present and future sync data. 237 // Turns on encryption of all present and future sync data.
236 virtual void EnableEncryptEverything(); 238 virtual void EnableEncryptEverything();
237 239
238 // Activates change processing for the given data type. This must 240 // Activates change processing for the given data type. This must
239 // be called synchronously with the data type's model association so 241 // be called synchronously with the data type's model association so
240 // no changes are dropped between model association and change 242 // no changes are dropped between model association and change
241 // processor activation. 243 // processor activation.
242 void ActivateDataType( 244 void ActivateDataType(
243 syncable::ModelType type, csync::ModelSafeGroup group, 245 syncable::ModelType type, syncer::ModelSafeGroup group,
244 ChangeProcessor* change_processor); 246 ChangeProcessor* change_processor);
245 247
246 // Deactivates change processing for the given data type. 248 // Deactivates change processing for the given data type.
247 void DeactivateDataType(syncable::ModelType type); 249 void DeactivateDataType(syncable::ModelType type);
248 250
249 // Called on |frontend_loop_| to obtain a handle to the UserShare needed 251 // Called on |frontend_loop_| to obtain a handle to the UserShare needed
250 // for creating transactions. 252 // for creating transactions.
251 csync::UserShare* GetUserShare() const; 253 syncer::UserShare* GetUserShare() const;
252 254
253 // Called from any thread to obtain current status information in detailed or 255 // Called from any thread to obtain current status information in detailed or
254 // summarized form. 256 // summarized form.
255 Status GetDetailedStatus(); 257 Status GetDetailedStatus();
256 csync::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; 258 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const;
257 259
258 // Determines if the underlying sync engine has made any local changes to 260 // Determines if the underlying sync engine has made any local changes to
259 // items that have not yet been synced with the server. 261 // items that have not yet been synced with the server.
260 // ONLY CALL THIS IF OnInitializationComplete was called! 262 // ONLY CALL THIS IF OnInitializationComplete was called!
261 bool HasUnsyncedItems() const; 263 bool HasUnsyncedItems() const;
262 264
263 // Whether or not we are syncing encryption keys. 265 // Whether or not we are syncing encryption keys.
264 bool IsNigoriEnabled() const; 266 bool IsNigoriEnabled() const;
265 267
266 // Whether or not the Nigori node is encrypted using an explicit passphrase. 268 // Whether or not the Nigori node is encrypted using an explicit passphrase.
267 bool IsUsingExplicitPassphrase(); 269 bool IsUsingExplicitPassphrase();
268 270
269 // True if the cryptographer has any keys available to attempt decryption. 271 // True if the cryptographer has any keys available to attempt decryption.
270 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped 272 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped
271 // using a token previously received. 273 // using a token previously received.
272 bool IsCryptographerReady(const csync::BaseTransaction* trans) const; 274 bool IsCryptographerReady(const syncer::BaseTransaction* trans) const;
273 275
274 void GetModelSafeRoutingInfo(csync::ModelSafeRoutingInfo* out) const; 276 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const;
275 277
276 protected: 278 protected:
277 // The types and functions below are protected so that test 279 // The types and functions below are protected so that test
278 // subclasses can use them. 280 // subclasses can use them.
279 // 281 //
280 // TODO(akalin): Figure out a better way for tests to hook into 282 // TODO(akalin): Figure out a better way for tests to hook into
281 // SyncBackendHost. 283 // SyncBackendHost.
282 284
283 typedef base::Callback<csync::HttpPostProviderFactory*(void)> 285 typedef base::Callback<syncer::HttpPostProviderFactory*(void)>
284 MakeHttpBridgeFactoryFn; 286 MakeHttpBridgeFactoryFn;
285 287
286 struct DoInitializeOptions { 288 struct DoInitializeOptions {
287 DoInitializeOptions( 289 DoInitializeOptions(
288 MessageLoop* sync_loop, 290 MessageLoop* sync_loop,
289 SyncBackendRegistrar* registrar, 291 SyncBackendRegistrar* registrar,
290 const csync::ModelSafeRoutingInfo& routing_info, 292 const syncer::ModelSafeRoutingInfo& routing_info,
291 const std::vector<csync::ModelSafeWorker*>& workers, 293 const std::vector<syncer::ModelSafeWorker*>& workers,
292 csync::ExtensionsActivityMonitor* extensions_activity_monitor, 294 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
293 const csync::WeakHandle<csync::JsEventHandler>& event_handler, 295 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
294 const GURL& service_url, 296 const GURL& service_url,
295 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 297 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
296 const csync::SyncCredentials& credentials, 298 const syncer::SyncCredentials& credentials,
297 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, 299 ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
298 csync::SyncNotifierFactory* sync_notifier_factory, 300 syncer::SyncNotifierFactory* sync_notifier_factory,
299 bool delete_sync_data_folder, 301 bool delete_sync_data_folder,
300 const std::string& restored_key_for_bootstrapping, 302 const std::string& restored_key_for_bootstrapping,
301 csync::SyncManager::TestingMode testing_mode, 303 syncer::SyncManager::TestingMode testing_mode,
302 csync::UnrecoverableErrorHandler* unrecoverable_error_handler, 304 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
303 csync::ReportUnrecoverableErrorFunction 305 syncer::ReportUnrecoverableErrorFunction
304 report_unrecoverable_error_function); 306 report_unrecoverable_error_function);
305 ~DoInitializeOptions(); 307 ~DoInitializeOptions();
306 308
307 MessageLoop* sync_loop; 309 MessageLoop* sync_loop;
308 SyncBackendRegistrar* registrar; 310 SyncBackendRegistrar* registrar;
309 csync::ModelSafeRoutingInfo routing_info; 311 syncer::ModelSafeRoutingInfo routing_info;
310 std::vector<csync::ModelSafeWorker*> workers; 312 std::vector<syncer::ModelSafeWorker*> workers;
311 csync::ExtensionsActivityMonitor* extensions_activity_monitor; 313 syncer::ExtensionsActivityMonitor* extensions_activity_monitor;
312 csync::WeakHandle<csync::JsEventHandler> event_handler; 314 syncer::WeakHandle<syncer::JsEventHandler> event_handler;
313 GURL service_url; 315 GURL service_url;
314 // Overridden by tests. 316 // Overridden by tests.
315 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; 317 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn;
316 csync::SyncCredentials credentials; 318 syncer::SyncCredentials credentials;
317 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge; 319 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge;
318 csync::SyncNotifierFactory* const sync_notifier_factory; 320 syncer::SyncNotifierFactory* const sync_notifier_factory;
319 std::string lsid; 321 std::string lsid;
320 bool delete_sync_data_folder; 322 bool delete_sync_data_folder;
321 std::string restored_key_for_bootstrapping; 323 std::string restored_key_for_bootstrapping;
322 csync::SyncManager::TestingMode testing_mode; 324 syncer::SyncManager::TestingMode testing_mode;
323 csync::UnrecoverableErrorHandler* unrecoverable_error_handler; 325 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler;
324 csync::ReportUnrecoverableErrorFunction 326 syncer::ReportUnrecoverableErrorFunction
325 report_unrecoverable_error_function; 327 report_unrecoverable_error_function;
326 }; 328 };
327 329
328 // Allows tests to perform alternate core initialization work. 330 // Allows tests to perform alternate core initialization work.
329 virtual void InitCore(const DoInitializeOptions& options); 331 virtual void InitCore(const DoInitializeOptions& options);
330 332
331 // Called from Core::OnSyncCycleCompleted to handle updating frontend 333 // Called from Core::OnSyncCycleCompleted to handle updating frontend
332 // thread components. 334 // thread components.
333 void HandleSyncCycleCompletedOnFrontendLoop( 335 void HandleSyncCycleCompletedOnFrontendLoop(
334 const csync::sessions::SyncSessionSnapshot& snapshot); 336 const syncer::sessions::SyncSessionSnapshot& snapshot);
335 337
336 // Called to finish the job of ConfigureDataTypes once the syncer is in 338 // Called to finish the job of ConfigureDataTypes once the syncer is in
337 // configuration mode. 339 // configuration mode.
338 void FinishConfigureDataTypesOnFrontendLoop(); 340 void FinishConfigureDataTypesOnFrontendLoop();
339 341
340 bool IsDownloadingNigoriForTest() const; 342 bool IsDownloadingNigoriForTest() const;
341 343
342 private: 344 private:
343 // The real guts of SyncBackendHost, to keep the public client API clean. 345 // The real guts of SyncBackendHost, to keep the public client API clean.
344 class Core; 346 class Core;
(...skipping 30 matching lines...) Expand all
375 // that we will not notify DTM until the sync is successful or in a 377 // that we will not notify DTM until the sync is successful or in a
376 // permanent error state. 378 // permanent error state.
377 base::Callback<void()> retry_callback; 379 base::Callback<void()> retry_callback;
378 380
379 // The set of types that we are waiting to be initially synced in a 381 // The set of types that we are waiting to be initially synced in a
380 // configuration cycle. 382 // configuration cycle.
381 syncable::ModelTypeSet types_to_add; 383 syncable::ModelTypeSet types_to_add;
382 384
383 // Additional details about which types were added. 385 // Additional details about which types were added.
384 syncable::ModelTypeSet added_types; 386 syncable::ModelTypeSet added_types;
385 csync::ConfigureReason reason; 387 syncer::ConfigureReason reason;
386 bool retry_in_progress; 388 bool retry_in_progress;
387 }; 389 };
388 390
389 // Checks if we have received a notice to turn on experimental datatypes 391 // Checks if we have received a notice to turn on experimental datatypes
390 // (via the nigori node) and informs the frontend if that is the case. 392 // (via the nigori node) and informs the frontend if that is the case.
391 // Note: it is illegal to call this before the backend is initialized. 393 // Note: it is illegal to call this before the backend is initialized.
392 void AddExperimentalTypes(); 394 void AddExperimentalTypes();
393 395
394 // Downloading of nigori failed and will be retried. 396 // Downloading of nigori failed and will be retried.
395 virtual void OnNigoriDownloadRetry(); 397 virtual void OnNigoriDownloadRetry();
396 398
397 // InitializationComplete passes through the SyncBackendHost to forward 399 // InitializationComplete passes through the SyncBackendHost to forward
398 // on to |frontend_|, and so that tests can intercept here if they need to 400 // on to |frontend_|, and so that tests can intercept here if they need to
399 // set up initial conditions. 401 // set up initial conditions.
400 virtual void HandleInitializationCompletedOnFrontendLoop( 402 virtual void HandleInitializationCompletedOnFrontendLoop(
401 const csync::WeakHandle<csync::JsBackend>& js_backend, 403 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
402 bool success); 404 bool success);
403 405
404 // Helpers to persist a token that can be used to bootstrap sync encryption 406 // Helpers to persist a token that can be used to bootstrap sync encryption
405 // across browser restart to avoid requiring the user to re-enter their 407 // across browser restart to avoid requiring the user to re-enter their
406 // passphrase. |token| must be valid UTF-8 as we use the PrefService for 408 // passphrase. |token| must be valid UTF-8 as we use the PrefService for
407 // storage. 409 // storage.
408 void PersistEncryptionBootstrapToken(const std::string& token); 410 void PersistEncryptionBootstrapToken(const std::string& token);
409 411
410 // For convenience, checks if initialization state is INITIALIZED. 412 // For convenience, checks if initialization state is INITIALIZED.
411 bool initialized() const { return initialization_state_ == INITIALIZED; } 413 bool initialized() const { return initialization_state_ == INITIALIZED; }
412 414
413 // Let the front end handle the actionable error event. 415 // Let the front end handle the actionable error event.
414 void HandleActionableErrorEventOnFrontendLoop( 416 void HandleActionableErrorEventOnFrontendLoop(
415 const csync::SyncProtocolError& sync_error); 417 const syncer::SyncProtocolError& sync_error);
416 418
417 // Checks if |passphrase| can be used to decrypt the cryptographer's pending 419 // Checks if |passphrase| can be used to decrypt the cryptographer's pending
418 // keys that were cached during NotifyPassphraseRequired. Returns true if 420 // keys that were cached during NotifyPassphraseRequired. Returns true if
419 // decryption was successful. Returns false otherwise. Must be called with a 421 // decryption was successful. Returns false otherwise. Must be called with a
420 // non-empty pending keys cache. 422 // non-empty pending keys cache.
421 bool CheckPassphraseAgainstCachedPendingKeys( 423 bool CheckPassphraseAgainstCachedPendingKeys(
422 const std::string& passphrase) const; 424 const std::string& passphrase) const;
423 425
424 // Invoked when a passphrase is required to decrypt a set of Nigori keys, 426 // Invoked when a passphrase is required to decrypt a set of Nigori keys,
425 // or for encrypting. |reason| denotes why the passphrase was required. 427 // or for encrypting. |reason| denotes why the passphrase was required.
426 // |pending_keys| is a copy of the cryptographer's pending keys, that are 428 // |pending_keys| is a copy of the cryptographer's pending keys, that are
427 // cached by the frontend. If there are no pending keys, or if the passphrase 429 // cached by the frontend. If there are no pending keys, or if the passphrase
428 // required reason is REASON_ENCRYPTION, an empty EncryptedData object is 430 // required reason is REASON_ENCRYPTION, an empty EncryptedData object is
429 // passed. 431 // passed.
430 void NotifyPassphraseRequired(csync::PassphraseRequiredReason reason, 432 void NotifyPassphraseRequired(syncer::PassphraseRequiredReason reason,
431 sync_pb::EncryptedData pending_keys); 433 sync_pb::EncryptedData pending_keys);
432 434
433 // Invoked when the passphrase provided by the user has been accepted. 435 // Invoked when the passphrase provided by the user has been accepted.
434 void NotifyPassphraseAccepted(); 436 void NotifyPassphraseAccepted();
435 437
436 // Invoked when an updated token is available from the sync server. 438 // Invoked when an updated token is available from the sync server.
437 void NotifyUpdatedToken(const std::string& token); 439 void NotifyUpdatedToken(const std::string& token);
438 440
439 // Invoked when the set of encrypted types or the encrypt 441 // Invoked when the set of encrypted types or the encrypt
440 // everything flag changes. 442 // everything flag changes.
441 void NotifyEncryptedTypesChanged( 443 void NotifyEncryptedTypesChanged(
442 syncable::ModelTypeSet encrypted_types, 444 syncable::ModelTypeSet encrypted_types,
443 bool encrypt_everything); 445 bool encrypt_everything);
444 446
445 // Invoked when sync finishes encrypting new datatypes. 447 // Invoked when sync finishes encrypting new datatypes.
446 void NotifyEncryptionComplete(); 448 void NotifyEncryptionComplete();
447 449
448 void HandleStopSyncingPermanentlyOnFrontendLoop(); 450 void HandleStopSyncingPermanentlyOnFrontendLoop();
449 451
450 // Dispatched to from OnConnectionStatusChange to handle updating 452 // Dispatched to from OnConnectionStatusChange to handle updating
451 // frontend UI components. 453 // frontend UI components.
452 void HandleConnectionStatusChangeOnFrontendLoop( 454 void HandleConnectionStatusChangeOnFrontendLoop(
453 csync::ConnectionStatus status); 455 syncer::ConnectionStatus status);
454 456
455 // Called when configuration of the Nigori node has completed as 457 // Called when configuration of the Nigori node has completed as
456 // part of the initialization process. 458 // part of the initialization process.
457 void HandleNigoriConfigurationCompletedOnFrontendLoop( 459 void HandleNigoriConfigurationCompletedOnFrontendLoop(
458 const csync::WeakHandle<csync::JsBackend>& js_backend, 460 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
459 syncable::ModelTypeSet failed_configuration_types); 461 syncable::ModelTypeSet failed_configuration_types);
460 462
461 // Must be called on |frontend_loop_|. |done_callback| is called on 463 // Must be called on |frontend_loop_|. |done_callback| is called on
462 // |frontend_loop_|. 464 // |frontend_loop_|.
463 void RefreshNigori(const base::Closure& done_callback); 465 void RefreshNigori(const base::Closure& done_callback);
464 466
465 // Handles stopping the core's SyncManager, accounting for whether 467 // Handles stopping the core's SyncManager, accounting for whether
466 // initialization is done yet. 468 // initialization is done yet.
467 void StopSyncManagerForShutdown(const base::Closure& closure); 469 void StopSyncManagerForShutdown(const base::Closure& closure);
468 470
(...skipping 15 matching lines...) Expand all
484 scoped_refptr<Core> core_; 486 scoped_refptr<Core> core_;
485 487
486 InitializationState initialization_state_; 488 InitializationState initialization_state_;
487 489
488 const base::WeakPtr<SyncPrefs> sync_prefs_; 490 const base::WeakPtr<SyncPrefs> sync_prefs_;
489 491
490 // A thread-safe listener for handling notifications triggered by 492 // A thread-safe listener for handling notifications triggered by
491 // chrome events. 493 // chrome events.
492 ChromeSyncNotificationBridge chrome_sync_notification_bridge_; 494 ChromeSyncNotificationBridge chrome_sync_notification_bridge_;
493 495
494 csync::SyncNotifierFactory sync_notifier_factory_; 496 syncer::SyncNotifierFactory sync_notifier_factory_;
495 497
496 ChromeExtensionsActivityMonitor extensions_activity_monitor_; 498 ChromeExtensionsActivityMonitor extensions_activity_monitor_;
497 499
498 scoped_ptr<SyncBackendRegistrar> registrar_; 500 scoped_ptr<SyncBackendRegistrar> registrar_;
499 501
500 // The frontend which we serve (and are owned by). 502 // The frontend which we serve (and are owned by).
501 SyncFrontend* frontend_; 503 SyncFrontend* frontend_;
502 504
503 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; 505 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_;
504 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; 506 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_;
505 507
506 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired 508 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired
507 // is called. This way, before the UI calls SetDecryptionPassphrase on the 509 // is called. This way, before the UI calls SetDecryptionPassphrase on the
508 // syncer, it can avoid the overhead of an asynchronous decryption call and 510 // syncer, it can avoid the overhead of an asynchronous decryption call and
509 // give the user immediate feedback about the passphrase entered by first 511 // give the user immediate feedback about the passphrase entered by first
510 // trying to decrypt the cached pending keys on the UI thread. Note that 512 // trying to decrypt the cached pending keys on the UI thread. Note that
511 // SetDecryptionPassphrase can still fail after the cached pending keys are 513 // SetDecryptionPassphrase can still fail after the cached pending keys are
512 // successfully decrypted if the pending keys have changed since the time they 514 // successfully decrypted if the pending keys have changed since the time they
513 // were cached. 515 // were cached.
514 sync_pb::EncryptedData cached_pending_keys_; 516 sync_pb::EncryptedData cached_pending_keys_;
515 517
516 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 518 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
517 csync::sessions::SyncSessionSnapshot last_snapshot_; 519 syncer::sessions::SyncSessionSnapshot last_snapshot_;
518 520
519 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 521 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
520 }; 522 };
521 523
522 } // namespace browser_sync 524 } // namespace browser_sync
523 525
524 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 526 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/shared_change_processor_unittest.cc ('k') | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698