Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/sync/glue/device_info.h

Issue 594643003: Device info datatype should be moved to components/sync_driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_DEVICE_INFO_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_
6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/callback.h"
12 #include "sync/protocol/sync.pb.h" 12 #include "sync/protocol/sync.pb.h"
13 13
14 namespace base { 14 namespace base {
15 class DictionaryValue; 15 class DictionaryValue;
16 } 16 }
17 17
18 namespace chrome {
19 class VersionInfo;
20 }
21
22 namespace browser_sync { 18 namespace browser_sync {
23 19
24 // A class that holds information regarding the properties of a device. 20 // A class that holds information regarding the properties of a device.
25 class DeviceInfo { 21 class DeviceInfo {
26 public: 22 public:
23 typedef base::Callback<void(const std::string&)> GetClientNameCallback;
24
27 DeviceInfo(const std::string& guid, 25 DeviceInfo(const std::string& guid,
28 const std::string& client_name, 26 const std::string& client_name,
29 const std::string& chrome_version, 27 const std::string& chrome_version,
30 const std::string& sync_user_agent, 28 const std::string& sync_user_agent,
31 const sync_pb::SyncEnums::DeviceType device_type, 29 const sync_pb::SyncEnums::DeviceType device_type,
32 const std::string& signin_scoped_device_id); 30 const std::string& signin_scoped_device_id);
33 ~DeviceInfo(); 31 ~DeviceInfo();
34 32
35 // Sync specific unique identifier for the device. Note if a device 33 // Sync specific unique identifier for the device. Note if a device
36 // is wiped and sync is set up again this id WILL be different. 34 // is wiped and sync is set up again this id WILL be different.
37 // The same device might have more than 1 guid if the device has multiple 35 // The same device might have more than 1 guid if the device has multiple
38 // accounts syncing. 36 // accounts syncing.
39 const std::string& guid() const; 37 const std::string& guid() const;
40 38
41 // The host name for the client. 39 // The host name for the client.
42 const std::string& client_name() const; 40 const std::string& client_name() const;
43 41
44 // Chrome version string. 42 // Chrome version string.
45 const std::string& chrome_version() const; 43 const std::string& chrome_version() const;
46 44
47 // The user agent is the combination of OS type, chrome version and which 45 // The user agent is the combination of OS type, chrome version and which
48 // channel of chrome(stable or beta). For more information see 46 // channel of chrome(stable or beta). For more information see
49 // |DeviceInfo::MakeUserAgentForSyncApi|. 47 // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
50 const std::string& sync_user_agent() const; 48 const std::string& sync_user_agent() const;
51 49
52 // Third party visible id for the device. See |public_id_| for more details. 50 // Third party visible id for the device. See |public_id_| for more details.
53 const std::string& public_id() const; 51 const std::string& public_id() const;
54 52
55 // Device Type. 53 // Device Type.
56 sync_pb::SyncEnums::DeviceType device_type() const; 54 sync_pb::SyncEnums::DeviceType device_type() const;
57 55
58 // Device_id that is stable until user signs out. This device_id is used for 56 // Device_id that is stable until user signs out. This device_id is used for
59 // annotating login scoped refresh token. 57 // annotating login scoped refresh token.
(...skipping 11 matching lines...) Expand all
71 // Apps can set ids for a device that is meaningful to them but 69 // Apps can set ids for a device that is meaningful to them but
72 // not unique enough so the user can be tracked. Exposing |guid| 70 // not unique enough so the user can be tracked. Exposing |guid|
73 // would lead to a stable unique id for a device which can potentially 71 // would lead to a stable unique id for a device which can potentially
74 // be used for tracking. 72 // be used for tracking.
75 void set_public_id(std::string id); 73 void set_public_id(std::string id);
76 74
77 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue, 75 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue,
78 // which extension APIs can expose to third party apps. 76 // which extension APIs can expose to third party apps.
79 base::DictionaryValue* ToValue(); 77 base::DictionaryValue* ToValue();
80 78
81 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType();
82
83 // Creates a |DeviceInfo| object representing the local device and passes
84 // it as parameter to the callback.
85 static void CreateLocalDeviceInfo(
86 const std::string& guid,
87 const std::string& signin_scoped_device_id,
88 base::Callback<void(const DeviceInfo& local_info)> callback);
89
90 // Gets the local device name and passes it as a parameter to callback. 79 // Gets the local device name and passes it as a parameter to callback.
91 static void GetClientName( 80 static void GetClientName(const GetClientNameCallback& callback);
92 base::Callback<void(const std::string& local_info)> callback);
93
94 // Helper to construct a user agent string (ASCII) suitable for use by
95 // the syncapi for any HTTP communication. This string is used by the sync
96 // backend for classifying client types when calculating statistics.
97 static std::string MakeUserAgentForSyncApi(
98 const chrome::VersionInfo& version_info);
99 81
100 private: 82 private:
101 static void GetClientNameContinuation(
102 base::Callback<void(const std::string& local_info)> callback,
103 const std::string& session_name);
104
105 static void CreateLocalDeviceInfoContinuation(
106 const std::string& guid,
107 const std::string& signin_scoped_device_id,
108 base::Callback<void(const DeviceInfo& local_info)> callback,
109 const std::string& session_name);
110
111 const std::string guid_; 83 const std::string guid_;
112 84
113 const std::string client_name_; 85 const std::string client_name_;
114 86
115 const std::string chrome_version_; 87 const std::string chrome_version_;
116 88
117 const std::string sync_user_agent_; 89 const std::string sync_user_agent_;
118 90
119 const sync_pb::SyncEnums::DeviceType device_type_; 91 const sync_pb::SyncEnums::DeviceType device_type_;
120 92
121 std::string signin_scoped_device_id_; 93 std::string signin_scoped_device_id_;
122 94
123 // Exposing |guid| would lead to a stable unique id for a device which 95 // Exposing |guid| would lead to a stable unique id for a device which
124 // can potentially be used for tracking. Public ids are privacy safe 96 // can potentially be used for tracking. Public ids are privacy safe
125 // ids in that the same device will have different id for different apps 97 // ids in that the same device will have different id for different apps
126 // and they are also reset when app/extension is uninstalled. 98 // and they are also reset when app/extension is uninstalled.
127 std::string public_id_; 99 std::string public_id_;
128 100
129 DISALLOW_COPY_AND_ASSIGN(DeviceInfo); 101 DISALLOW_COPY_AND_ASSIGN(DeviceInfo);
130 }; 102 };
131 103
132 } // namespace browser_sync 104 } // namespace browser_sync
133 105
134 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ 106 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/ui_thread_search_terms_data.cc ('k') | chrome/browser/sync/glue/device_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698