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_DEVICE_INFO_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/bind.h" |
| 11 #include "sync/protocol/sync.pb.h" |
| 12 |
| 13 namespace chrome { |
| 14 class VersionInfo; |
| 15 } |
| 16 |
| 17 namespace browser_sync { |
| 18 |
| 19 // A class that holds information regarding the properties of a device. |
| 20 // |
| 21 // These objects do not contain enough information to uniquely identify devices. |
| 22 // Two different devices may end up generating identical DeviceInfos. |
| 23 class DeviceInfo { |
| 24 public: |
| 25 DeviceInfo(); |
| 26 DeviceInfo(const std::string& client_name, |
| 27 const std::string& chrome_version, |
| 28 const std::string& sync_user_agent, |
| 29 const sync_pb::SyncEnums::DeviceType device_type); |
| 30 ~DeviceInfo(); |
| 31 |
| 32 const std::string& client_name() const; |
| 33 const std::string& chrome_version() const; |
| 34 const std::string& sync_user_agent() const; |
| 35 sync_pb::SyncEnums::DeviceType device_type() const; |
| 36 |
| 37 // Compares this object's fields with another's. |
| 38 bool Equals(const DeviceInfo& other) const; |
| 39 |
| 40 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); |
| 41 static void CreateLocalDeviceInfo( |
| 42 base::Callback<void(const DeviceInfo& local_info)> callback); |
| 43 |
| 44 // Helper to construct a user agent string (ASCII) suitable for use by |
| 45 // the syncapi for any HTTP communication. This string is used by the sync |
| 46 // backend for classifying client types when calculating statistics. |
| 47 static std::string MakeUserAgentForSyncApi( |
| 48 const chrome::VersionInfo& version_info); |
| 49 |
| 50 private: |
| 51 static void CreateLocalDeviceInfoContinuation( |
| 52 base::Callback<void(const DeviceInfo& local_info)> callback, |
| 53 const std::string& session_name); |
| 54 |
| 55 const std::string client_name_; |
| 56 const std::string chrome_version_; |
| 57 const std::string sync_user_agent_; |
| 58 const sync_pb::SyncEnums::DeviceType device_type_; |
| 59 }; |
| 60 |
| 61 } |
| 62 |
| 63 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
OLD | NEW |