| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "components/sync_driver/device_info_tracker.h" | 9 #include "components/sync_driver/device_info_tracker.h" |
| 10 #include "sync/api/sync_change_processor.h" | 10 #include "sync/api/sync_change_processor.h" |
| 11 #include "sync/api/sync_data.h" | 11 #include "sync/api/sync_data.h" |
| 12 #include "sync/api/sync_error_factory.h" | 12 #include "sync/api/sync_error_factory.h" |
| 13 #include "sync/api/syncable_service.h" | 13 #include "sync/api/syncable_service.h" |
| 14 | 14 |
| 15 namespace sync_driver { | 15 namespace sync_driver { |
| 16 | 16 |
| 17 class LocalDeviceInfoProvider; | 17 class LocalDeviceInfoProvider; |
| 18 | 18 |
| 19 // SyncableService implementation for DEVICE_INFO model type. | 19 // SyncableService implementation for DEVICE_INFO model type. |
| 20 class DeviceInfoSyncService : public syncer::SyncableService, | 20 class DeviceInfoSyncService : public syncer::SyncableService, |
| 21 public DeviceInfoTracker { | 21 public DeviceInfoTracker { |
| 22 public: | 22 public: |
| 23 explicit DeviceInfoSyncService( | 23 explicit DeviceInfoSyncService( |
| 24 LocalDeviceInfoProvider* local_device_info_provider); | 24 LocalDeviceInfoProvider* local_device_info_provider); |
| 25 virtual ~DeviceInfoSyncService(); | 25 ~DeviceInfoSyncService() override; |
| 26 | 26 |
| 27 // syncer::SyncableService implementation. | 27 // syncer::SyncableService implementation. |
| 28 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 28 syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 29 syncer::ModelType type, | 29 syncer::ModelType type, |
| 30 const syncer::SyncDataList& initial_sync_data, | 30 const syncer::SyncDataList& initial_sync_data, |
| 31 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 31 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 32 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; | 32 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; |
| 33 virtual void StopSyncing(syncer::ModelType type) override; | 33 void StopSyncing(syncer::ModelType type) override; |
| 34 virtual syncer::SyncDataList GetAllSyncData( | 34 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; |
| 35 syncer::ModelType type) const override; | 35 syncer::SyncError ProcessSyncChanges( |
| 36 virtual syncer::SyncError ProcessSyncChanges( | |
| 37 const tracked_objects::Location& from_here, | 36 const tracked_objects::Location& from_here, |
| 38 const syncer::SyncChangeList& change_list) override; | 37 const syncer::SyncChangeList& change_list) override; |
| 39 | 38 |
| 40 // DeviceInfoTracker implementation. | 39 // DeviceInfoTracker implementation. |
| 41 virtual scoped_ptr<DeviceInfo> GetDeviceInfo( | 40 scoped_ptr<DeviceInfo> GetDeviceInfo( |
| 42 const std::string& client_id) const override; | 41 const std::string& client_id) const override; |
| 43 virtual ScopedVector<DeviceInfo> GetAllDeviceInfo() const override; | 42 ScopedVector<DeviceInfo> GetAllDeviceInfo() const override; |
| 44 virtual void AddObserver(Observer* observer) override; | 43 void AddObserver(Observer* observer) override; |
| 45 virtual void RemoveObserver(Observer* observer) override; | 44 void RemoveObserver(Observer* observer) override; |
| 46 | 45 |
| 47 // Called to update local device backup time. | 46 // Called to update local device backup time. |
| 48 void UpdateLocalDeviceBackupTime(base::Time backup_time); | 47 void UpdateLocalDeviceBackupTime(base::Time backup_time); |
| 49 // Gets the most recently set local device backup time. | 48 // Gets the most recently set local device backup time. |
| 50 base::Time GetLocalDeviceBackupTime() const; | 49 base::Time GetLocalDeviceBackupTime() const; |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 // Create SyncData from local DeviceInfo and |local_device_backup_time_|. | 52 // Create SyncData from local DeviceInfo and |local_device_backup_time_|. |
| 54 syncer::SyncData CreateLocalData(const DeviceInfo* info); | 53 syncer::SyncData CreateLocalData(const DeviceInfo* info); |
| 55 // Create SyncData from EntitySpecifics. | 54 // Create SyncData from EntitySpecifics. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 98 |
| 100 // Registered observers, not owned. | 99 // Registered observers, not owned. |
| 101 ObserverList<Observer, true> observers_; | 100 ObserverList<Observer, true> observers_; |
| 102 | 101 |
| 103 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService); | 102 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService); |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 } // namespace sync_driver | 105 } // namespace sync_driver |
| 107 | 106 |
| 108 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ | 107 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ |
| OLD | NEW |