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

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

Issue 2623723002: [Sync] Remove ModelError::IsSet() in favor of base::Optional. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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_SYNC_BRIDGE_H_ 5 #ifndef COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_
6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_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/optional.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
18 #include "components/sync/device_info/device_info_tracker.h" 19 #include "components/sync/device_info/device_info_tracker.h"
19 #include "components/sync/device_info/local_device_info_provider.h" 20 #include "components/sync/device_info/local_device_info_provider.h"
20 #include "components/sync/model/model_error.h" 21 #include "components/sync/model/model_error.h"
21 #include "components/sync/model/model_type_store.h" 22 #include "components/sync/model/model_type_store.h"
22 #include "components/sync/model/model_type_sync_bridge.h" 23 #include "components/sync/model/model_type_sync_bridge.h"
23 24
24 namespace sync_pb { 25 namespace sync_pb {
25 class DeviceInfoSpecifics; 26 class DeviceInfoSpecifics;
(...skipping 10 matching lines...) Expand all
36 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)> 37 typedef base::Callback<void(const ModelTypeStore::InitCallback& callback)>
37 StoreFactoryFunction; 38 StoreFactoryFunction;
38 39
39 DeviceInfoSyncBridge(LocalDeviceInfoProvider* local_device_info_provider, 40 DeviceInfoSyncBridge(LocalDeviceInfoProvider* local_device_info_provider,
40 const StoreFactoryFunction& callback, 41 const StoreFactoryFunction& callback,
41 const ChangeProcessorFactory& change_processor_factory); 42 const ChangeProcessorFactory& change_processor_factory);
42 ~DeviceInfoSyncBridge() override; 43 ~DeviceInfoSyncBridge() override;
43 44
44 // ModelTypeSyncBridge implementation. 45 // ModelTypeSyncBridge implementation.
45 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; 46 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override;
46 ModelError MergeSyncData( 47 base::Optional<ModelError> MergeSyncData(
47 std::unique_ptr<MetadataChangeList> metadata_change_list, 48 std::unique_ptr<MetadataChangeList> metadata_change_list,
48 EntityDataMap entity_data_map) override; 49 EntityDataMap entity_data_map) override;
49 ModelError ApplySyncChanges( 50 base::Optional<ModelError> ApplySyncChanges(
50 std::unique_ptr<MetadataChangeList> metadata_change_list, 51 std::unique_ptr<MetadataChangeList> metadata_change_list,
51 EntityChangeList entity_changes) override; 52 EntityChangeList entity_changes) override;
52 void GetData(StorageKeyList storage_keys, DataCallback callback) override; 53 void GetData(StorageKeyList storage_keys, DataCallback callback) override;
53 void GetAllData(DataCallback callback) override; 54 void GetAllData(DataCallback callback) override;
54 std::string GetClientTag(const EntityData& entity_data) override; 55 std::string GetClientTag(const EntityData& entity_data) override;
55 std::string GetStorageKey(const EntityData& entity_data) override; 56 std::string GetStorageKey(const EntityData& entity_data) override;
56 void DisableSync() override; 57 void DisableSync() override;
57 58
58 // DeviceInfoTracker implementation. 59 // DeviceInfoTracker implementation.
59 bool IsSyncing() const override; 60 bool IsSyncing() const override;
(...skipping 23 matching lines...) Expand all
83 void NotifyObservers(); 84 void NotifyObservers();
84 85
85 // Used as callback given to LocalDeviceInfoProvider. 86 // Used as callback given to LocalDeviceInfoProvider.
86 void OnProviderInitialized(); 87 void OnProviderInitialized();
87 88
88 // Methods used as callbacks given to DataTypeStore. 89 // Methods used as callbacks given to DataTypeStore.
89 void OnStoreCreated(ModelTypeStore::Result result, 90 void OnStoreCreated(ModelTypeStore::Result result,
90 std::unique_ptr<ModelTypeStore> store); 91 std::unique_ptr<ModelTypeStore> store);
91 void OnReadAllData(ModelTypeStore::Result result, 92 void OnReadAllData(ModelTypeStore::Result result,
92 std::unique_ptr<ModelTypeStore::RecordList> record_list); 93 std::unique_ptr<ModelTypeStore::RecordList> record_list);
93 void OnReadAllMetadata(ModelError error, 94 void OnReadAllMetadata(base::Optional<ModelError> error,
94 std::unique_ptr<MetadataBatch> metadata_batch); 95 std::unique_ptr<MetadataBatch> metadata_batch);
95 void OnCommit(ModelTypeStore::Result result); 96 void OnCommit(ModelTypeStore::Result result);
96 97
97 // Load metadata if the data is loaded and the provider is initialized. 98 // Load metadata if the data is loaded and the provider is initialized.
98 void LoadMetadataIfReady(); 99 void LoadMetadataIfReady();
99 100
100 // Performs reconciliation between the locally provided device info and the 101 // Performs reconciliation between the locally provided device info and the
101 // stored device info data. If the sets of data differ, then we consider this 102 // stored device info data. If the sets of data differ, then we consider this
102 // a local change and we send it to the processor. 103 // a local change and we send it to the processor.
103 void ReconcileLocalAndStored(); 104 void ReconcileLocalAndStored();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 // Used to update our local device info once every pulse interval. 142 // Used to update our local device info once every pulse interval.
142 base::OneShotTimer pulse_timer_; 143 base::OneShotTimer pulse_timer_;
143 144
144 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge); 145 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge);
145 }; 146 };
146 147
147 } // namespace syncer 148 } // namespace syncer
148 149
149 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_ 150 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698