| 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_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/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" | |
| 23 | 22 |
| 24 namespace sync_pb { | 23 namespace sync_pb { |
| 25 class DeviceInfoSpecifics; | 24 class DeviceInfoSpecifics; |
| 26 } // namespace sync_pb | 25 } // namespace sync_pb |
| 27 | 26 |
| 28 namespace syncer { | 27 namespace syncer { |
| 29 | 28 |
| 30 class ModelTypeChangeProcessor; | 29 class ModelTypeChangeProcessor; |
| 31 class SyncError; | 30 class SyncError; |
| 32 | 31 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 void ReconcileLocalAndStored(); | 107 void ReconcileLocalAndStored(); |
| 109 | 108 |
| 110 // Stores the updated version of the local copy of device info in durable | 109 // Stores the updated version of the local copy of device info in durable |
| 111 // storage, in memory, and informs sync of the change. Should not be called | 110 // storage, in memory, and informs sync of the change. Should not be called |
| 112 // before the provider and processor have initialized. | 111 // before the provider and processor have initialized. |
| 113 void SendLocalData(); | 112 void SendLocalData(); |
| 114 | 113 |
| 115 // Persists the changes in the given aggregators and notifies observers if | 114 // Persists the changes in the given aggregators and notifies observers if |
| 116 // indicated to do as such. | 115 // indicated to do as such. |
| 117 void CommitAndNotify(std::unique_ptr<ModelTypeStore::WriteBatch> batch, | 116 void CommitAndNotify(std::unique_ptr<ModelTypeStore::WriteBatch> batch, |
| 118 std::unique_ptr<MetadataChangeList> metadata_change_list, | |
| 119 bool should_notify); | 117 bool should_notify); |
| 120 | 118 |
| 121 // Counts the number of active devices relative to |now|. The activeness of a | 119 // Counts the number of active devices relative to |now|. The activeness of a |
| 122 // device depends on the amount of time since it was updated, which means | 120 // device depends on the amount of time since it was updated, which means |
| 123 // comparing it against the current time. |now| is passed into this method to | 121 // comparing it against the current time. |now| is passed into this method to |
| 124 // allow unit tests to control expected results. | 122 // allow unit tests to control expected results. |
| 125 int CountActiveDevices(const base::Time now) const; | 123 int CountActiveDevices(const base::Time now) const; |
| 126 | 124 |
| 127 // Report an error starting up to sync if it tries to connect to this | 125 // Report an error starting up to sync if it tries to connect to this |
| 128 // datatype, since these errors prevent us from knowing if sync is enabled. | 126 // datatype, since these errors prevent us from knowing if sync is enabled. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 150 | 148 |
| 151 // Used to update our local device info once every pulse interval. | 149 // Used to update our local device info once every pulse interval. |
| 152 base::OneShotTimer pulse_timer_; | 150 base::OneShotTimer pulse_timer_; |
| 153 | 151 |
| 154 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge); | 152 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncBridge); |
| 155 }; | 153 }; |
| 156 | 154 |
| 157 } // namespace syncer | 155 } // namespace syncer |
| 158 | 156 |
| 159 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_ | 157 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_BRIDGE_H_ |
| OLD | NEW |