OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/sync/glue/change_processor.h" |
| 14 |
| 15 namespace syncer { |
| 16 struct UserShare; |
| 17 } |
| 18 |
| 19 namespace browser_sync { |
| 20 |
| 21 class DeviceInfo; |
| 22 |
| 23 class SyncedDeviceTracker : public ChangeProcessor { |
| 24 public: |
| 25 SyncedDeviceTracker(syncer::UserShare* user_share, |
| 26 const std::string& cache_guid); |
| 27 virtual ~SyncedDeviceTracker(); |
| 28 |
| 29 // ChangeProcessor methods |
| 30 virtual void StartImpl(Profile* profile) OVERRIDE; |
| 31 virtual void ApplyChangesFromSyncModel( |
| 32 const syncer::BaseTransaction* trans, |
| 33 int64 model_version, |
| 34 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; |
| 35 virtual void CommitChangesFromSyncModel() OVERRIDE; |
| 36 |
| 37 // Methods for accessing and updating the device_info list. |
| 38 // These are virtual for testing. |
| 39 virtual scoped_ptr<DeviceInfo> ReadLocalDeviceInfo( |
| 40 const syncer::BaseTransaction &trans); |
| 41 virtual scoped_ptr<DeviceInfo> ReadLocalDeviceInfo(); |
| 42 virtual void InitLocalDeviceInfo(const base::Closure& callback); |
| 43 |
| 44 private: |
| 45 friend class SyncedDeviceTrackerTest; |
| 46 |
| 47 void InitLocalDeviceInfoContinuation(const base::Closure& callback, |
| 48 const DeviceInfo& local_info); |
| 49 |
| 50 // Helper to write specifics into our node. Also useful for testing. |
| 51 void WriteLocalDeviceInfo(const DeviceInfo& info); |
| 52 |
| 53 base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_; |
| 54 |
| 55 syncer::UserShare* user_share_; |
| 56 const std::string cache_guid_; |
| 57 const std::string local_device_info_tag_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker); |
| 60 }; |
| 61 |
| 62 } // namespace browser_sync |
| 63 |
| 64 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
OLD | NEW |