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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 namespace syncer { | 36 namespace syncer { |
37 class SyncManagerFactory; | 37 class SyncManagerFactory; |
38 } | 38 } |
39 | 39 |
40 namespace browser_sync { | 40 namespace browser_sync { |
41 | 41 |
42 class ChangeProcessor; | 42 class ChangeProcessor; |
43 class ChromeSyncNotificationBridge; | 43 class ChromeSyncNotificationBridge; |
44 struct Experiments; | 44 struct Experiments; |
45 class InvalidatorStorage; | 45 class InvalidatorStorage; |
46 class JsBackend; | |
47 class JsEventHandler; | |
48 class SyncBackendRegistrar; | 46 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: |
(...skipping 105 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // be called synchronously with the data type's model association so | 236 // be called synchronously with the data type's model association so |
240 // no changes are dropped between model association and change | 237 // no changes are dropped between model association and change |
241 // processor activation. | 238 // processor activation. |
242 void ActivateDataType( | 239 void ActivateDataType( |
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 for |
250 // for creating transactions. | 247 // creating transactions. Should not be called before we signal |
| 248 // initialization is complete with OnBackendInitialized(). |
251 syncer::UserShare* GetUserShare() const; | 249 syncer::UserShare* GetUserShare() const; |
252 | 250 |
253 // Called from any thread to obtain current status information in detailed or | 251 // Called from any thread to obtain current status information in detailed or |
254 // summarized form. | 252 // summarized form. |
255 Status GetDetailedStatus(); | 253 Status GetDetailedStatus(); |
256 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; | 254 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const; |
257 | 255 |
258 // Determines if the underlying sync engine has made any local changes to | 256 // Determines if the underlying sync engine has made any local changes to |
259 // items that have not yet been synced with the server. | 257 // items that have not yet been synced with the server. |
260 // ONLY CALL THIS IF OnInitializationComplete was called! | 258 // ONLY CALL THIS IF OnInitializationComplete was called! |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 syncer::ModelTypeSet types_to_config, | 335 syncer::ModelTypeSet types_to_config, |
338 const syncer::ModelSafeRoutingInfo& routing_info, | 336 const syncer::ModelSafeRoutingInfo& routing_info, |
339 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 337 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
340 const base::Closure& retry_callback); | 338 const base::Closure& retry_callback); |
341 | 339 |
342 // Called when the syncer has finished performing a configuration. | 340 // Called when the syncer has finished performing a configuration. |
343 void FinishConfigureDataTypesOnFrontendLoop( | 341 void FinishConfigureDataTypesOnFrontendLoop( |
344 const syncer::ModelTypeSet failed_configuration_types, | 342 const syncer::ModelTypeSet failed_configuration_types, |
345 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); | 343 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); |
346 | 344 |
| 345 // Called when the SyncManager has been constructed and initialized. |
| 346 virtual void HandleSyncManagerInitializationOnFrontendLoop( |
| 347 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, |
| 348 syncer::ModelTypeSet restored_types); |
| 349 |
347 private: | 350 private: |
348 // The real guts of SyncBackendHost, to keep the public client API clean. | 351 // The real guts of SyncBackendHost, to keep the public client API clean. |
349 class Core; | 352 class Core; |
350 | 353 |
351 // An enum representing the steps to initializing the SyncBackendHost. | 354 // An enum representing the steps to initializing the SyncBackendHost. |
352 enum InitializationState { | 355 enum InitializationState { |
353 NOT_ATTEMPTED, | 356 NOT_ATTEMPTED, |
354 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the | 357 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the |
355 // sync thread to inform us that the sync manager | 358 // sync thread to inform us that the sync manager |
356 // has been created. | 359 // has been created. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 504 |
502 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 505 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
503 syncer::sessions::SyncSessionSnapshot last_snapshot_; | 506 syncer::sessions::SyncSessionSnapshot last_snapshot_; |
504 | 507 |
505 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 508 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
506 }; | 509 }; |
507 | 510 |
508 } // namespace browser_sync | 511 } // namespace browser_sync |
509 | 512 |
510 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 513 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |