| 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_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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "base/timer.h" | 20 #include "base/timer.h" |
| 21 #include "chrome/browser/profiles/profile_keyed_service.h" | 21 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 22 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" | 22 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" |
| 23 #include "chrome/browser/sync/failed_datatypes_handler.h" | 23 #include "chrome/browser/sync/failed_datatypes_handler.h" |
| 24 #include "chrome/browser/sync/glue/data_type_controller.h" | 24 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 25 #include "chrome/browser/sync/glue/data_type_manager.h" | 25 #include "chrome/browser/sync/glue/data_type_manager.h" |
| 26 #include "chrome/browser/sync/glue/data_type_manager_observer.h" | 26 #include "chrome/browser/sync/glue/data_type_manager_observer.h" |
| 27 #include "chrome/browser/sync/glue/sync_backend_host.h" | 27 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 28 #include "chrome/browser/sync/invalidation_frontend.h" |
| 28 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 29 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 29 #include "chrome/browser/sync/profile_sync_service_observer.h" | 30 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 30 #include "chrome/browser/sync/sync_prefs.h" | 31 #include "chrome/browser/sync/sync_prefs.h" |
| 31 #include "chrome/common/net/gaia/google_service_auth_error.h" | 32 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 32 #include "content/public/browser/notification_observer.h" | 33 #include "content/public/browser/notification_observer.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
| 34 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
| 35 #include "googleurl/src/gurl.h" | 36 #include "googleurl/src/gurl.h" |
| 36 #include "sync/internal_api/public/base/model_type.h" | 37 #include "sync/internal_api/public/base/model_type.h" |
| 37 #include "sync/internal_api/public/engine/model_safe_worker.h" | 38 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // When initial sync is complete, the UI code should call | 147 // When initial sync is complete, the UI code should call |
| 147 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will | 148 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will |
| 148 // tell the sync engine that setup is completed and it can begin downloading | 149 // tell the sync engine that setup is completed and it can begin downloading |
| 149 // data from the sync server. | 150 // data from the sync server. |
| 150 // | 151 // |
| 151 class ProfileSyncService : public browser_sync::SyncFrontend, | 152 class ProfileSyncService : public browser_sync::SyncFrontend, |
| 152 public browser_sync::SyncPrefObserver, | 153 public browser_sync::SyncPrefObserver, |
| 153 public browser_sync::DataTypeManagerObserver, | 154 public browser_sync::DataTypeManagerObserver, |
| 154 public syncer::UnrecoverableErrorHandler, | 155 public syncer::UnrecoverableErrorHandler, |
| 155 public content::NotificationObserver, | 156 public content::NotificationObserver, |
| 156 public ProfileKeyedService { | 157 public ProfileKeyedService, |
| 158 public InvalidationFrontend { |
| 157 public: | 159 public: |
| 158 typedef ProfileSyncServiceObserver Observer; | 160 typedef ProfileSyncServiceObserver Observer; |
| 159 typedef browser_sync::SyncBackendHost::Status Status; | 161 typedef browser_sync::SyncBackendHost::Status Status; |
| 160 | 162 |
| 161 enum SyncEventCodes { | 163 enum SyncEventCodes { |
| 162 MIN_SYNC_EVENT_CODE = 0, | 164 MIN_SYNC_EVENT_CODE = 0, |
| 163 | 165 |
| 164 // Events starting the sync service. | 166 // Events starting the sync service. |
| 165 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 167 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 166 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 168 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 // pss->UnregisterInvalidationHandler(client_handler); | 589 // pss->UnregisterInvalidationHandler(client_handler); |
| 588 | 590 |
| 589 // NOTE(akalin): Invalidations that come in during browser shutdown may get | 591 // NOTE(akalin): Invalidations that come in during browser shutdown may get |
| 590 // dropped. This won't matter once we have an Acknowledge API, though: see | 592 // dropped. This won't matter once we have an Acknowledge API, though: see |
| 591 // http://crbug.com/78462 and http://crbug.com/124149. | 593 // http://crbug.com/78462 and http://crbug.com/124149. |
| 592 | 594 |
| 593 // Starts sending notifications to |handler|. |handler| must not be NULL, | 595 // Starts sending notifications to |handler|. |handler| must not be NULL, |
| 594 // and it must already be registered. | 596 // and it must already be registered. |
| 595 // | 597 // |
| 596 // Handler registrations are persisted across restarts of sync. | 598 // Handler registrations are persisted across restarts of sync. |
| 597 void RegisterInvalidationHandler(syncer::SyncNotifierObserver* handler); | 599 virtual void RegisterInvalidationHandler( |
| 600 syncer::SyncNotifierObserver* handler) OVERRIDE; |
| 598 | 601 |
| 599 // Updates the set of ObjectIds associated with |handler|. |handler| must | 602 // Updates the set of ObjectIds associated with |handler|. |handler| must |
| 600 // not be NULL, and must already be registered. An ID must be registered for | 603 // not be NULL, and must already be registered. An ID must be registered for |
| 601 // at most one handler. | 604 // at most one handler. |
| 602 // | 605 // |
| 603 // Registered IDs are persisted across restarts of sync. | 606 // Registered IDs are persisted across restarts of sync. |
| 604 void UpdateRegisteredInvalidationIds(syncer::SyncNotifierObserver* handler, | 607 virtual void UpdateRegisteredInvalidationIds( |
| 605 const syncer::ObjectIdSet& ids); | 608 syncer::SyncNotifierObserver* handler, |
| 609 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 606 | 610 |
| 607 // Stops sending notifications to |handler|. |handler| must not be NULL, and | 611 // Stops sending notifications to |handler|. |handler| must not be NULL, and |
| 608 // it must already be registered. Note that this doesn't unregister the IDs | 612 // it must already be registered. Note that this doesn't unregister the IDs |
| 609 // associated with |handler|. | 613 // associated with |handler|. |
| 610 // | 614 // |
| 611 // Handler registrations are persisted across restarts of sync. | 615 // Handler registrations are persisted across restarts of sync. |
| 612 void UnregisterInvalidationHandler(syncer::SyncNotifierObserver* handler); | 616 virtual void UnregisterInvalidationHandler( |
| 617 syncer::SyncNotifierObserver* handler) OVERRIDE; |
| 613 | 618 |
| 614 // ProfileKeyedService implementation. | 619 // ProfileKeyedService implementation. |
| 615 virtual void Shutdown() OVERRIDE; | 620 virtual void Shutdown() OVERRIDE; |
| 616 | 621 |
| 617 protected: | 622 protected: |
| 618 // Used by test classes that derive from ProfileSyncService. | 623 // Used by test classes that derive from ProfileSyncService. |
| 619 virtual browser_sync::SyncBackendHost* GetBackendForTest(); | 624 virtual browser_sync::SyncBackendHost* GetBackendForTest(); |
| 620 | 625 |
| 621 // Helper to install and configure a data type manager. | 626 // Helper to install and configure a data type manager. |
| 622 void ConfigureDataTypeManager(); | 627 void ConfigureDataTypeManager(); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 syncer::SyncNotifierRegistrar notifier_registrar_; | 894 syncer::SyncNotifierRegistrar notifier_registrar_; |
| 890 | 895 |
| 891 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 896 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 892 }; | 897 }; |
| 893 | 898 |
| 894 bool ShouldShowActionOnUI( | 899 bool ShouldShowActionOnUI( |
| 895 const syncer::SyncProtocolError& error); | 900 const syncer::SyncProtocolError& error); |
| 896 | 901 |
| 897 | 902 |
| 898 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 903 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |