Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Side by Side Diff: components/sync/device_info/device_info_sync_bridge.h

Issue 2460903003: [Sync] Rename DeviceInfoService to DeviceInfoSyncBridge. (Closed)
Patch Set: Removed 'USS' from a comment. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SYNC_BRIDGE_H_
6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ 6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_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_store.h" 22 #include "components/sync/model/model_type_store.h"
23 #include "components/sync/model/model_type_sync_bridge.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 // Sync bridge 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 ModelTypeSyncBridge, public DeviceInfoTracker { 38 class DeviceInfoSyncBridge : public ModelTypeSyncBridge,
39 public DeviceInfoTracker {
39 public: 40 public:
40 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)> 41 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)>
41 StoreFactoryFunction; 42 StoreFactoryFunction;
42 43
43 DeviceInfoService(LocalDeviceInfoProvider* local_device_info_provider, 44 DeviceInfoSyncBridge(LocalDeviceInfoProvider* local_device_info_provider,
44 const StoreFactoryFunction& callback, 45 const StoreFactoryFunction& callback,
45 const ChangeProcessorFactory& change_processor_factory); 46 const ChangeProcessorFactory& change_processor_factory);
46 ~DeviceInfoService() override; 47 ~DeviceInfoSyncBridge() override;
47 48
48 // ModelTypeSyncBridge implementation. 49 // ModelTypeSyncBridge implementation.
49 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; 50 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override;
50 SyncError MergeSyncData( 51 SyncError MergeSyncData(
51 std::unique_ptr<MetadataChangeList> metadata_change_list, 52 std::unique_ptr<MetadataChangeList> metadata_change_list,
52 EntityDataMap entity_data_map) override; 53 EntityDataMap entity_data_map) override;
53 SyncError ApplySyncChanges( 54 SyncError ApplySyncChanges(
54 std::unique_ptr<MetadataChangeList> metadata_change_list, 55 std::unique_ptr<MetadataChangeList> metadata_change_list,
55 EntityChangeList entity_changes) override; 56 EntityChangeList entity_changes) override;
56 void GetData(StorageKeyList storage_keys, DataCallback callback) override; 57 void GetData(StorageKeyList storage_keys, DataCallback callback) override;
57 void GetAllData(DataCallback callback) override; 58 void GetAllData(DataCallback callback) override;
58 std::string GetClientTag(const EntityData& entity_data) override; 59 std::string GetClientTag(const EntityData& entity_data) override;
59 std::string GetStorageKey(const EntityData& entity_data) override; 60 std::string GetStorageKey(const EntityData& entity_data) override;
60 void DisableSync() override; 61 void DisableSync() override;
61 62
62 // DeviceInfoTracker implementation. 63 // DeviceInfoTracker implementation.
63 bool IsSyncing() const override; 64 bool IsSyncing() const override;
64 std::unique_ptr<DeviceInfo> GetDeviceInfo( 65 std::unique_ptr<DeviceInfo> GetDeviceInfo(
65 const std::string& client_id) const override; 66 const std::string& client_id) const override;
66 std::vector<std::unique_ptr<DeviceInfo>> GetAllDeviceInfo() const override; 67 std::vector<std::unique_ptr<DeviceInfo>> GetAllDeviceInfo() const override;
67 void AddObserver(Observer* observer) override; 68 void AddObserver(Observer* observer) override;
68 void RemoveObserver(Observer* observer) override; 69 void RemoveObserver(Observer* observer) override;
69 int CountActiveDevices() const override; 70 int CountActiveDevices() const override;
70 71
71 private: 72 private:
72 friend class DeviceInfoServiceTest; 73 friend class DeviceInfoSyncBridgeTest;
73 74
74 // Cache of all syncable and local data, stored by device cache guid. 75 // Cache of all syncable and local data, stored by device cache guid.
75 using ClientIdToSpecifics = 76 using ClientIdToSpecifics =
76 std::map<std::string, std::unique_ptr<sync_pb::DeviceInfoSpecifics>>; 77 std::map<std::string, std::unique_ptr<sync_pb::DeviceInfoSpecifics>>;
77 78
78 // Store SyncData in the cache and durable storage. 79 // Store SyncData in the cache and durable storage.
79 void StoreSpecifics(std::unique_ptr<sync_pb::DeviceInfoSpecifics> specifics, 80 void StoreSpecifics(std::unique_ptr<sync_pb::DeviceInfoSpecifics> specifics,
80 ModelTypeStore::WriteBatch* batch); 81 ModelTypeStore::WriteBatch* batch);
81 // Delete SyncData from the cache and durable storage, returns true if there 82 // Delete SyncData from the cache and durable storage, returns true if there
82 // was actually anything at the given tag. 83 // was actually anything at the given tag.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 std::unique_ptr<ModelTypeStore> store_; 146 std::unique_ptr<ModelTypeStore> store_;
146 147
147 // If |local_device_info_provider_| has initialized. 148 // If |local_device_info_provider_| has initialized.
148 bool has_provider_initialized_ = false; 149 bool has_provider_initialized_ = false;
149 // If data has been loaded from the store. 150 // If data has been loaded from the store.
150 bool has_data_loaded_ = false; 151 bool has_data_loaded_ = false;
151 152
152 // Used to update our local device info once every pulse interval. 153 // Used to update our local device info once every pulse interval.
153 base::OneShotTimer pulse_timer_; 154 base::OneShotTimer pulse_timer_;
154 155
155 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); 156 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge);
156 }; 157 };
157 158
158 } // namespace syncer 159 } // namespace syncer
159 160
160 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ 161 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698