Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // in some intermediate state. Those finer-grained intermediate states | 83 // in some intermediate state. Those finer-grained intermediate states |
| 84 // are differentiated by the DataTypeController state. | 84 // are differentiated by the DataTypeController state. |
| 85 // | 85 // |
| 86 class ProfileSyncService : public browser_sync::SyncFrontend, | 86 class ProfileSyncService : public browser_sync::SyncFrontend, |
| 87 public browser_sync::UnrecoverableErrorHandler, | 87 public browser_sync::UnrecoverableErrorHandler, |
| 88 public BrowserSignin::SigninDelegate, | 88 public BrowserSignin::SigninDelegate, |
| 89 public NotificationObserver { | 89 public NotificationObserver { |
| 90 public: | 90 public: |
| 91 typedef ProfileSyncServiceObserver Observer; | 91 typedef ProfileSyncServiceObserver Observer; |
| 92 typedef browser_sync::SyncBackendHost::Status Status; | 92 typedef browser_sync::SyncBackendHost::Status Status; |
| 93 typedef browser_sync::SyncBackendHost::UserShareHandle UserShareHandle; | |
|
tim (not reviewing)
2011/01/21 18:17:00
ring around the rosie... :(
akalin
2011/01/21 21:21:09
Removed!
| |
| 93 | 94 |
| 94 enum SyncEventCodes { | 95 enum SyncEventCodes { |
| 95 MIN_SYNC_EVENT_CODE = 0, | 96 MIN_SYNC_EVENT_CODE = 0, |
| 96 | 97 |
| 97 // Events starting the sync service. | 98 // Events starting the sync service. |
| 98 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 99 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 99 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 100 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 100 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 101 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
| 101 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. | 102 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
| 102 | 103 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 | 320 |
| 320 // Returns whether sync is managed, i.e. controlled by configuration | 321 // Returns whether sync is managed, i.e. controlled by configuration |
| 321 // management. If so, the user is not allowed to configure sync. | 322 // management. If so, the user is not allowed to configure sync. |
| 322 bool IsManaged(); | 323 bool IsManaged(); |
| 323 | 324 |
| 324 // UnrecoverableErrorHandler implementation. | 325 // UnrecoverableErrorHandler implementation. |
| 325 virtual void OnUnrecoverableError( | 326 virtual void OnUnrecoverableError( |
| 326 const tracked_objects::Location& from_here, | 327 const tracked_objects::Location& from_here, |
| 327 const std::string& message); | 328 const std::string& message); |
| 328 | 329 |
| 329 browser_sync::SyncBackendHost* backend() { return backend_.get(); } | 330 // Should only be called if sync_initialized() is true. |
| 331 UserShareHandle GetUserShareHandle() const; | |
| 332 | |
| 333 // The three functions below, used by | |
| 334 // sync_ui_util::ConstructAboutInformation(), should only be called | |
| 335 // if sync_initialized() is true. | |
| 336 | |
| 337 const browser_sync::sessions::SyncSessionSnapshot* | |
| 338 GetLastSessionSnapshot() const; | |
| 339 | |
| 340 bool HasUnsyncedItems() const; | |
|
tim (not reviewing)
2011/01/21 18:17:00
The comments should probably have moved too
akalin
2011/01/21 21:21:09
Done.
| |
| 341 | |
| 342 void GetModelSafeRoutingInfo(browser_sync::ModelSafeRoutingInfo* out); | |
| 343 | |
| 344 // The autofill migration functions below should only be called if | |
| 345 // sync_initialized() is true. | |
| 346 | |
| 347 syncable::AutofillMigrationState | |
| 348 GetAutofillMigrationState(); | |
| 349 | |
| 350 void SetAutofillMigrationState( | |
| 351 syncable::AutofillMigrationState state); | |
| 352 | |
| 353 syncable::AutofillMigrationDebugInfo | |
| 354 GetAutofillMigrationDebugInfo(); | |
| 355 | |
| 356 void SetAutofillMigrationDebugInfo( | |
| 357 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, | |
| 358 const syncable::AutofillMigrationDebugInfo& info); | |
| 330 | 359 |
| 331 virtual void ActivateDataType( | 360 virtual void ActivateDataType( |
| 332 browser_sync::DataTypeController* data_type_controller, | 361 browser_sync::DataTypeController* data_type_controller, |
| 333 browser_sync::ChangeProcessor* change_processor); | 362 browser_sync::ChangeProcessor* change_processor); |
| 334 virtual void DeactivateDataType( | 363 virtual void DeactivateDataType( |
| 335 browser_sync::DataTypeController* data_type_controller, | 364 browser_sync::DataTypeController* data_type_controller, |
| 336 browser_sync::ChangeProcessor* change_processor); | 365 browser_sync::ChangeProcessor* change_processor); |
| 337 | 366 |
| 338 // NotificationObserver implementation. | 367 // NotificationObserver implementation. |
| 339 virtual void Observe(NotificationType type, | 368 virtual void Observe(NotificationType type, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 const std::string& cros_user() const { return cros_user_; } | 424 const std::string& cros_user() const { return cros_user_; } |
| 396 | 425 |
| 397 protected: | 426 protected: |
| 398 // Used by ProfileSyncServiceMock only. | 427 // Used by ProfileSyncServiceMock only. |
| 399 // | 428 // |
| 400 // TODO(akalin): Separate this class out into an abstract | 429 // TODO(akalin): Separate this class out into an abstract |
| 401 // ProfileSyncService interface and a ProfileSyncServiceImpl class | 430 // ProfileSyncService interface and a ProfileSyncServiceImpl class |
| 402 // so we don't need this hack anymore. | 431 // so we don't need this hack anymore. |
| 403 ProfileSyncService(); | 432 ProfileSyncService(); |
| 404 | 433 |
| 434 // Used by test classes that derive from ProfileSyncService. | |
| 435 browser_sync::SyncBackendHost* GetBackendForTest(); | |
| 436 | |
| 405 // Helper to install and configure a data type manager. | 437 // Helper to install and configure a data type manager. |
| 406 void ConfigureDataTypeManager(); | 438 void ConfigureDataTypeManager(); |
| 407 | 439 |
| 408 // Starts up the backend sync components. | 440 // Starts up the backend sync components. |
| 409 void StartUp(); | 441 void StartUp(); |
| 410 // Shuts down the backend sync components. | 442 // Shuts down the backend sync components. |
| 411 // |sync_disabled| indicates if syncing is being disabled or not. | 443 // |sync_disabled| indicates if syncing is being disabled or not. |
| 412 void Shutdown(bool sync_disabled); | 444 void Shutdown(bool sync_disabled); |
| 413 | 445 |
| 414 // Methods to register and remove preferences. | 446 // Methods to register and remove preferences. |
| 415 void RegisterPreferences(); | 447 void RegisterPreferences(); |
| 416 void ClearPreferences(); | 448 void ClearPreferences(); |
| 417 | 449 |
| 418 // Return SyncCredentials from the TokenService. | 450 // Return SyncCredentials from the TokenService. |
| 419 sync_api::SyncCredentials GetCredentials(); | 451 sync_api::SyncCredentials GetCredentials(); |
| 420 | 452 |
| 421 // Test need to override this to create backends that allow setting up | 453 // Test need to override this to create backends that allow setting up |
| 422 // initial conditions, such as populating sync nodes. | 454 // initial conditions, such as populating sync nodes. |
| 455 // | |
| 456 // TODO(akalin): Figure out a better way to do this. Ideally, we'd | |
| 457 // construct the backend outside this class and pass it in to the | |
| 458 // contructor or Initialize(). | |
| 423 virtual void CreateBackend(); | 459 virtual void CreateBackend(); |
| 424 | 460 |
| 425 const browser_sync::DataTypeController::TypeMap& data_type_controllers() { | 461 const browser_sync::DataTypeController::TypeMap& data_type_controllers() { |
| 426 return data_type_controllers_; | 462 return data_type_controllers_; |
| 427 } | 463 } |
| 428 | 464 |
| 429 // The wizard will try to read the auth state out of the profile sync | 465 // The wizard will try to read the auth state out of the profile sync |
| 430 // service using this member. Captcha and error state are reflected. | 466 // service using this member. Captcha and error state are reflected. |
| 431 GoogleServiceAuthError last_auth_error_; | 467 GoogleServiceAuthError last_auth_error_; |
| 432 | 468 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 447 | 483 |
| 448 // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the | 484 // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the |
| 449 // backend, telling us that it is safe to send a passphrase down ASAP. | 485 // backend, telling us that it is safe to send a passphrase down ASAP. |
| 450 bool observed_passphrase_required_; | 486 bool observed_passphrase_required_; |
| 451 | 487 |
| 452 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it | 488 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
| 453 // was required for decryption? | 489 // was required for decryption? |
| 454 bool passphrase_required_for_decryption_; | 490 bool passphrase_required_for_decryption_; |
| 455 | 491 |
| 456 private: | 492 private: |
| 457 friend class ProfileSyncServiceTest; | |
| 458 friend class ProfileSyncServicePasswordTest; | 493 friend class ProfileSyncServicePasswordTest; |
| 459 friend class ProfileSyncServicePreferenceTest; | 494 friend class TestProfileSyncService; |
| 460 friend class ProfileSyncServiceSessionTest; | |
| 461 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); | 495 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); |
| 462 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, | |
| 463 UnrecoverableErrorSuspendsService); | |
| 464 | 496 |
| 465 // If |delete_sync_data_folder| is true, then this method will delete all | 497 // If |delete_sync_data_folder| is true, then this method will delete all |
| 466 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). | 498 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). |
| 467 void InitializeBackend(bool delete_sync_data_folder); | 499 void InitializeBackend(bool delete_sync_data_folder); |
| 468 | 500 |
| 469 // Initializes the various settings from the command line. | 501 // Initializes the various settings from the command line. |
| 470 void InitSettings(); | 502 void InitSettings(); |
| 471 | 503 |
| 472 // Sets the last synced time to the current time. | 504 // Sets the last synced time to the current time. |
| 473 void UpdateLastSyncedTime(); | 505 void UpdateLastSyncedTime(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 // and is necessary because the nudge sync framework can drop nudges for | 610 // and is necessary because the nudge sync framework can drop nudges for |
| 579 // a wide variety of sync-related conditions (throttling, connections issues, | 611 // a wide variety of sync-related conditions (throttling, connections issues, |
| 580 // syncer paused, etc.). It can only be removed correctly when the framework | 612 // syncer paused, etc.). It can only be removed correctly when the framework |
| 581 // is reworked to allow one-shot commands like clearing server data. | 613 // is reworked to allow one-shot commands like clearing server data. |
| 582 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; | 614 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; |
| 583 | 615 |
| 584 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 616 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 585 }; | 617 }; |
| 586 | 618 |
| 587 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 619 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |