Chromium Code Reviews| 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/browser/sync/glue/chrome_sync_notification_bridge.h" | 19 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" |
| 20 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | |
|
Nicolas Zea
2012/07/20 21:35:39
Any reason you're not forward declaring this anymo
rlarocque
2012/07/20 23:20:05
No. Fixed.
| |
| 20 #include "chrome/common/net/gaia/google_service_auth_error.h" | 21 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 22 #include "sync/internal_api/public/base/model_type.h" | 23 #include "sync/internal_api/public/base/model_type.h" |
| 23 #include "sync/internal_api/public/configure_reason.h" | 24 #include "sync/internal_api/public/configure_reason.h" |
| 24 #include "sync/internal_api/public/engine/model_safe_worker.h" | 25 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 25 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 26 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 26 #include "sync/internal_api/public/sync_manager.h" | 27 #include "sync/internal_api/public/sync_manager.h" |
| 27 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 28 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 28 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 29 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 29 #include "sync/internal_api/public/util/weak_handle.h" | 30 #include "sync/internal_api/public/util/weak_handle.h" |
| 30 #include "sync/notifier/sync_notifier_factory.h" | 31 #include "sync/notifier/sync_notifier_factory.h" |
| 31 #include "sync/protocol/encryption.pb.h" | 32 #include "sync/protocol/encryption.pb.h" |
| 32 #include "sync/protocol/sync_protocol_error.h" | 33 #include "sync/protocol/sync_protocol_error.h" |
| 33 | 34 |
| 34 class MessageLoop; | 35 class MessageLoop; |
| 35 class Profile; | 36 class Profile; |
| 36 | 37 |
| 37 namespace syncer { | 38 namespace syncer { |
| 38 class SyncManagerFactory; | 39 class SyncManagerFactory; |
| 39 } | 40 } |
| 40 | 41 |
| 41 namespace browser_sync { | 42 namespace browser_sync { |
| 42 | 43 |
| 43 class ChangeProcessor; | 44 class ChangeProcessor; |
| 44 struct Experiments; | 45 struct Experiments; |
| 45 class InvalidatorStorage; | 46 class InvalidatorStorage; |
| 46 class JsBackend; | |
| 47 class JsEventHandler; | |
| 48 class SyncBackendRegistrar; | |
| 49 class SyncPrefs; | 47 class SyncPrefs; |
| 50 | 48 |
| 51 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 49 // SyncFrontend is the interface used by SyncBackendHost to communicate with |
| 52 // the entity that created it and, presumably, is interested in sync-related | 50 // the entity that created it and, presumably, is interested in sync-related |
| 53 // activity. | 51 // activity. |
| 54 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 52 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread |
| 55 // used to create that SyncBackendHost. | 53 // used to create that SyncBackendHost. |
| 56 class SyncFrontend { | 54 class SyncFrontend { |
| 57 public: | 55 public: |
| 58 SyncFrontend() {} | 56 SyncFrontend() {} |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // Called on |frontend_loop_| to kick off asynchronous initialization. | 161 // Called on |frontend_loop_| to kick off asynchronous initialization. |
| 164 // As a fallback when no cached auth information is available, try to | 162 // As a fallback when no cached auth information is available, try to |
| 165 // bootstrap authentication using |lsid|, if it isn't empty. | 163 // bootstrap authentication using |lsid|, if it isn't empty. |
| 166 // Optionally delete the Sync Data folder (if it's corrupt). | 164 // Optionally delete the Sync Data folder (if it's corrupt). |
| 167 // |report_unrecoverable_error_function| can be NULL. | 165 // |report_unrecoverable_error_function| can be NULL. |
| 168 // Note: |unrecoverable_error_handler| may be invoked from any thread. | 166 // Note: |unrecoverable_error_handler| may be invoked from any thread. |
| 169 void Initialize( | 167 void Initialize( |
| 170 SyncFrontend* frontend, | 168 SyncFrontend* frontend, |
| 171 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 169 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 172 const GURL& service_url, | 170 const GURL& service_url, |
| 173 syncer::ModelTypeSet initial_types, | |
| 174 const syncer::SyncCredentials& credentials, | 171 const syncer::SyncCredentials& credentials, |
| 175 bool delete_sync_data_folder, | 172 bool delete_sync_data_folder, |
| 176 syncer::SyncManagerFactory* sync_manager_factory, | 173 syncer::SyncManagerFactory* sync_manager_factory, |
| 177 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 174 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 178 syncer::ReportUnrecoverableErrorFunction | 175 syncer::ReportUnrecoverableErrorFunction |
| 179 report_unrecoverable_error_function); | 176 report_unrecoverable_error_function); |
| 180 | 177 |
| 181 // Called from |frontend_loop| to update SyncCredentials. | 178 // Called from |frontend_loop| to update SyncCredentials. |
| 182 void UpdateCredentials(const syncer::SyncCredentials& credentials); | 179 void UpdateCredentials(const syncer::SyncCredentials& credentials); |
| 183 | 180 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 syncer::ModelType type, syncer::ModelSafeGroup group, | 240 syncer::ModelType type, syncer::ModelSafeGroup group, |
| 244 ChangeProcessor* change_processor); | 241 ChangeProcessor* change_processor); |
| 245 | 242 |
| 246 // Deactivates change processing for the given data type. | 243 // Deactivates change processing for the given data type. |
| 247 void DeactivateDataType(syncer::ModelType type); | 244 void DeactivateDataType(syncer::ModelType type); |
| 248 | 245 |
| 249 // Called on |frontend_loop_| to obtain a handle to the UserShare needed | 246 // Called on |frontend_loop_| to obtain a handle to the UserShare needed |
| 250 // for creating transactions. | 247 // for creating transactions. |
| 251 syncer::UserShare* GetUserShare() const; | 248 syncer::UserShare* GetUserShare() const; |
| 252 | 249 |
| 250 // Same as the above function, but bypasses a few sanity checks. | |
| 251 syncer::UserShare* GetUserShareForTest() const; | |
| 252 | |
| 253 // Called from any thread to obtain current status information in detailed or | 253 // Called from any thread to obtain current status information in detailed or |
| 254 // summarized form. | 254 // summarized form. |
| 255 Status GetDetailedStatus(); | 255 Status GetDetailedStatus(); |
| 256 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; | 256 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; |
| 257 | 257 |
| 258 // Determines if the underlying sync engine has made any local changes to | 258 // Determines if the underlying sync engine has made any local changes to |
| 259 // items that have not yet been synced with the server. | 259 // items that have not yet been synced with the server. |
| 260 // ONLY CALL THIS IF OnInitializationComplete was called! | 260 // ONLY CALL THIS IF OnInitializationComplete was called! |
| 261 bool HasUnsyncedItems() const; | 261 bool HasUnsyncedItems() const; |
| 262 | 262 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 const syncer::ModelSafeRoutingInfo& routing_info, | 338 const syncer::ModelSafeRoutingInfo& routing_info, |
| 339 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 339 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
| 340 const base::Closure& retry_callback); | 340 const base::Closure& retry_callback); |
| 341 | 341 |
| 342 // Called when the syncer has finished performing a configuration. | 342 // Called when the syncer has finished performing a configuration. |
| 343 void FinishConfigureDataTypesOnFrontendLoop( | 343 void FinishConfigureDataTypesOnFrontendLoop( |
| 344 const syncer::ModelTypeSet types_to_configure, | 344 const syncer::ModelTypeSet types_to_configure, |
| 345 const syncer::ModelTypeSet configured_types, | 345 const syncer::ModelTypeSet configured_types, |
| 346 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); | 346 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); |
| 347 | 347 |
| 348 // Called when the SyncManager has been constructed and initialized. | |
| 349 virtual void HandleSyncManagerInitializationOnFrontendLoop( | |
| 350 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, | |
| 351 syncer::ModelTypeSet restored_types); | |
| 352 | |
| 348 private: | 353 private: |
| 349 // The real guts of SyncBackendHost, to keep the public client API clean. | 354 // The real guts of SyncBackendHost, to keep the public client API clean. |
| 350 class Core; | 355 class Core; |
| 351 | 356 |
| 352 // An enum representing the steps to initializing the SyncBackendHost. | 357 // An enum representing the steps to initializing the SyncBackendHost. |
| 353 enum InitializationState { | 358 enum InitializationState { |
| 354 NOT_ATTEMPTED, | 359 NOT_ATTEMPTED, |
| 355 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the | 360 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the |
| 356 // sync thread to inform us that the sync manager | 361 // sync thread to inform us that the sync manager |
| 357 // has been created. | 362 // has been created. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 | 507 |
| 503 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 508 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
| 504 syncer::sessions::SyncSessionSnapshot last_snapshot_; | 509 syncer::sessions::SyncSessionSnapshot last_snapshot_; |
| 505 | 510 |
| 506 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 511 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 507 }; | 512 }; |
| 508 | 513 |
| 509 } // namespace browser_sync | 514 } // namespace browser_sync |
| 510 | 515 |
| 511 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 516 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |