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

Side by Side Diff: components/sync_driver/device_info.cc

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. Created 4 years, 4 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
(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 #include "components/sync_driver/device_info.h"
6
7 #include "base/values.h"
8
9 namespace sync_driver {
10
11 DeviceInfo::DeviceInfo(const std::string& guid,
12 const std::string& client_name,
13 const std::string& chrome_version,
14 const std::string& sync_user_agent,
15 const sync_pb::SyncEnums::DeviceType device_type,
16 const std::string& signin_scoped_device_id)
17 : guid_(guid),
18 client_name_(client_name),
19 chrome_version_(chrome_version),
20 sync_user_agent_(sync_user_agent),
21 device_type_(device_type),
22 signin_scoped_device_id_(signin_scoped_device_id) {
23 }
24
25 DeviceInfo::~DeviceInfo() { }
26
27 const std::string& DeviceInfo::guid() const {
28 return guid_;
29 }
30
31 const std::string& DeviceInfo::client_name() const {
32 return client_name_;
33 }
34
35 const std::string& DeviceInfo::chrome_version() const {
36 return chrome_version_;
37 }
38
39 const std::string& DeviceInfo::sync_user_agent() const {
40 return sync_user_agent_;
41 }
42
43 const std::string& DeviceInfo::public_id() const {
44 return public_id_;
45 }
46
47 sync_pb::SyncEnums::DeviceType DeviceInfo::device_type() const {
48 return device_type_;
49 }
50
51 const std::string& DeviceInfo::signin_scoped_device_id() const {
52 return signin_scoped_device_id_;
53 }
54
55 std::string DeviceInfo::GetOSString() const {
56 switch (device_type_) {
57 case sync_pb::SyncEnums_DeviceType_TYPE_WIN:
58 return "win";
59 case sync_pb::SyncEnums_DeviceType_TYPE_MAC:
60 return "mac";
61 case sync_pb::SyncEnums_DeviceType_TYPE_LINUX:
62 return "linux";
63 case sync_pb::SyncEnums_DeviceType_TYPE_CROS:
64 return "chrome_os";
65 case sync_pb::SyncEnums_DeviceType_TYPE_PHONE:
66 case sync_pb::SyncEnums_DeviceType_TYPE_TABLET:
67 // TODO(lipalani): crbug.com/170375. Add support for ios
68 // phones and tablets.
69 return "android";
70 default:
71 return "unknown";
72 }
73 }
74
75 std::string DeviceInfo::GetDeviceTypeString() const {
76 switch (device_type_) {
77 case sync_pb::SyncEnums_DeviceType_TYPE_WIN:
78 case sync_pb::SyncEnums_DeviceType_TYPE_MAC:
79 case sync_pb::SyncEnums_DeviceType_TYPE_LINUX:
80 case sync_pb::SyncEnums_DeviceType_TYPE_CROS:
81 return "desktop_or_laptop";
82 case sync_pb::SyncEnums_DeviceType_TYPE_PHONE:
83 return "phone";
84 case sync_pb::SyncEnums_DeviceType_TYPE_TABLET:
85 return "tablet";
86 default:
87 return "unknown";
88 }
89 }
90
91 bool DeviceInfo::Equals(const DeviceInfo& other) const {
92 return this->guid() == other.guid() &&
93 this->client_name() == other.client_name() &&
94 this->chrome_version() == other.chrome_version() &&
95 this->sync_user_agent() == other.sync_user_agent() &&
96 this->device_type() == other.device_type() &&
97 this->signin_scoped_device_id() == other.signin_scoped_device_id();
98 }
99
100 base::DictionaryValue* DeviceInfo::ToValue() {
101 base::DictionaryValue* value = new base::DictionaryValue();
102 value->SetString("name", client_name_);
103 value->SetString("id", public_id_);
104 value->SetString("os", GetOSString());
105 value->SetString("type", GetDeviceTypeString());
106 value->SetString("chromeVersion", chrome_version_);
107 return value;
108 }
109
110 void DeviceInfo::set_public_id(const std::string& id) {
111 public_id_ = id;
112 }
113
114 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync_driver/device_info.h ('k') | components/sync_driver/device_info_data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698