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

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

Issue 23717047: Retry: sync: Gracefully handle early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move signals to SyncaBackendHost::Core Created 7 years, 3 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 // Called on |frontend_loop_| to use the provided passphrase to asynchronously 212 // Called on |frontend_loop_| to use the provided passphrase to asynchronously
213 // attempt decryption. Returns false immediately if the passphrase could not 213 // attempt decryption. Returns false immediately if the passphrase could not
214 // be used to decrypt a locally cached copy of encrypted keys; returns true 214 // be used to decrypt a locally cached copy of encrypted keys; returns true
215 // otherwise. If new encrypted keys arrive during the asynchronous call, 215 // otherwise. If new encrypted keys arrive during the asynchronous call,
216 // OnPassphraseRequired may be triggered at a later time. It is an error to 216 // OnPassphraseRequired may be triggered at a later time. It is an error to
217 // call this when there are no pending keys. 217 // call this when there are no pending keys.
218 bool SetDecryptionPassphrase(const std::string& passphrase) 218 bool SetDecryptionPassphrase(const std::string& passphrase)
219 WARN_UNUSED_RESULT; 219 WARN_UNUSED_RESULT;
220 220
221 // Called on |frontend_loop_| to kick off shutdown procedure. After this, no 221 // Called on |frontend_loop_| to kick off shutdown procedure. Attempts to cut
222 // further sync activity will occur with the sync server and no further 222 // short any long-lived or blocking sync thread tasks so that the shutdown on
223 // change applications will occur from changes already downloaded. 223 // sync thread task that we're about to post won't have to wait very long.
224 // Furthermore, no notifications will be sent to any invalidation handler.
225 virtual void StopSyncingForShutdown(); 224 virtual void StopSyncingForShutdown();
226 225
227 // Called on |frontend_loop_| to kick off shutdown. 226 // Called on |frontend_loop_| to kick off shutdown.
228 // See the implementation and Core::DoShutdown for details. 227 // See the implementation and Core::DoShutdown for details.
229 // Must be called *after* StopSyncingForShutdown. Caller should claim sync 228 // Must be called *after* StopSyncingForShutdown. Caller should claim sync
230 // thread using STOP_AND_CLAIM_THREAD or DISABLE_AND_CLAIM_THREAD if sync 229 // thread using STOP_AND_CLAIM_THREAD or DISABLE_AND_CLAIM_THREAD if sync
231 // backend might be recreated later because otherwise: 230 // backend might be recreated later because otherwise:
232 // * sync loop may be stopped on main loop and cause it to be blocked. 231 // * sync loop may be stopped on main loop and cause it to be blocked.
233 // * new/old backend may interfere with each other if new backend is created 232 // * new/old backend may interfere with each other if new backend is created
234 // before old one finishes cleanup. 233 // before old one finishes cleanup.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 305
307 base::MessageLoop* GetSyncLoopForTesting(); 306 base::MessageLoop* GetSyncLoopForTesting();
308 307
309 protected: 308 protected:
310 // The types and functions below are protected so that test 309 // The types and functions below are protected so that test
311 // subclasses can use them. 310 // subclasses can use them.
312 // 311 //
313 // TODO(akalin): Figure out a better way for tests to hook into 312 // TODO(akalin): Figure out a better way for tests to hook into
314 // SyncBackendHost. 313 // SyncBackendHost.
315 314
316 typedef base::Callback<scoped_ptr<syncer::HttpPostProviderFactory>(void)>
317 MakeHttpBridgeFactoryFn;
318
319 // Utility struct for holding initialization options. 315 // Utility struct for holding initialization options.
320 struct DoInitializeOptions { 316 struct DoInitializeOptions {
321 DoInitializeOptions( 317 DoInitializeOptions(
322 base::MessageLoop* sync_loop, 318 base::MessageLoop* sync_loop,
323 SyncBackendRegistrar* registrar, 319 SyncBackendRegistrar* registrar,
324 const syncer::ModelSafeRoutingInfo& routing_info, 320 const syncer::ModelSafeRoutingInfo& routing_info,
325 const std::vector<syncer::ModelSafeWorker*>& workers, 321 const std::vector<syncer::ModelSafeWorker*>& workers,
326 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, 322 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity,
327 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 323 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
328 const GURL& service_url, 324 const GURL& service_url,
329 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 325 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory,
330 const syncer::SyncCredentials& credentials, 326 const syncer::SyncCredentials& credentials,
331 const std::string& invalidator_client_id, 327 const std::string& invalidator_client_id,
332 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, 328 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
333 bool delete_sync_data_folder, 329 bool delete_sync_data_folder,
334 const std::string& restored_key_for_bootstrapping, 330 const std::string& restored_key_for_bootstrapping,
335 const std::string& restored_keystore_key_for_bootstrapping, 331 const std::string& restored_keystore_key_for_bootstrapping,
336 scoped_ptr<syncer::InternalComponentsFactory> 332 scoped_ptr<syncer::InternalComponentsFactory>
337 internal_components_factory, 333 internal_components_factory,
338 scoped_ptr<syncer::UnrecoverableErrorHandler> 334 scoped_ptr<syncer::UnrecoverableErrorHandler>
339 unrecoverable_error_handler, 335 unrecoverable_error_handler,
340 syncer::ReportUnrecoverableErrorFunction 336 syncer::ReportUnrecoverableErrorFunction
341 report_unrecoverable_error_function, 337 report_unrecoverable_error_function,
342 bool use_oauth2_token); 338 bool use_oauth2_token);
343 ~DoInitializeOptions(); 339 ~DoInitializeOptions();
344 340
345 base::MessageLoop* sync_loop; 341 base::MessageLoop* sync_loop;
346 SyncBackendRegistrar* registrar; 342 SyncBackendRegistrar* registrar;
347 syncer::ModelSafeRoutingInfo routing_info; 343 syncer::ModelSafeRoutingInfo routing_info;
348 std::vector<syncer::ModelSafeWorker*> workers; 344 std::vector<syncer::ModelSafeWorker*> workers;
349 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; 345 scoped_refptr<syncer::ExtensionsActivity> extensions_activity;
350 syncer::WeakHandle<syncer::JsEventHandler> event_handler; 346 syncer::WeakHandle<syncer::JsEventHandler> event_handler;
351 GURL service_url; 347 GURL service_url;
352 // Overridden by tests. 348 // Overridden by tests.
353 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; 349 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory;
354 syncer::SyncCredentials credentials; 350 syncer::SyncCredentials credentials;
355 const std::string invalidator_client_id; 351 const std::string invalidator_client_id;
356 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; 352 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory;
357 std::string lsid; 353 std::string lsid;
358 bool delete_sync_data_folder; 354 bool delete_sync_data_folder;
359 std::string restored_key_for_bootstrapping; 355 std::string restored_key_for_bootstrapping;
360 std::string restored_keystore_key_for_bootstrapping; 356 std::string restored_keystore_key_for_bootstrapping;
361 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; 357 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory;
362 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler; 358 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler;
363 syncer::ReportUnrecoverableErrorFunction 359 syncer::ReportUnrecoverableErrorFunction
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 int type, 512 int type,
517 const content::NotificationSource& source, 513 const content::NotificationSource& source,
518 const content::NotificationDetails& details) OVERRIDE; 514 const content::NotificationDetails& details) OVERRIDE;
519 515
520 // InvalidationHandler implementation. 516 // InvalidationHandler implementation.
521 virtual void OnInvalidatorStateChange( 517 virtual void OnInvalidatorStateChange(
522 syncer::InvalidatorState state) OVERRIDE; 518 syncer::InvalidatorState state) OVERRIDE;
523 virtual void OnIncomingInvalidation( 519 virtual void OnIncomingInvalidation(
524 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 520 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
525 521
526 // Handles stopping the core's SyncManager, accounting for whether
527 // initialization is done yet.
528 void StopSyncManagerForShutdown();
529
530 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; 522 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_;
531 523
532 content::NotificationRegistrar notification_registrar_; 524 content::NotificationRegistrar notification_registrar_;
533 525
534 // A reference to the MessageLoop used to construct |this|, so we know how 526 // A reference to the MessageLoop used to construct |this|, so we know how
535 // to safely talk back to the SyncFrontend. 527 // to safely talk back to the SyncFrontend.
536 base::MessageLoop* const frontend_loop_; 528 base::MessageLoop* const frontend_loop_;
537 529
538 Profile* const profile_; 530 Profile* const profile_;
539 531
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 580
589 invalidation::InvalidationService* invalidator_; 581 invalidation::InvalidationService* invalidator_;
590 bool invalidation_handler_registered_; 582 bool invalidation_handler_registered_;
591 583
592 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 584 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
593 }; 585 };
594 586
595 } // namespace browser_sync 587 } // namespace browser_sync
596 588
597 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 589 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | chrome/browser/sync/glue/sync_backend_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698