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 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; | |
47 class InvalidatorStorage; | 46 class InvalidatorStorage; |
48 class SyncBackendRegistrar; | 47 class SyncBackendRegistrar; |
49 class SyncPrefs; | 48 class SyncPrefs; |
| 49 class SyncedDeviceTracker; |
| 50 struct Experiments; |
50 | 51 |
51 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 52 // SyncFrontend is the interface used by SyncBackendHost to communicate with |
52 // the entity that created it and, presumably, is interested in sync-related | 53 // the entity that created it and, presumably, is interested in sync-related |
53 // activity. | 54 // activity. |
54 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 55 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread |
55 // used to create that SyncBackendHost. | 56 // used to create that SyncBackendHost. |
56 class SyncFrontend : public syncer::InvalidationHandler { | 57 class SyncFrontend : public syncer::InvalidationHandler { |
57 public: | 58 public: |
58 SyncFrontend() {} | 59 SyncFrontend() {} |
59 | 60 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // passphrase was set (if available). | 278 // passphrase was set (if available). |
278 base::Time GetExplicitPassphraseTime() const; | 279 base::Time GetExplicitPassphraseTime() const; |
279 | 280 |
280 // True if the cryptographer has any keys available to attempt decryption. | 281 // True if the cryptographer has any keys available to attempt decryption. |
281 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped | 282 // Could mean we've downloaded and loaded Nigori objects, or we bootstrapped |
282 // using a token previously received. | 283 // using a token previously received. |
283 bool IsCryptographerReady(const syncer::BaseTransaction* trans) const; | 284 bool IsCryptographerReady(const syncer::BaseTransaction* trans) const; |
284 | 285 |
285 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; | 286 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; |
286 | 287 |
| 288 // Fetches the DeviceInfo ChangeProcessor. |
| 289 // We'll keep this test-only until we have non-test clients. |
| 290 virtual SyncedDeviceTracker* GetSyncedDeviceTrackerForTest(); |
| 291 |
287 protected: | 292 protected: |
288 // The types and functions below are protected so that test | 293 // The types and functions below are protected so that test |
289 // subclasses can use them. | 294 // subclasses can use them. |
290 // | 295 // |
291 // TODO(akalin): Figure out a better way for tests to hook into | 296 // TODO(akalin): Figure out a better way for tests to hook into |
292 // SyncBackendHost. | 297 // SyncBackendHost. |
293 | 298 |
294 typedef base::Callback<scoped_ptr<syncer::HttpPostProviderFactory>(void)> | 299 typedef base::Callback<scoped_ptr<syncer::HttpPostProviderFactory>(void)> |
295 MakeHttpBridgeFactoryFn; | 300 MakeHttpBridgeFactoryFn; |
296 | 301 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 372 |
368 SyncFrontend* frontend() { return frontend_; } | 373 SyncFrontend* frontend() { return frontend_; } |
369 | 374 |
370 private: | 375 private: |
371 // The real guts of SyncBackendHost, to keep the public client API clean. | 376 // The real guts of SyncBackendHost, to keep the public client API clean. |
372 class Core; | 377 class Core; |
373 | 378 |
374 // An enum representing the steps to initializing the SyncBackendHost. | 379 // An enum representing the steps to initializing the SyncBackendHost. |
375 enum InitializationState { | 380 enum InitializationState { |
376 NOT_ATTEMPTED, | 381 NOT_ATTEMPTED, |
377 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the | 382 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the |
378 // sync thread to inform us that the sync manager | 383 // sync thread to inform us that the sync |
379 // has been created. | 384 // manager has been created. |
380 NOT_INITIALIZED, // Initialization hasn't completed, but we've | 385 NOT_INITIALIZED, // Initialization hasn't completed, but we've |
381 // constructed a SyncManager. | 386 // constructed a SyncManager. |
382 DOWNLOADING_NIGORI, // The SyncManager is initialized, but | 387 DOWNLOADING_CONTROL_TYPES, // The SyncManager is initialized, but |
383 // we're fetching sync encryption information. | 388 // we're fetching metadata, such as encryption |
384 ASSOCIATING_NIGORI, // The SyncManager is initialized, and we | 389 // information, from the server. |
385 // have the sync encryption information, but we | 390 PROCESSING_CONTROL_TYPES, // Running init tasks that require metadata to |
386 // have to update the local encryption state. | 391 // be available. This includes registering our |
387 INITIALIZED, // Initialization is complete. | 392 // device information and refreshing encryption. |
| 393 INITIALIZED, // Initialization is complete. |
388 }; | 394 }; |
389 | 395 |
390 // Checks if we have received a notice to turn on experimental datatypes | 396 // Checks if we have received a notice to turn on experimental datatypes |
391 // (via the nigori node) and informs the frontend if that is the case. | 397 // (via the nigori node) and informs the frontend if that is the case. |
392 // Note: it is illegal to call this before the backend is initialized. | 398 // Note: it is illegal to call this before the backend is initialized. |
393 void AddExperimentalTypes(); | 399 void AddExperimentalTypes(); |
394 | 400 |
395 // Downloading of nigori failed and will be retried. | 401 // Downloading of nigori failed and will be retried. |
396 void OnNigoriDownloadRetry(); | 402 void OnNigoriDownloadRetry(); |
397 | 403 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void HandleInvalidatorStateChangeOnFrontendLoop( | 488 void HandleInvalidatorStateChangeOnFrontendLoop( |
483 syncer::InvalidatorState state); | 489 syncer::InvalidatorState state); |
484 void HandleIncomingInvalidationOnFrontendLoop( | 490 void HandleIncomingInvalidationOnFrontendLoop( |
485 const syncer::ObjectIdInvalidationMap& invalidation_map, | 491 const syncer::ObjectIdInvalidationMap& invalidation_map, |
486 syncer::IncomingInvalidationSource source); | 492 syncer::IncomingInvalidationSource source); |
487 | 493 |
488 // Handles stopping the core's SyncManager, accounting for whether | 494 // Handles stopping the core's SyncManager, accounting for whether |
489 // initialization is done yet. | 495 // initialization is done yet. |
490 void StopSyncManagerForShutdown(const base::Closure& closure); | 496 void StopSyncManagerForShutdown(const base::Closure& closure); |
491 | 497 |
| 498 // Must be called on |frontend_loop_|. |done_callback| is called on |
| 499 // |frontend_loop_|. |
| 500 void InitialProcessControlTypes(const base::Closure& done_callback); |
| 501 |
492 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; | 502 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; |
493 | 503 |
494 // A thread where all the sync operations happen. | 504 // A thread where all the sync operations happen. |
495 base::Thread sync_thread_; | 505 base::Thread sync_thread_; |
496 | 506 |
497 // A reference to the MessageLoop used to construct |this|, so we know how | 507 // A reference to the MessageLoop used to construct |this|, so we know how |
498 // to safely talk back to the SyncFrontend. | 508 // to safely talk back to the SyncFrontend. |
499 MessageLoop* const frontend_loop_; | 509 MessageLoop* const frontend_loop_; |
500 | 510 |
501 Profile* const profile_; | 511 Profile* const profile_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // HandleInitializationCompletedOnFrontendLoop. | 562 // HandleInitializationCompletedOnFrontendLoop. |
553 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 563 syncer::WeakHandle<syncer::JsBackend> js_backend_; |
554 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 564 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
555 | 565 |
556 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 566 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
557 }; | 567 }; |
558 | 568 |
559 } // namespace browser_sync | 569 } // namespace browser_sync |
560 | 570 |
561 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 571 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |