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

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

Issue 2460903003: [Sync] Rename DeviceInfoService to DeviceInfoSyncBridge. (Closed)
Patch Set: Updating nullptr to null in 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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "components/sync/device_info/device_info_tracker.h" 18 #include "components/sync/device_info/device_info_tracker.h"
19 #include "components/sync/device_info/local_device_info_provider.h" 19 #include "components/sync/device_info/local_device_info_provider.h"
20 #include "components/sync/model/model_type_store.h" 20 #include "components/sync/model/model_type_store.h"
21 #include "components/sync/model/model_type_sync_bridge.h" 21 #include "components/sync/model/model_type_sync_bridge.h"
22 #include "components/sync/model/simple_metadata_change_list.h" 22 #include "components/sync/model/simple_metadata_change_list.h"
23 23
24 namespace sync_pb { 24 namespace sync_pb {
25 class DeviceInfoSpecifics; 25 class DeviceInfoSpecifics;
26 } // namespace sync_pb 26 } // namespace sync_pb
27 27
28 namespace syncer { 28 namespace syncer {
29 29
30 class ModelTypeChangeProcessor; 30 class ModelTypeChangeProcessor;
31 class SyncError; 31 class SyncError;
32 32
33 // USS service implementation for DEVICE_INFO model type. Handles storage of 33 // Sync bridge implementation for DEVICE_INFO model type. Handles storage of
34 // device info and associated sync metadata, applying/merging foreign changes, 34 // device info and associated sync metadata, applying/merging foreign changes,
35 // and allows public read access. 35 // and allows public read access.
36 class DeviceInfoService : public ModelTypeSyncBridge, public DeviceInfoTracker { 36 class DeviceInfoSyncBridge : public ModelTypeSyncBridge,
37 public DeviceInfoTracker {
37 public: 38 public:
38 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)> 39 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)>
39 StoreFactoryFunction; 40 StoreFactoryFunction;
40 41
41 DeviceInfoService(LocalDeviceInfoProvider* local_device_info_provider, 42 DeviceInfoSyncBridge(LocalDeviceInfoProvider* local_device_info_provider,
42 const StoreFactoryFunction& callback, 43 const StoreFactoryFunction& callback,
43 const ChangeProcessorFactory& change_processor_factory); 44 const ChangeProcessorFactory& change_processor_factory);
44 ~DeviceInfoService() override; 45 ~DeviceInfoSyncBridge() override;
45 46
46 // ModelTypeSyncBridge implementation. 47 // ModelTypeSyncBridge implementation.
47 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; 48 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override;
48 SyncError MergeSyncData( 49 SyncError MergeSyncData(
49 std::unique_ptr<MetadataChangeList> metadata_change_list, 50 std::unique_ptr<MetadataChangeList> metadata_change_list,
50 EntityDataMap entity_data_map) override; 51 EntityDataMap entity_data_map) override;
51 SyncError ApplySyncChanges( 52 SyncError ApplySyncChanges(
52 std::unique_ptr<MetadataChangeList> metadata_change_list, 53 std::unique_ptr<MetadataChangeList> metadata_change_list,
53 EntityChangeList entity_changes) override; 54 EntityChangeList entity_changes) override;
54 void GetData(StorageKeyList storage_keys, DataCallback callback) override; 55 void GetData(StorageKeyList storage_keys, DataCallback callback) override;
55 void GetAllData(DataCallback callback) override; 56 void GetAllData(DataCallback callback) override;
56 std::string GetClientTag(const EntityData& entity_data) override; 57 std::string GetClientTag(const EntityData& entity_data) override;
57 std::string GetStorageKey(const EntityData& entity_data) override; 58 std::string GetStorageKey(const EntityData& entity_data) override;
58 void DisableSync() override; 59 void DisableSync() override;
59 60
60 // DeviceInfoTracker implementation. 61 // DeviceInfoTracker implementation.
61 bool IsSyncing() const override; 62 bool IsSyncing() const override;
62 std::unique_ptr<DeviceInfo> GetDeviceInfo( 63 std::unique_ptr<DeviceInfo> GetDeviceInfo(
63 const std::string& client_id) const override; 64 const std::string& client_id) const override;
64 std::vector<std::unique_ptr<DeviceInfo>> GetAllDeviceInfo() const override; 65 std::vector<std::unique_ptr<DeviceInfo>> GetAllDeviceInfo() const override;
65 void AddObserver(Observer* observer) override; 66 void AddObserver(Observer* observer) override;
66 void RemoveObserver(Observer* observer) override; 67 void RemoveObserver(Observer* observer) override;
67 int CountActiveDevices() const override; 68 int CountActiveDevices() const override;
68 69
69 private: 70 private:
70 friend class DeviceInfoServiceTest; 71 friend class DeviceInfoSyncBridgeTest;
71 72
72 // Cache of all syncable and local data, stored by device cache guid. 73 // Cache of all syncable and local data, stored by device cache guid.
73 using ClientIdToSpecifics = 74 using ClientIdToSpecifics =
74 std::map<std::string, std::unique_ptr<sync_pb::DeviceInfoSpecifics>>; 75 std::map<std::string, std::unique_ptr<sync_pb::DeviceInfoSpecifics>>;
75 76
76 // Store SyncData in the cache and durable storage. 77 // Store SyncData in the cache and durable storage.
77 void StoreSpecifics(std::unique_ptr<sync_pb::DeviceInfoSpecifics> specifics, 78 void StoreSpecifics(std::unique_ptr<sync_pb::DeviceInfoSpecifics> specifics,
78 ModelTypeStore::WriteBatch* batch); 79 ModelTypeStore::WriteBatch* batch);
79 // Delete SyncData from the cache and durable storage, returns true if there 80 // Delete SyncData from the cache and durable storage, returns true if there
80 // was actually anything at the given tag. 81 // was actually anything at the given tag.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 std::unique_ptr<ModelTypeStore> store_; 144 std::unique_ptr<ModelTypeStore> store_;
144 145
145 // If |local_device_info_provider_| has initialized. 146 // If |local_device_info_provider_| has initialized.
146 bool has_provider_initialized_ = false; 147 bool has_provider_initialized_ = false;
147 // If data has been loaded from the store. 148 // If data has been loaded from the store.
148 bool has_data_loaded_ = false; 149 bool has_data_loaded_ = false;
149 150
150 // Used to update our local device info once every pulse interval. 151 // Used to update our local device info once every pulse interval.
151 base::OneShotTimer pulse_timer_; 152 base::OneShotTimer pulse_timer_;
152 153
153 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); 154 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge);
154 }; 155 };
155 156
156 } // namespace syncer 157 } // namespace syncer
157 158
158 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ 159 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_
OLDNEW
« no previous file with comments | « components/sync/device_info/device_info_service_unittest.cc ('k') | components/sync/device_info/device_info_sync_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698