| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ScopedVector<DeviceInfo>* device_info) const; | 54 ScopedVector<DeviceInfo>* device_info) const; |
| 55 | 55 |
| 56 virtual std::string cache_guid() const; | 56 virtual std::string cache_guid() const; |
| 57 | 57 |
| 58 // Can be called on any thread. Will be notified back on the same thread | 58 // Can be called on any thread. Will be notified back on the same thread |
| 59 // they were called on. Observer will be called on every device info | 59 // they were called on. Observer will be called on every device info |
| 60 // change. | 60 // change. |
| 61 void AddObserver(Observer* observer); | 61 void AddObserver(Observer* observer); |
| 62 void RemoveObserver(Observer* observer); | 62 void RemoveObserver(Observer* observer); |
| 63 | 63 |
| 64 // Update |backup_timestamp| in local device info specifics to |backup_time| |
| 65 // if different. |
| 66 void UpdateLocalDeviceBackupTime(base::Time backup_time); |
| 67 |
| 68 // Return time derived from |backup_timestamp| in local device info specifics. |
| 69 base::Time GetLocalDeviceBackupTime() const; |
| 70 |
| 64 private: | 71 private: |
| 65 friend class SyncedDeviceTrackerTest; | 72 friend class SyncedDeviceTrackerTest; |
| 66 | 73 |
| 67 void InitLocalDeviceInfoContinuation(const base::Closure& callback, | 74 void InitLocalDeviceInfoContinuation(const base::Closure& callback, |
| 68 const DeviceInfo& local_info); | 75 const DeviceInfo& local_info); |
| 69 | 76 |
| 70 // Helper to write specifics into our node. Also useful for testing. | 77 // Helper to write specifics into our node. Also useful for testing. |
| 71 void WriteLocalDeviceInfo(const DeviceInfo& info); | 78 void WriteLocalDeviceInfo(const DeviceInfo& info); |
| 72 | 79 |
| 73 // Helper to write arbitrary device info. Useful for writing local device | 80 // Helper to write arbitrary device info. Useful for writing local device |
| 74 // info and also used by test cases to write arbitrary device infos. | 81 // info and also used by test cases to write arbitrary device infos. |
| 75 void WriteDeviceInfo(const sync_pb::DeviceInfoSpecifics& specifics, | 82 void WriteDeviceInfo(const DeviceInfo& info, const std::string& tag); |
| 76 const std::string& tag); | |
| 77 | 83 |
| 78 syncer::UserShare* user_share_; | 84 syncer::UserShare* user_share_; |
| 79 const std::string cache_guid_; | 85 const std::string cache_guid_; |
| 80 const std::string local_device_info_tag_; | 86 const std::string local_device_info_tag_; |
| 81 | 87 |
| 82 // The |ObserverList| has to be thread safe as the changes happen | 88 // The |ObserverList| has to be thread safe as the changes happen |
| 83 // on sync thread and the observers could be on any thread. | 89 // on sync thread and the observers could be on any thread. |
| 84 typedef ObserverListThreadSafe<Observer> ObserverList; | 90 typedef ObserverListThreadSafe<Observer> ObserverList; |
| 85 scoped_refptr<ObserverList> observers_; | 91 scoped_refptr<ObserverList> observers_; |
| 86 | 92 |
| 87 base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_; | 93 base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_; |
| 88 | 94 |
| 89 DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker); | 95 DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker); |
| 90 }; | 96 }; |
| 91 | 97 |
| 92 } // namespace browser_sync | 98 } // namespace browser_sync |
| 93 | 99 |
| 94 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ | 100 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| OLD | NEW |