| 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/sync/glue/backend_data_type_configurer.h" | 17 #include "chrome/browser/sync/glue/backend_data_type_configurer.h" |
| 18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h" | 18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h" |
| 19 #include "chrome/common/net/gaia/google_service_auth_error.h" | 19 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 #include "sync/internal_api/public/base/model_type.h" | 21 #include "sync/internal_api/public/base/model_type.h" |
| 22 #include "sync/internal_api/public/configure_reason.h" | 22 #include "sync/internal_api/public/configure_reason.h" |
| 23 #include "sync/internal_api/public/engine/model_safe_worker.h" | 23 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 25 #include "sync/internal_api/public/sync_encryption_handler.h" | 25 #include "sync/internal_api/public/sync_encryption_handler.h" |
| 26 #include "sync/internal_api/public/sync_manager.h" | 26 #include "sync/internal_api/public/sync_manager.h" |
| 27 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 27 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 28 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 28 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 29 #include "sync/internal_api/public/util/weak_handle.h" | 29 #include "sync/internal_api/public/util/weak_handle.h" |
| 30 #include "sync/notifier/sync_notifier_factory.h" | 30 #include "sync/notifier/invalidation_handler.h" |
| 31 #include "sync/notifier/sync_notifier_observer.h" | 31 #include "sync/notifier/invalidator_factory.h" |
| 32 #include "sync/protocol/encryption.pb.h" | 32 #include "sync/protocol/encryption.pb.h" |
| 33 #include "sync/protocol/sync_protocol_error.h" | 33 #include "sync/protocol/sync_protocol_error.h" |
| 34 | 34 |
| 35 class MessageLoop; | 35 class MessageLoop; |
| 36 class Profile; | 36 class Profile; |
| 37 | 37 |
| 38 namespace syncer { | 38 namespace syncer { |
| 39 class SyncManagerFactory; | 39 class SyncManagerFactory; |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace browser_sync { | 42 namespace browser_sync { |
| 43 | 43 |
| 44 class ChangeProcessor; | 44 class ChangeProcessor; |
| 45 class ChromeSyncNotificationBridge; | 45 class ChromeSyncNotificationBridge; |
| 46 struct Experiments; | 46 struct Experiments; |
| 47 class InvalidatorStorage; | 47 class InvalidatorStorage; |
| 48 class SyncBackendRegistrar; | 48 class SyncBackendRegistrar; |
| 49 class SyncPrefs; | 49 class SyncPrefs; |
| 50 | 50 |
| 51 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 51 // SyncFrontend is the interface used by SyncBackendHost to communicate with |
| 52 // the entity that created it and, presumably, is interested in sync-related | 52 // the entity that created it and, presumably, is interested in sync-related |
| 53 // activity. | 53 // activity. |
| 54 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 54 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread |
| 55 // used to create that SyncBackendHost. | 55 // used to create that SyncBackendHost. |
| 56 class SyncFrontend : public syncer::SyncNotifierObserver { | 56 class SyncFrontend : public syncer::InvalidationHandler { |
| 57 public: | 57 public: |
| 58 SyncFrontend() {} | 58 SyncFrontend() {} |
| 59 | 59 |
| 60 // The backend has completed initialization and it is now ready to | 60 // The backend has completed initialization and it is now ready to |
| 61 // accept and process changes. If success is false, initialization | 61 // accept and process changes. If success is false, initialization |
| 62 // wasn't able to be completed and should be retried. | 62 // wasn't able to be completed and should be retried. |
| 63 // | 63 // |
| 64 // |js_backend| is what about:sync interacts with; it's different | 64 // |js_backend| is what about:sync interacts with; it's different |
| 65 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It | 65 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It |
| 66 // is initialized only if |success| is true. | 66 // is initialized only if |success| is true. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 MessageLoop* sync_loop, | 292 MessageLoop* sync_loop, |
| 293 SyncBackendRegistrar* registrar, | 293 SyncBackendRegistrar* registrar, |
| 294 const syncer::ModelSafeRoutingInfo& routing_info, | 294 const syncer::ModelSafeRoutingInfo& routing_info, |
| 295 const std::vector<syncer::ModelSafeWorker*>& workers, | 295 const std::vector<syncer::ModelSafeWorker*>& workers, |
| 296 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 296 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
| 297 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 297 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 298 const GURL& service_url, | 298 const GURL& service_url, |
| 299 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, | 299 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, |
| 300 const syncer::SyncCredentials& credentials, | 300 const syncer::SyncCredentials& credentials, |
| 301 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, | 301 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, |
| 302 syncer::SyncNotifierFactory* sync_notifier_factory, | 302 syncer::InvalidatorFactory* invalidator_factory, |
| 303 syncer::SyncManagerFactory* sync_manager_factory, | 303 syncer::SyncManagerFactory* sync_manager_factory, |
| 304 bool delete_sync_data_folder, | 304 bool delete_sync_data_folder, |
| 305 const std::string& restored_key_for_bootstrapping, | 305 const std::string& restored_key_for_bootstrapping, |
| 306 const std::string& restored_keystore_key_for_bootstrapping, | 306 const std::string& restored_keystore_key_for_bootstrapping, |
| 307 syncer::InternalComponentsFactory* internal_components_factory, | 307 syncer::InternalComponentsFactory* internal_components_factory, |
| 308 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 308 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 309 syncer::ReportUnrecoverableErrorFunction | 309 syncer::ReportUnrecoverableErrorFunction |
| 310 report_unrecoverable_error_function); | 310 report_unrecoverable_error_function); |
| 311 ~DoInitializeOptions(); | 311 ~DoInitializeOptions(); |
| 312 | 312 |
| 313 MessageLoop* sync_loop; | 313 MessageLoop* sync_loop; |
| 314 SyncBackendRegistrar* registrar; | 314 SyncBackendRegistrar* registrar; |
| 315 syncer::ModelSafeRoutingInfo routing_info; | 315 syncer::ModelSafeRoutingInfo routing_info; |
| 316 std::vector<syncer::ModelSafeWorker*> workers; | 316 std::vector<syncer::ModelSafeWorker*> workers; |
| 317 syncer::ExtensionsActivityMonitor* extensions_activity_monitor; | 317 syncer::ExtensionsActivityMonitor* extensions_activity_monitor; |
| 318 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 318 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
| 319 GURL service_url; | 319 GURL service_url; |
| 320 // Overridden by tests. | 320 // Overridden by tests. |
| 321 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; | 321 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; |
| 322 syncer::SyncCredentials credentials; | 322 syncer::SyncCredentials credentials; |
| 323 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge; | 323 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge; |
| 324 syncer::SyncNotifierFactory* const sync_notifier_factory; | 324 syncer::InvalidatorFactory* const invalidator_factory; |
| 325 syncer::SyncManagerFactory* const sync_manager_factory; | 325 syncer::SyncManagerFactory* const sync_manager_factory; |
| 326 std::string lsid; | 326 std::string lsid; |
| 327 bool delete_sync_data_folder; | 327 bool delete_sync_data_folder; |
| 328 std::string restored_key_for_bootstrapping; | 328 std::string restored_key_for_bootstrapping; |
| 329 std::string restored_keystore_key_for_bootstrapping; | 329 std::string restored_keystore_key_for_bootstrapping; |
| 330 syncer::InternalComponentsFactory* internal_components_factory; | 330 syncer::InternalComponentsFactory* internal_components_factory; |
| 331 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler; | 331 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler; |
| 332 syncer::ReportUnrecoverableErrorFunction | 332 syncer::ReportUnrecoverableErrorFunction |
| 333 report_unrecoverable_error_function; | 333 report_unrecoverable_error_function; |
| 334 }; | 334 }; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // Dispatched to from OnConnectionStatusChange to handle updating | 464 // Dispatched to from OnConnectionStatusChange to handle updating |
| 465 // frontend UI components. | 465 // frontend UI components. |
| 466 void HandleConnectionStatusChangeOnFrontendLoop( | 466 void HandleConnectionStatusChangeOnFrontendLoop( |
| 467 syncer::ConnectionStatus status); | 467 syncer::ConnectionStatus status); |
| 468 | 468 |
| 469 // Called when configuration of the Nigori node has completed as | 469 // Called when configuration of the Nigori node has completed as |
| 470 // part of the initialization process. | 470 // part of the initialization process. |
| 471 void HandleNigoriConfigurationCompletedOnFrontendLoop( | 471 void HandleNigoriConfigurationCompletedOnFrontendLoop( |
| 472 syncer::ModelTypeSet failed_configuration_types); | 472 syncer::ModelTypeSet failed_configuration_types); |
| 473 | 473 |
| 474 // syncer::SyncNotifierObserver-like functions. | 474 // syncer::InvalidationHandler-like functions. |
| 475 void HandleNotificationsEnabledOnFrontendLoop(); | 475 void HandleNotificationsEnabledOnFrontendLoop(); |
| 476 void HandleNotificationsDisabledOnFrontendLoop( | 476 void HandleNotificationsDisabledOnFrontendLoop( |
| 477 syncer::NotificationsDisabledReason reason); | 477 syncer::NotificationsDisabledReason reason); |
| 478 void HandleIncomingNotificationOnFrontendLoop( | 478 void HandleIncomingNotificationOnFrontendLoop( |
| 479 const syncer::ObjectIdStateMap& id_state_map, | 479 const syncer::ObjectIdStateMap& id_state_map, |
| 480 syncer::IncomingNotificationSource source); | 480 syncer::IncomingNotificationSource source); |
| 481 | 481 |
| 482 // Handles stopping the core's SyncManager, accounting for whether | 482 // Handles stopping the core's SyncManager, accounting for whether |
| 483 // initialization is done yet. | 483 // initialization is done yet. |
| 484 void StopSyncManagerForShutdown(const base::Closure& closure); | 484 void StopSyncManagerForShutdown(const base::Closure& closure); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 501 scoped_refptr<Core> core_; | 501 scoped_refptr<Core> core_; |
| 502 | 502 |
| 503 InitializationState initialization_state_; | 503 InitializationState initialization_state_; |
| 504 | 504 |
| 505 const base::WeakPtr<SyncPrefs> sync_prefs_; | 505 const base::WeakPtr<SyncPrefs> sync_prefs_; |
| 506 | 506 |
| 507 // A bridge that converts Chrome notifications (on the UI thread) | 507 // A bridge that converts Chrome notifications (on the UI thread) |
| 508 // into invalidations (on the sync thread). | 508 // into invalidations (on the sync thread). |
| 509 scoped_ptr<ChromeSyncNotificationBridge> chrome_sync_notification_bridge_; | 509 scoped_ptr<ChromeSyncNotificationBridge> chrome_sync_notification_bridge_; |
| 510 | 510 |
| 511 syncer::SyncNotifierFactory sync_notifier_factory_; | 511 syncer::InvalidatorFactory invalidator_factory_; |
| 512 | 512 |
| 513 ChromeExtensionsActivityMonitor extensions_activity_monitor_; | 513 ChromeExtensionsActivityMonitor extensions_activity_monitor_; |
| 514 | 514 |
| 515 scoped_ptr<SyncBackendRegistrar> registrar_; | 515 scoped_ptr<SyncBackendRegistrar> registrar_; |
| 516 | 516 |
| 517 // The frontend which we serve (and are owned by). | 517 // The frontend which we serve (and are owned by). |
| 518 SyncFrontend* frontend_; | 518 SyncFrontend* frontend_; |
| 519 | 519 |
| 520 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired | 520 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired |
| 521 // is called. This way, before the UI calls SetDecryptionPassphrase on the | 521 // is called. This way, before the UI calls SetDecryptionPassphrase on the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 541 // it via OnBackendInitialized in the final state of | 541 // it via OnBackendInitialized in the final state of |
| 542 // HandleInitializationCompletedOnFrontendLoop. | 542 // HandleInitializationCompletedOnFrontendLoop. |
| 543 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 543 syncer::WeakHandle<syncer::JsBackend> js_backend_; |
| 544 | 544 |
| 545 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 545 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 546 }; | 546 }; |
| 547 | 547 |
| 548 } // namespace browser_sync | 548 } // namespace browser_sync |
| 549 | 549 |
| 550 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 550 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |