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

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

Issue 10911073: NOT FOR COMMIT: Add DeviceInfo type and ChangeProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes Created 8 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 | Annotate | Revision Log
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 "chrome/browser/sync/glue/device_info.h"
6
7 #include "base/threading/sequenced_worker_pool.h"
8 #include "chrome/common/chrome_version_info.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "sync/util/get_session_name.h"
11
12 namespace browser_sync {
13
14 DeviceInfo::DeviceInfo()
15 : client_name_("Unset"),
16 chrome_version_("Unknown"),
17 device_type_(sync_pb::SyncEnums::TYPE_OTHER) {
18 }
19
20 DeviceInfo::DeviceInfo(const std::string& client_name,
21 const std::string& chrome_version,
22 const sync_pb::SyncEnums::DeviceType device_type)
23 : client_name_(client_name),
24 chrome_version_(chrome_version),
25 device_type_(device_type) {
26 }
27
28 DeviceInfo::~DeviceInfo() { }
29
30 const std::string& DeviceInfo::client_name() const {
31 return client_name_;
32 }
33
34 const std::string& DeviceInfo::chrome_version() const {
35 return chrome_version_;
36 }
37
38 sync_pb::SyncEnums::DeviceType DeviceInfo::device_type() const {
39 return device_type_;
40 }
41
42 bool DeviceInfo::Equals(const DeviceInfo& other) const {
43 return this->client_name() == other.client_name()
44 && this->chrome_version() == other.chrome_version()
45 && this->device_type() == other.device_type();
46 }
47
48 // static.
49 sync_pb::SyncEnums::DeviceType DeviceInfo::GetLocalDeviceType() {
50 #if defined(OS_CHROMEOS)
51 return sync_pb::SyncEnums_DeviceType_TYPE_CROS;
52 #elif defined(OS_LINUX)
53 return sync_pb::SyncEnums_DeviceType_TYPE_LINUX;
54 #elif defined(OS_MACOSX)
55 return sync_pb::SyncEnums_DeviceType_TYPE_MAC;
56 #elif defined(OS_WIN)
57 return sync_pb::SyncEnums_DeviceType_TYPE_WIN;
58 #elif defined(OS_ANDROID)
59 return IsTabletUI() ?
60 sync_pb::SessionHeader_DeviceType_TYPE_TABLET :
61 sync_pb::SessionHeader_DeviceType_TYPE_PHONE;
62 #else
63 return sync_pb::SessionHeader_DeviceType_TYPE_OTHER;
64 #endif
65 }
66
67 // static.
68 void DeviceInfo::CreateLocalDeviceInfo(
69 base::Callback<void(const DeviceInfo& local_info)> callback) {
70 const scoped_refptr<base::TaskRunner> blocking_task_runner(
71 content::BrowserThread::GetBlockingPool());
72 syncer::GetSessionName(
73 blocking_task_runner.get(),
74 base::Bind(&DeviceInfo::CreateLocalDeviceInfoContinuation, callback));
75 }
76
77 // static.
78 void DeviceInfo::CreateLocalDeviceInfoContinuation(
79 base::Callback<void(const DeviceInfo& local_info)> callback,
80 const std::string& session_name) {
81 chrome::VersionInfo version_info;
82
83 DeviceInfo local_info(
84 session_name,
85 version_info.CreateVersionString(),
86 GetLocalDeviceType());
87
88 callback.Run(local_info);
89 }
90
91 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698