Chromium Code Reviews| Index: chrome/browser/sync/glue/synced_device_tracker.h |
| diff --git a/chrome/browser/sync/glue/synced_device_tracker.h b/chrome/browser/sync/glue/synced_device_tracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..59b110fb116f3cbd0a06f18049fc2a6aff9c681a |
| --- /dev/null |
| +++ b/chrome/browser/sync/glue/synced_device_tracker.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| +#define CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |
| + |
| +#include <string> |
|
Nicolas Zea
2012/09/14 19:15:08
newline after
rlarocque
2012/09/15 01:36:37
Done.
|
| +#include "base/basictypes.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/sync/glue/change_processor.h" |
| +#include "sync/protocol/sync.pb.h" |
| + |
| +namespace browser_sync { |
| + |
| +// TODO(rlarocque): Move this into its own class. |
| +// TODO(rlarocque): Create a class to manage a list of these. |
| +struct DeviceInfo { |
| + std::string client_name; |
| + std::string chrome_version; |
| + sync_pb::SyncEnums::DeviceType device_type; |
| +}; |
| + |
| +class SyncedDeviceTracker : public ChangeProcessor { |
| + public: |
| + SyncedDeviceTracker(); |
| + virtual ~SyncedDeviceTracker(); |
| + |
| + // ChangeProcessor methods |
| + virtual void StartImpl(Profile* profile) OVERRIDE; |
| + virtual void StopImpl() OVERRIDE; |
| + |
| + 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.
|
| + const syncer::BaseTransaction* trans, |
| + const syncer::ImmutableChangeRecordList& changes) OVERRIDE; |
| + virtual void CommitChangesFromSyncModel() OVERRIDE; |
| + |
| + // Methods for accessing and updating the device_info list. |
| + bool GetLocalDeviceInfo(const syncer::BaseTransaction &trans, |
| + DeviceInfo* out); |
| + bool GetLocalDeviceInfo(DeviceInfo* out); |
| + void InitLocalDeviceInfo(const base::Closure& callback); |
| + |
| + // TODO(rlarocque): Move this to the DeviceInfo class. |
| + static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); |
| + |
| + private: |
| + friend class SyncedDeviceTrackerTest; |
| + |
| + void InitLocalDeviceInfoContinuation(const base::Closure& callback, |
| + const std::string& session_name); |
| + |
| + // Helper to write specifics into our node. Also useful for testing. |
| + void WriteLocalDeviceInfo(const DeviceInfo& info); |
| + |
| + base::WeakPtrFactory<SyncedDeviceTracker> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SyncedDeviceTracker); |
| +}; |
| + |
| +} // namespace browser_sync |
| + |
| +#endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_DEVICE_TRACKER_H_ |