OLD | NEW |
---|---|
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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "chrome/browser/invalidation/invalidation_service.h" | 17 #include "chrome/browser/invalidation/invalidation_service.h" |
18 #include "chrome/browser/sync/glue/backend_data_type_configurer.h" | 18 #include "chrome/browser/sync/glue/backend_data_type_configurer.h" |
19 #include "chrome/browser/sync/glue/extensions_activity_monitor.h" | 19 #include "chrome/browser/sync/glue/extensions_activity_monitor.h" |
20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
22 #include "google_apis/gaia/google_service_auth_error.h" | 22 #include "google_apis/gaia/google_service_auth_error.h" |
23 #include "sync/internal_api/public/base/cancellation_signal.h" | |
23 #include "sync/internal_api/public/base/model_type.h" | 24 #include "sync/internal_api/public/base/model_type.h" |
24 #include "sync/internal_api/public/configure_reason.h" | 25 #include "sync/internal_api/public/configure_reason.h" |
25 #include "sync/internal_api/public/engine/model_safe_worker.h" | 26 #include "sync/internal_api/public/engine/model_safe_worker.h" |
26 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 27 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
27 #include "sync/internal_api/public/sync_encryption_handler.h" | 28 #include "sync/internal_api/public/sync_encryption_handler.h" |
28 #include "sync/internal_api/public/sync_manager.h" | 29 #include "sync/internal_api/public/sync_manager.h" |
29 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 30 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
30 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 31 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
31 #include "sync/internal_api/public/util/weak_handle.h" | 32 #include "sync/internal_api/public/util/weak_handle.h" |
32 #include "sync/notifier/invalidation_handler.h" | 33 #include "sync/notifier/invalidation_handler.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 | 212 |
212 // Called on |frontend_loop_| to use the provided passphrase to asynchronously | 213 // Called on |frontend_loop_| to use the provided passphrase to asynchronously |
213 // attempt decryption. Returns false immediately if the passphrase could not | 214 // attempt decryption. Returns false immediately if the passphrase could not |
214 // be used to decrypt a locally cached copy of encrypted keys; returns true | 215 // be used to decrypt a locally cached copy of encrypted keys; returns true |
215 // otherwise. If new encrypted keys arrive during the asynchronous call, | 216 // otherwise. If new encrypted keys arrive during the asynchronous call, |
216 // OnPassphraseRequired may be triggered at a later time. It is an error to | 217 // OnPassphraseRequired may be triggered at a later time. It is an error to |
217 // call this when there are no pending keys. | 218 // call this when there are no pending keys. |
218 bool SetDecryptionPassphrase(const std::string& passphrase) | 219 bool SetDecryptionPassphrase(const std::string& passphrase) |
219 WARN_UNUSED_RESULT; | 220 WARN_UNUSED_RESULT; |
220 | 221 |
221 // Called on |frontend_loop_| to kick off shutdown procedure. After this, no | 222 // 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 | 223 // short any long-lived or blocking sync thread tasks so that the shutdown on |
223 // change applications will occur from changes already downloaded. | 224 // 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(); | 225 virtual void StopSyncingForShutdown(); |
226 | 226 |
227 // Called on |frontend_loop_| to kick off shutdown. | 227 // Called on |frontend_loop_| to kick off shutdown. |
228 // See the implementation and Core::DoShutdown for details. | 228 // See the implementation and Core::DoShutdown for details. |
229 // Must be called *after* StopSyncingForShutdown. Caller should claim sync | 229 // Must be called *after* StopSyncingForShutdown. Caller should claim sync |
230 // thread using STOP_AND_CLAIM_THREAD or DISABLE_AND_CLAIM_THREAD if sync | 230 // thread using STOP_AND_CLAIM_THREAD or DISABLE_AND_CLAIM_THREAD if sync |
231 // backend might be recreated later because otherwise: | 231 // backend might be recreated later because otherwise: |
232 // * sync loop may be stopped on main loop and cause it to be blocked. | 232 // * 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 | 233 // * new/old backend may interfere with each other if new backend is created |
234 // before old one finishes cleanup. | 234 // before old one finishes cleanup. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 332 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
333 bool delete_sync_data_folder, | 333 bool delete_sync_data_folder, |
334 const std::string& restored_key_for_bootstrapping, | 334 const std::string& restored_key_for_bootstrapping, |
335 const std::string& restored_keystore_key_for_bootstrapping, | 335 const std::string& restored_keystore_key_for_bootstrapping, |
336 scoped_ptr<syncer::InternalComponentsFactory> | 336 scoped_ptr<syncer::InternalComponentsFactory> |
337 internal_components_factory, | 337 internal_components_factory, |
338 scoped_ptr<syncer::UnrecoverableErrorHandler> | 338 scoped_ptr<syncer::UnrecoverableErrorHandler> |
339 unrecoverable_error_handler, | 339 unrecoverable_error_handler, |
340 syncer::ReportUnrecoverableErrorFunction | 340 syncer::ReportUnrecoverableErrorFunction |
341 report_unrecoverable_error_function, | 341 report_unrecoverable_error_function, |
342 bool use_oauth2_token); | 342 bool use_oauth2_token, |
343 syncer::CancellationSignal* cancellation_signal); | |
343 ~DoInitializeOptions(); | 344 ~DoInitializeOptions(); |
344 | 345 |
345 base::MessageLoop* sync_loop; | 346 base::MessageLoop* sync_loop; |
346 SyncBackendRegistrar* registrar; | 347 SyncBackendRegistrar* registrar; |
347 syncer::ModelSafeRoutingInfo routing_info; | 348 syncer::ModelSafeRoutingInfo routing_info; |
348 std::vector<syncer::ModelSafeWorker*> workers; | 349 std::vector<syncer::ModelSafeWorker*> workers; |
349 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; | 350 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; |
350 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 351 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
351 GURL service_url; | 352 GURL service_url; |
352 // Overridden by tests. | 353 // Overridden by tests. |
353 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; | 354 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; |
354 syncer::SyncCredentials credentials; | 355 syncer::SyncCredentials credentials; |
355 const std::string invalidator_client_id; | 356 const std::string invalidator_client_id; |
356 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; | 357 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; |
357 std::string lsid; | 358 std::string lsid; |
358 bool delete_sync_data_folder; | 359 bool delete_sync_data_folder; |
359 std::string restored_key_for_bootstrapping; | 360 std::string restored_key_for_bootstrapping; |
360 std::string restored_keystore_key_for_bootstrapping; | 361 std::string restored_keystore_key_for_bootstrapping; |
361 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; | 362 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; |
362 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler; | 363 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler; |
363 syncer::ReportUnrecoverableErrorFunction | 364 syncer::ReportUnrecoverableErrorFunction |
364 report_unrecoverable_error_function; | 365 report_unrecoverable_error_function; |
365 bool use_oauth2_token; | 366 bool use_oauth2_token; |
367 syncer::CancellationSignal* cancellation_signal; | |
akalin
2013/09/05 16:06:35
const?
rlarocque
2013/09/05 22:37:06
Done.
| |
366 }; | 368 }; |
367 | 369 |
368 // Allows tests to perform alternate core initialization work. | 370 // Allows tests to perform alternate core initialization work. |
369 virtual void InitCore(scoped_ptr<DoInitializeOptions> options); | 371 virtual void InitCore(scoped_ptr<DoInitializeOptions> options); |
370 | 372 |
371 // Request the syncer to reconfigure with the specfied params. | 373 // Request the syncer to reconfigure with the specfied params. |
372 // Virtual for testing. | 374 // Virtual for testing. |
373 virtual void RequestConfigureSyncer( | 375 virtual void RequestConfigureSyncer( |
374 syncer::ConfigureReason reason, | 376 syncer::ConfigureReason reason, |
375 syncer::ModelTypeSet to_download, | 377 syncer::ModelTypeSet to_download, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 int type, | 518 int type, |
517 const content::NotificationSource& source, | 519 const content::NotificationSource& source, |
518 const content::NotificationDetails& details) OVERRIDE; | 520 const content::NotificationDetails& details) OVERRIDE; |
519 | 521 |
520 // InvalidationHandler implementation. | 522 // InvalidationHandler implementation. |
521 virtual void OnInvalidatorStateChange( | 523 virtual void OnInvalidatorStateChange( |
522 syncer::InvalidatorState state) OVERRIDE; | 524 syncer::InvalidatorState state) OVERRIDE; |
523 virtual void OnIncomingInvalidation( | 525 virtual void OnIncomingInvalidation( |
524 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 526 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
525 | 527 |
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_; | 528 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; |
531 | 529 |
532 content::NotificationRegistrar notification_registrar_; | 530 content::NotificationRegistrar notification_registrar_; |
533 | 531 |
534 // A reference to the MessageLoop used to construct |this|, so we know how | 532 // A reference to the MessageLoop used to construct |this|, so we know how |
535 // to safely talk back to the SyncFrontend. | 533 // to safely talk back to the SyncFrontend. |
536 base::MessageLoop* const frontend_loop_; | 534 base::MessageLoop* const frontend_loop_; |
537 | 535 |
538 Profile* const profile_; | 536 Profile* const profile_; |
539 | 537 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 // Temporary holder of sync manager's initialization results. Set by | 580 // Temporary holder of sync manager's initialization results. Set by |
583 // HandleSyncManagerInitializationOnFrontendLoop, and consumed when we pass | 581 // HandleSyncManagerInitializationOnFrontendLoop, and consumed when we pass |
584 // it via OnBackendInitialized in the final state of | 582 // it via OnBackendInitialized in the final state of |
585 // HandleInitializationCompletedOnFrontendLoop. | 583 // HandleInitializationCompletedOnFrontendLoop. |
586 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 584 syncer::WeakHandle<syncer::JsBackend> js_backend_; |
587 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 585 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
588 | 586 |
589 invalidation::InvalidationService* invalidator_; | 587 invalidation::InvalidationService* invalidator_; |
590 bool invalidation_handler_registered_; | 588 bool invalidation_handler_registered_; |
591 | 589 |
590 syncer::CancellationSignal cancellation_signal_; | |
591 | |
592 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 592 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
593 }; | 593 }; |
594 | 594 |
595 } // namespace browser_sync | 595 } // namespace browser_sync |
596 | 596 |
597 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 597 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |