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_DRIVER_DEVICE_INFO_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SERVICE_H_ |
6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SERVICE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SERVICE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <string> | 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
15 #include "components/sync_driver/device_info_tracker.h" | 17 #include "components/sync_driver/device_info_tracker.h" |
16 #include "components/sync_driver/local_device_info_provider.h" | 18 #include "components/sync_driver/local_device_info_provider.h" |
17 #include "sync/api/model_type_service.h" | 19 #include "sync/api/model_type_service.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void StoreSpecifics(scoped_ptr<sync_pb::DeviceInfoSpecifics> specifics); | 84 void StoreSpecifics(scoped_ptr<sync_pb::DeviceInfoSpecifics> specifics); |
83 // Delete SyncData from the cache. | 85 // Delete SyncData from the cache. |
84 void DeleteSpecifics(const std::string& client_id); | 86 void DeleteSpecifics(const std::string& client_id); |
85 | 87 |
86 // Notify all registered observers. | 88 // Notify all registered observers. |
87 void NotifyObservers(); | 89 void NotifyObservers(); |
88 | 90 |
89 void OnProviderInitialized(); | 91 void OnProviderInitialized(); |
90 | 92 |
91 // |local_device_backup_time_| accessors. | 93 // |local_device_backup_time_| accessors. |
92 int64 local_device_backup_time() const { return local_device_backup_time_; } | 94 int64_t local_device_backup_time() const { return local_device_backup_time_; } |
93 bool has_local_device_backup_time() const { | 95 bool has_local_device_backup_time() const { |
94 return local_device_backup_time_ >= 0; | 96 return local_device_backup_time_ >= 0; |
95 } | 97 } |
96 void set_local_device_backup_time(int64 value) { | 98 void set_local_device_backup_time(int64_t value) { |
97 local_device_backup_time_ = value; | 99 local_device_backup_time_ = value; |
98 } | 100 } |
99 void clear_local_device_backup_time() { local_device_backup_time_ = -1; } | 101 void clear_local_device_backup_time() { local_device_backup_time_ = -1; } |
100 | 102 |
101 // TODO(skym): Remove once we remove local provider. | 103 // TODO(skym): Remove once we remove local provider. |
102 // Local device last set backup time (in proto format). | 104 // Local device last set backup time (in proto format). |
103 // -1 if the value hasn't been specified | 105 // -1 if the value hasn't been specified |
104 int64 local_device_backup_time_; | 106 int64_t local_device_backup_time_; |
105 | 107 |
106 // |local_device_info_provider_| isn't owned. | 108 // |local_device_info_provider_| isn't owned. |
107 const sync_driver::LocalDeviceInfoProvider* const local_device_info_provider_; | 109 const sync_driver::LocalDeviceInfoProvider* const local_device_info_provider_; |
108 | 110 |
109 // TODO(skym): Switch to use client tag hash instead of cache guid as key. | 111 // TODO(skym): Switch to use client tag hash instead of cache guid as key. |
110 // Cache of all syncable and local data, stored by device cache guid. | 112 // Cache of all syncable and local data, stored by device cache guid. |
111 using ClientIdToSpecifics = | 113 using ClientIdToSpecifics = |
112 std::map<std::string, scoped_ptr<sync_pb::DeviceInfoSpecifics>>; | 114 std::map<std::string, scoped_ptr<sync_pb::DeviceInfoSpecifics>>; |
113 ClientIdToSpecifics all_data_; | 115 ClientIdToSpecifics all_data_; |
114 | 116 |
115 // Registered observers, not owned. | 117 // Registered observers, not owned. |
116 base::ObserverList<Observer, true> observers_; | 118 base::ObserverList<Observer, true> observers_; |
117 | 119 |
118 scoped_ptr<sync_driver::LocalDeviceInfoProvider::Subscription> subscription_; | 120 scoped_ptr<sync_driver::LocalDeviceInfoProvider::Subscription> subscription_; |
119 | 121 |
120 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); | 122 DISALLOW_COPY_AND_ASSIGN(DeviceInfoService); |
121 }; | 123 }; |
122 | 124 |
123 } // namespace sync_driver_v2 | 125 } // namespace sync_driver_v2 |
124 | 126 |
125 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SERVICE_H_ | 127 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SERVICE_H_ |
OLD | NEW |