| 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/sync_backend_host.h" | 26 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 27 #include "chrome/browser/sync/invalidation_service.h" |
| 27 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 28 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 28 #include "chrome/browser/sync/profile_sync_service_observer.h" | 29 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 29 #include "chrome/browser/sync/sync_prefs.h" | 30 #include "chrome/browser/sync/sync_prefs.h" |
| 30 #include "chrome/common/net/gaia/google_service_auth_error.h" | 31 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 31 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 34 #include "googleurl/src/gurl.h" | 35 #include "googleurl/src/gurl.h" |
| 35 #include "sync/internal_api/public/base/model_type.h" | 36 #include "sync/internal_api/public/base/model_type.h" |
| 36 #include "sync/internal_api/public/engine/model_safe_worker.h" | 37 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // | 145 // |
| 145 // When initial sync is complete, the UI code should call | 146 // When initial sync is complete, the UI code should call |
| 146 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will | 147 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will |
| 147 // tell the sync engine that setup is completed and it can begin downloading | 148 // tell the sync engine that setup is completed and it can begin downloading |
| 148 // data from the sync server. | 149 // data from the sync server. |
| 149 // | 150 // |
| 150 class ProfileSyncService : public browser_sync::SyncFrontend, | 151 class ProfileSyncService : public browser_sync::SyncFrontend, |
| 151 public browser_sync::SyncPrefObserver, | 152 public browser_sync::SyncPrefObserver, |
| 152 public syncer::UnrecoverableErrorHandler, | 153 public syncer::UnrecoverableErrorHandler, |
| 153 public content::NotificationObserver, | 154 public content::NotificationObserver, |
| 154 public ProfileKeyedService { | 155 public ProfileKeyedService, |
| 156 public InvalidationService { |
| 155 public: | 157 public: |
| 156 typedef ProfileSyncServiceObserver Observer; | 158 typedef ProfileSyncServiceObserver Observer; |
| 157 typedef browser_sync::SyncBackendHost::Status Status; | 159 typedef browser_sync::SyncBackendHost::Status Status; |
| 158 | 160 |
| 159 enum SyncEventCodes { | 161 enum SyncEventCodes { |
| 160 MIN_SYNC_EVENT_CODE = 0, | 162 MIN_SYNC_EVENT_CODE = 0, |
| 161 | 163 |
| 162 // Events starting the sync service. | 164 // Events starting the sync service. |
| 163 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 165 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 164 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 166 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 // pss->UnregisterInvalidationHandler(client_handler); | 580 // pss->UnregisterInvalidationHandler(client_handler); |
| 579 | 581 |
| 580 // NOTE(akalin): Invalidations that come in during browser shutdown may get | 582 // NOTE(akalin): Invalidations that come in during browser shutdown may get |
| 581 // dropped. This won't matter once we have an Acknowledge API, though: see | 583 // dropped. This won't matter once we have an Acknowledge API, though: see |
| 582 // http://crbug.com/78462 and http://crbug.com/124149. | 584 // http://crbug.com/78462 and http://crbug.com/124149. |
| 583 | 585 |
| 584 // Starts sending notifications to |handler|. |handler| must not be NULL, | 586 // Starts sending notifications to |handler|. |handler| must not be NULL, |
| 585 // and it must already be registered. | 587 // and it must already be registered. |
| 586 // | 588 // |
| 587 // Handler registrations are persisted across restarts of sync. | 589 // Handler registrations are persisted across restarts of sync. |
| 588 void RegisterInvalidationHandler(syncer::SyncNotifierObserver* handler); | 590 virtual void RegisterInvalidationHandler( |
| 591 syncer::SyncNotifierObserver* handler) OVERRIDE; |
| 589 | 592 |
| 590 // Updates the set of ObjectIds associated with |handler|. |handler| must | 593 // Updates the set of ObjectIds associated with |handler|. |handler| must |
| 591 // not be NULL, and must already be registered. An ID must be registered for | 594 // not be NULL, and must already be registered. An ID must be registered for |
| 592 // at most one handler. | 595 // at most one handler. |
| 593 // | 596 // |
| 594 // Registered IDs are persisted across restarts of sync. | 597 // Registered IDs are persisted across restarts of sync. |
| 595 void UpdateRegisteredInvalidationIds(syncer::SyncNotifierObserver* handler, | 598 virtual void UpdateRegisteredInvalidationIds( |
| 596 const syncer::ObjectIdSet& ids); | 599 syncer::SyncNotifierObserver* handler, |
| 600 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 597 | 601 |
| 598 // Stops sending notifications to |handler|. |handler| must not be NULL, and | 602 // Stops sending notifications to |handler|. |handler| must not be NULL, and |
| 599 // it must already be registered. Note that this doesn't unregister the IDs | 603 // it must already be registered. Note that this doesn't unregister the IDs |
| 600 // associated with |handler|. | 604 // associated with |handler|. |
| 601 // | 605 // |
| 602 // Handler registrations are persisted across restarts of sync. | 606 // Handler registrations are persisted across restarts of sync. |
| 603 void UnregisterInvalidationHandler(syncer::SyncNotifierObserver* handler); | 607 virtual void UnregisterInvalidationHandler( |
| 608 syncer::SyncNotifierObserver* handler) OVERRIDE; |
| 604 | 609 |
| 605 // ProfileKeyedService implementation. | 610 // ProfileKeyedService implementation. |
| 606 virtual void Shutdown() OVERRIDE; | 611 virtual void Shutdown() OVERRIDE; |
| 607 | 612 |
| 608 protected: | 613 protected: |
| 609 // Used by test classes that derive from ProfileSyncService. | 614 // Used by test classes that derive from ProfileSyncService. |
| 610 virtual browser_sync::SyncBackendHost* GetBackendForTest(); | 615 virtual browser_sync::SyncBackendHost* GetBackendForTest(); |
| 611 | 616 |
| 612 // Helper to install and configure a data type manager. | 617 // Helper to install and configure a data type manager. |
| 613 void ConfigureDataTypeManager(); | 618 void ConfigureDataTypeManager(); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 syncer::SyncNotifierRegistrar notifier_registrar_; | 885 syncer::SyncNotifierRegistrar notifier_registrar_; |
| 881 | 886 |
| 882 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 887 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 883 }; | 888 }; |
| 884 | 889 |
| 885 bool ShouldShowActionOnUI( | 890 bool ShouldShowActionOnUI( |
| 886 const syncer::SyncProtocolError& error); | 891 const syncer::SyncProtocolError& error); |
| 887 | 892 |
| 888 | 893 |
| 889 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 894 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |