Chromium Code Reviews| 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> | |
|
Nicolas Zea
2012/09/14 19:15:08
newline after
rlarocque
2012/09/15 01:36:37
Done.
| |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/sync/glue/change_processor.h" | |
| 12 #include "sync/protocol/sync.pb.h" | |
| 13 | |
| 14 namespace browser_sync { | |
| 15 | |
| 16 // TODO(rlarocque): Move this into its own class. | |
| 17 // TODO(rlarocque): Create a class to manage a list of these. | |
| 18 struct DeviceInfo { | |
| 19 std::string client_name; | |
| 20 std::string chrome_version; | |
| 21 sync_pb::SyncEnums::DeviceType device_type; | |
| 22 }; | |
| 23 | |
| 24 class SyncedDeviceTracker : public ChangeProcessor { | |
| 25 public: | |
| 26 SyncedDeviceTracker(); | |
| 27 virtual ~SyncedDeviceTracker(); | |
| 28 | |
| 29 // ChangeProcessor methods | |
| 30 virtual void StartImpl(Profile* profile) OVERRIDE; | |
| 31 virtual void StopImpl() OVERRIDE; | |
| 32 | |
| 33 virtual void ApplyChangesFromSyncModel( | |
|
Nicolas Zea
2012/09/14 19:15:08
move up a line? (to make clear these are also chan
rlarocque
2012/09/15 01:36:37
Done.
| |
| 34 const syncer::BaseTransaction* trans, | |
| 35 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; | |
| 36 virtual void CommitChangesFromSyncModel() OVERRIDE; | |
| 37 | |
| 38 // Methods for accessing and updating the device_info list. | |
| 39 bool GetLocalDeviceInfo(const syncer::BaseTransaction &trans, | |
| 40 DeviceInfo* out); | |
| 41 bool GetLocalDeviceInfo(DeviceInfo* out); | |
| 42 void InitLocalDeviceInfo(const base::Closure& callback); | |
| 43 | |
| 44 // TODO(rlarocque): Move this to the DeviceInfo class. | |
| 45 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); | |
| 46 | |
| 47 private: | |
| 48 friend class SyncedDeviceTrackerTest; | |
| 49 | |
| 50 void InitLocalDeviceInfoContinuation(const base::Closure& callback, | |
| 51 const std::string& session_name); | |
| 52 | |
| 53 // Helper to write specifics into our node. Also useful for testing. | |
| 54 void WriteLocalDeviceInfo(const DeviceInfo& info); | |
| 55 | |
| 56 base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker); | |
| 59 }; | |
| 60 | |
| 61 } // namespace browser_sync | |
| 62 | |
| 63 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ | |
| OLD | NEW |