| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ |
| 6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ | 6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.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/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "components/sync/device_info/device_info_tracker.h" | 20 #include "components/sync/device_info/device_info_tracker.h" |
| 21 #include "components/sync/device_info/local_device_info_provider.h" | 21 #include "components/sync/device_info/local_device_info_provider.h" |
| 22 #include "components/sync/model/model_type_service.h" | |
| 23 #include "components/sync/model/model_type_store.h" | 22 #include "components/sync/model/model_type_store.h" |
| 23 #include "components/sync/model/model_type_sync_bridge.h" |
| 24 #include "components/sync/model/simple_metadata_change_list.h" | 24 #include "components/sync/model/simple_metadata_change_list.h" |
| 25 | 25 |
| 26 namespace sync_pb { | 26 namespace sync_pb { |
| 27 class DeviceInfoSpecifics; | 27 class DeviceInfoSpecifics; |
| 28 } // namespace sync_pb | 28 } // namespace sync_pb |
| 29 | 29 |
| 30 namespace syncer { | 30 namespace syncer { |
| 31 | 31 |
| 32 class ModelTypeChangeProcessor; | 32 class ModelTypeChangeProcessor; |
| 33 class SyncError; | 33 class SyncError; |
| 34 | 34 |
| 35 // USS service implementation for DEVICE_INFO model type. Handles storage of | 35 // USS service implementation for DEVICE_INFO model type. Handles storage of |
| 36 // device info and associated sync metadata, applying/merging foreign changes, | 36 // device info and associated sync metadata, applying/merging foreign changes, |
| 37 // and allows public read access. | 37 // and allows public read access. |
| 38 class DeviceInfoService : public ModelTypeService, public DeviceInfoTracker { | 38 class DeviceInfoService : public ModelTypeSyncBridge, public DeviceInfoTracker { |
| 39 public: | 39 public: |
| 40 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)> | 40 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)> |
| 41 StoreFactoryFunction; | 41 StoreFactoryFunction; |
| 42 | 42 |
| 43 DeviceInfoService(LocalDeviceInfoProvider* local_device_info_provider, | 43 DeviceInfoService(LocalDeviceInfoProvider* local_device_info_provider, |
| 44 const StoreFactoryFunction& callback, | 44 const StoreFactoryFunction& callback, |
| 45 const ChangeProcessorFactory& change_processor_factory); | 45 const ChangeProcessorFactory& change_processor_factory); |
| 46 ~DeviceInfoService() override; | 46 ~DeviceInfoService() override; |
| 47 | 47 |
| 48 // ModelTypeService implementation. | 48 // ModelTypeSyncBridge implementation. |
| 49 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; | 49 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; |
| 50 SyncError MergeSyncData( | 50 SyncError MergeSyncData( |
| 51 std::unique_ptr<MetadataChangeList> metadata_change_list, | 51 std::unique_ptr<MetadataChangeList> metadata_change_list, |
| 52 EntityDataMap entity_data_map) override; | 52 EntityDataMap entity_data_map) override; |
| 53 SyncError ApplySyncChanges( | 53 SyncError ApplySyncChanges( |
| 54 std::unique_ptr<MetadataChangeList> metadata_change_list, | 54 std::unique_ptr<MetadataChangeList> metadata_change_list, |
| 55 EntityChangeList entity_changes) override; | 55 EntityChangeList entity_changes) override; |
| 56 void GetData(StorageKeyList storage_keys, DataCallback callback) override; | 56 void GetData(StorageKeyList storage_keys, DataCallback callback) override; |
| 57 void GetAllData(DataCallback callback) override; | 57 void GetAllData(DataCallback callback) override; |
| 58 std::string GetClientTag(const EntityData& entity_data) override; | 58 std::string GetClientTag(const EntityData& entity_data) override; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 // Used to update our local device info once every pulse interval. | 166 // Used to update our local device info once every pulse interval. |
| 167 base::OneShotTimer pulse_timer_; | 167 base::OneShotTimer pulse_timer_; |
| 168 | 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); | 169 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 } // namespace syncer | 172 } // namespace syncer |
| 173 | 173 |
| 174 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ | 174 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ |
| OLD | NEW |