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

Unified Diff: chrome/browser/sync/glue/device_info.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/glue/device_info.h ('k') | chrome/browser/sync/glue/local_device_info_provider_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/device_info.cc
diff --git a/chrome/browser/sync/glue/device_info.cc b/chrome/browser/sync/glue/device_info.cc
index f3ea3602ddef8da4ffd64053a8f20d651f4c4f5f..8d07eeabd293ff94b5a1067390717c36359979db 100644
--- a/chrome/browser/sync/glue/device_info.cc
+++ b/chrome/browser/sync/glue/device_info.cc
@@ -2,48 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/glue/device_info.h"
-
-#include "base/command_line.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "base/values.h"
-#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/chrome_switches.h"
+#include "chrome/browser/sync/glue/device_info.h"
#include "content/public/browser/browser_thread.h"
#include "sync/util/get_session_name.h"
-#include "ui/base/device_form_factor.h"
namespace browser_sync {
-namespace {
-
-#if defined(OS_ANDROID)
-bool IsTabletUI() {
- return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET;
-}
-#endif
-
-// Converts VersionInfo::Channel to string for user-agent string.
-std::string ChannelToString(chrome::VersionInfo::Channel channel) {
- switch (channel) {
- case chrome::VersionInfo::CHANNEL_UNKNOWN:
- return "unknown";
- case chrome::VersionInfo::CHANNEL_CANARY:
- return "canary";
- case chrome::VersionInfo::CHANNEL_DEV:
- return "dev";
- case chrome::VersionInfo::CHANNEL_BETA:
- return "beta";
- case chrome::VersionInfo::CHANNEL_STABLE:
- return "stable";
- default:
- NOTREACHED();
- return "unknown";
- }
-}
-
-} // namespace
-
DeviceInfo::DeviceInfo(const std::string& guid,
const std::string& client_name,
const std::string& chrome_version,
@@ -133,65 +98,6 @@ bool DeviceInfo::Equals(const DeviceInfo& other) const {
this->signin_scoped_device_id() == other.signin_scoped_device_id();
}
-// static.
-sync_pb::SyncEnums::DeviceType DeviceInfo::GetLocalDeviceType() {
-#if defined(OS_CHROMEOS)
- return sync_pb::SyncEnums_DeviceType_TYPE_CROS;
-#elif defined(OS_LINUX)
- return sync_pb::SyncEnums_DeviceType_TYPE_LINUX;
-#elif defined(OS_MACOSX)
- return sync_pb::SyncEnums_DeviceType_TYPE_MAC;
-#elif defined(OS_WIN)
- return sync_pb::SyncEnums_DeviceType_TYPE_WIN;
-#elif defined(OS_ANDROID)
- return IsTabletUI() ?
- sync_pb::SyncEnums_DeviceType_TYPE_TABLET :
- sync_pb::SyncEnums_DeviceType_TYPE_PHONE;
-#else
- return sync_pb::SyncEnums_DeviceType_TYPE_OTHER;
-#endif
-}
-
-// static
-std::string DeviceInfo::MakeUserAgentForSyncApi(
- const chrome::VersionInfo& version_info) {
- std::string user_agent;
- user_agent = "Chrome ";
-#if defined(OS_WIN)
- user_agent += "WIN ";
-#elif defined(OS_CHROMEOS)
- user_agent += "CROS ";
-#elif defined(OS_ANDROID)
- if (IsTabletUI())
- user_agent += "ANDROID-TABLET ";
- else
- user_agent += "ANDROID-PHONE ";
-#elif defined(OS_LINUX)
- user_agent += "LINUX ";
-#elif defined(OS_FREEBSD)
- user_agent += "FREEBSD ";
-#elif defined(OS_OPENBSD)
- user_agent += "OPENBSD ";
-#elif defined(OS_MACOSX)
- user_agent += "MAC ";
-#endif
- if (!version_info.is_valid()) {
- DLOG(ERROR) << "Unable to create chrome::VersionInfo object";
- return user_agent;
- }
-
- user_agent += version_info.Version();
- user_agent += " (" + version_info.LastChange() + ")";
- if (!version_info.IsOfficialBuild()) {
- user_agent += "-devel";
- } else {
- user_agent += " channel(" +
- ChannelToString(version_info.GetChannel()) + ")";
- }
-
- return user_agent;
-}
-
base::DictionaryValue* DeviceInfo::ToValue() {
base::DictionaryValue* value = new base::DictionaryValue();
value->SetString("name", client_name_);
@@ -207,47 +113,8 @@ void DeviceInfo::set_public_id(std::string id) {
}
// static.
-void DeviceInfo::CreateLocalDeviceInfo(
- const std::string& guid,
- const std::string& signin_scoped_device_id,
- base::Callback<void(const DeviceInfo& local_info)> callback) {
- GetClientName(base::Bind(&DeviceInfo::CreateLocalDeviceInfoContinuation,
- guid,
- signin_scoped_device_id,
- callback));
-}
-
-// static.
-void DeviceInfo::GetClientName(
- base::Callback<void(const std::string& client_name)> callback) {
- syncer::GetSessionName(
- content::BrowserThread::GetBlockingPool(),
- base::Bind(&DeviceInfo::GetClientNameContinuation,
- callback));
-}
-
-void DeviceInfo::GetClientNameContinuation(
- base::Callback<void(const std::string& local_info)> callback,
- const std::string& session_name) {
- callback.Run(session_name);
-}
-
-// static.
-void DeviceInfo::CreateLocalDeviceInfoContinuation(
- const std::string& guid,
- const std::string& signin_scoped_device_id,
- base::Callback<void(const DeviceInfo& local_info)> callback,
- const std::string& session_name) {
- chrome::VersionInfo version_info;
-
- DeviceInfo local_info(guid,
- session_name,
- version_info.CreateVersionString(),
- MakeUserAgentForSyncApi(version_info),
- GetLocalDeviceType(),
- signin_scoped_device_id);
-
- callback.Run(local_info);
+void DeviceInfo::GetClientName(const GetClientNameCallback& callback) {
+ syncer::GetSessionName(content::BrowserThread::GetBlockingPool(), callback);
}
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/device_info.h ('k') | chrome/browser/sync/glue/local_device_info_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698