Commit 1052875a authored by stanisc's avatar stanisc Committed by Commit bot

Device info datatype should be moved to components/sync_driver.

This change prepares DeviceInfo class (and all other sync
classes that depend on DeviceInfo and implement DEVICE_INFO
syncable type) to be moved to components/sync_driver library
by removing any dependencies on chrome/browser.

To achieve this all chrome/browser specific code was moved to
LocalDeviceInfoProviderImpl which will stay in browser/sync/glue.
All other classes including DeviceInfo and LocalDeviceInfoProvider
should now depend only on base or components. I'll move
them to components/sync_driver in the next change.

Details:

1) In ui_thread_search_terms_data.cc DeviceInfo::GetLocalDeviceType()
was used just to find out if the device is an Android phone.
Since this code has nothing to do with Sync I replaced these
with direct calls to ui::GetDeviceFormFactor() - that exactly
what DeviceInfo::GetLocalDeviceType() does internally.

2) In sessions_sync_manager.cc - calling DeviceInfo::GetLocalDeviceType()
isn't necessary anymore because the local device type can be
accessed via the owned LocalDeviceInfoProvider instance.
This allowed me to move GetLocalDeviceType() to LocalDeviceInfoProviderImpl
and make it private.

3) DeviceInfo::MakeUserAgentForSyncApi() is called only
from the code that will stay in browser/sync/glue.
I moved the implemented to LocalDeviceInfoProviderImpl class.

BUG=396136

Review URL: https://codereview.chromium.org/594643003

Cr-Commit-Position: refs/heads/master@{#296267}
parent 1dbb8e29
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "chrome/browser/search/instant_service.h" #include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h" #include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
#include "chrome/browser/sync/glue/device_info.h"
#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
#include "components/omnibox/omnibox_field_trial.h" #include "components/omnibox/omnibox_field_trial.h"
#include "components/search/search.h" #include "components/search/search.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "sync/protocol/sync.pb.h" #include "ui/base/device_form_factor.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(ENABLE_RLZ) #if defined(ENABLE_RLZ)
...@@ -103,10 +102,8 @@ std::string UIThreadSearchTermsData::GetSuggestClient() const { ...@@ -103,10 +102,8 @@ std::string UIThreadSearchTermsData::GetSuggestClient() const {
DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::CurrentlyOn(BrowserThread::UI));
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
sync_pb::SyncEnums::DeviceType device_type = return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE ?
browser_sync::DeviceInfo::GetLocalDeviceType(); "chrome" : "chrome-omni";
return device_type == sync_pb::SyncEnums_DeviceType_TYPE_PHONE ?
"chrome" : "chrome-omni";
#else #else
return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome";
#endif #endif
...@@ -116,9 +113,7 @@ std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { ...@@ -116,9 +113,7 @@ std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const {
DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::CurrentlyOn(BrowserThread::UI));
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
sync_pb::SyncEnums::DeviceType device_type = if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE) {
browser_sync::DeviceInfo::GetLocalDeviceType();
if (device_type == sync_pb::SyncEnums_DeviceType_TYPE_PHONE) {
return OmniboxFieldTrial::EnableAnswersInSuggest() ? return OmniboxFieldTrial::EnableAnswersInSuggest() ?
"chrome-mobile-ext-ansg" : "chrome-mobile-ext"; "chrome-mobile-ext-ansg" : "chrome-mobile-ext";
} }
......
...@@ -2,48 +2,13 @@ ...@@ -2,48 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 "base/values.h"
#include "chrome/common/chrome_version_info.h" #include "chrome/browser/sync/glue/device_info.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "sync/util/get_session_name.h" #include "sync/util/get_session_name.h"
#include "ui/base/device_form_factor.h"
namespace browser_sync { 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, DeviceInfo::DeviceInfo(const std::string& guid,
const std::string& client_name, const std::string& client_name,
const std::string& chrome_version, const std::string& chrome_version,
...@@ -133,65 +98,6 @@ bool DeviceInfo::Equals(const DeviceInfo& other) const { ...@@ -133,65 +98,6 @@ bool DeviceInfo::Equals(const DeviceInfo& other) const {
this->signin_scoped_device_id() == other.signin_scoped_device_id(); 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* DeviceInfo::ToValue() {
base::DictionaryValue* value = new base::DictionaryValue(); base::DictionaryValue* value = new base::DictionaryValue();
value->SetString("name", client_name_); value->SetString("name", client_name_);
...@@ -207,47 +113,8 @@ void DeviceInfo::set_public_id(std::string id) { ...@@ -207,47 +113,8 @@ void DeviceInfo::set_public_id(std::string id) {
} }
// static. // static.
void DeviceInfo::CreateLocalDeviceInfo( void DeviceInfo::GetClientName(const GetClientNameCallback& callback) {
const std::string& guid, syncer::GetSessionName(content::BrowserThread::GetBlockingPool(), callback);
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);
} }
} // namespace browser_sync } // namespace browser_sync
...@@ -8,22 +8,20 @@ ...@@ -8,22 +8,20 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/callback.h"
#include "sync/protocol/sync.pb.h" #include "sync/protocol/sync.pb.h"
namespace base { namespace base {
class DictionaryValue; class DictionaryValue;
} }
namespace chrome {
class VersionInfo;
}
namespace browser_sync { namespace browser_sync {
// A class that holds information regarding the properties of a device. // A class that holds information regarding the properties of a device.
class DeviceInfo { class DeviceInfo {
public: public:
typedef base::Callback<void(const std::string&)> GetClientNameCallback;
DeviceInfo(const std::string& guid, DeviceInfo(const std::string& guid,
const std::string& client_name, const std::string& client_name,
const std::string& chrome_version, const std::string& chrome_version,
...@@ -46,7 +44,7 @@ class DeviceInfo { ...@@ -46,7 +44,7 @@ class DeviceInfo {
// The user agent is the combination of OS type, chrome version and which // The user agent is the combination of OS type, chrome version and which
// channel of chrome(stable or beta). For more information see // channel of chrome(stable or beta). For more information see
// |DeviceInfo::MakeUserAgentForSyncApi|. // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
const std::string& sync_user_agent() const; const std::string& sync_user_agent() const;
// Third party visible id for the device. See |public_id_| for more details. // Third party visible id for the device. See |public_id_| for more details.
...@@ -78,36 +76,10 @@ class DeviceInfo { ...@@ -78,36 +76,10 @@ class DeviceInfo {
// which extension APIs can expose to third party apps. // which extension APIs can expose to third party apps.
base::DictionaryValue* ToValue(); base::DictionaryValue* ToValue();
static sync_pb::SyncEnums::DeviceType GetLocalDeviceType();
// Creates a |DeviceInfo| object representing the local device and passes
// it as parameter to the callback.
static void CreateLocalDeviceInfo(
const std::string& guid,
const std::string& signin_scoped_device_id,
base::Callback<void(const DeviceInfo& local_info)> callback);
// Gets the local device name and passes it as a parameter to callback. // Gets the local device name and passes it as a parameter to callback.
static void GetClientName( static void GetClientName(const GetClientNameCallback& callback);
base::Callback<void(const std::string& local_info)> callback);
// Helper to construct a user agent string (ASCII) suitable for use by
// the syncapi for any HTTP communication. This string is used by the sync
// backend for classifying client types when calculating statistics.
static std::string MakeUserAgentForSyncApi(
const chrome::VersionInfo& version_info);
private: private:
static void GetClientNameContinuation(
base::Callback<void(const std::string& local_info)> callback,
const std::string& session_name);
static void 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);
const std::string guid_; const std::string guid_;
const std::string client_name_; const std::string client_name_;
......
...@@ -2,10 +2,59 @@ ...@@ -2,10 +2,59 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/bind.h"
#include "chrome/browser/sync/glue/local_device_info_provider_impl.h" #include "chrome/browser/sync/glue/local_device_info_provider_impl.h"
#include "chrome/common/chrome_version_info.h"
#include "ui/base/device_form_factor.h"
namespace browser_sync { namespace browser_sync {
namespace {
// 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";
}
}
#if defined(OS_ANDROID)
bool IsTabletUI() {
return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET;
}
#endif
sync_pb::SyncEnums::DeviceType 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
}
} // namespace
LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl() LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl()
: weak_factory_(this) { : weak_factory_(this) {
} }
...@@ -13,6 +62,46 @@ LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl() ...@@ -13,6 +62,46 @@ LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl()
LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() { LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() {
} }
// static.
std::string LocalDeviceInfoProviderImpl::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;
}
const DeviceInfo* const DeviceInfo*
LocalDeviceInfoProviderImpl::GetLocalDeviceInfo() const { LocalDeviceInfoProviderImpl::GetLocalDeviceInfo() const {
return local_device_info_.get(); return local_device_info_.get();
...@@ -33,25 +122,26 @@ void LocalDeviceInfoProviderImpl::Initialize( ...@@ -33,25 +122,26 @@ void LocalDeviceInfoProviderImpl::Initialize(
const std::string& cache_guid, const std::string& signin_scoped_device_id) { const std::string& cache_guid, const std::string& signin_scoped_device_id) {
DCHECK(!cache_guid.empty()); DCHECK(!cache_guid.empty());
cache_guid_ = cache_guid; cache_guid_ = cache_guid;
DeviceInfo::CreateLocalDeviceInfo(
cache_guid_, DeviceInfo::GetClientName(
signin_scoped_device_id,
base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation, base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr(),
cache_guid,
signin_scoped_device_id));
} }
void LocalDeviceInfoProviderImpl::InitializeContinuation( void LocalDeviceInfoProviderImpl::InitializeContinuation(
const DeviceInfo& local_info) { const std::string& guid,
// Copy constructor is disallowed in DeviceInfo, construct a new one from const std::string& signin_scoped_device_id,
// the fields passed in local_info. const std::string& session_name) {
local_device_info_.reset( chrome::VersionInfo version_info;
new DeviceInfo(
local_info.guid(), local_device_info_.reset(new DeviceInfo(guid,
local_info.client_name(), session_name,
local_info.chrome_version(), version_info.CreateVersionString(),
local_info.sync_user_agent(), MakeUserAgentForSyncApi(version_info),
local_info.device_type(), GetLocalDeviceType(),
local_info.signin_scoped_device_id())); signin_scoped_device_id));
// Notify observers. // Notify observers.
callback_list_.Notify(); callback_list_.Notify();
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "chrome/browser/sync/glue/device_info.h" #include "chrome/browser/sync/glue/device_info.h"
#include "chrome/browser/sync/glue/local_device_info_provider.h" #include "chrome/browser/sync/glue/local_device_info_provider.h"
namespace chrome {
class VersionInfo;
}
namespace browser_sync { namespace browser_sync {
class LocalDeviceInfoProviderImpl : public LocalDeviceInfoProvider { class LocalDeviceInfoProviderImpl : public LocalDeviceInfoProvider {
...@@ -25,8 +29,16 @@ class LocalDeviceInfoProviderImpl : public LocalDeviceInfoProvider { ...@@ -25,8 +29,16 @@ class LocalDeviceInfoProviderImpl : public LocalDeviceInfoProvider {
virtual scoped_ptr<Subscription> RegisterOnInitializedCallback( virtual scoped_ptr<Subscription> RegisterOnInitializedCallback(
const base::Closure& callback) OVERRIDE; const base::Closure& callback) OVERRIDE;
// Helper to construct a user agent string (ASCII) suitable for use by
// the syncapi for any HTTP communication. This string is used by the sync
// backend for classifying client types when calculating statistics.
static std::string MakeUserAgentForSyncApi(
const chrome::VersionInfo& version_info);
private: private:
void InitializeContinuation(const DeviceInfo& local_info); void InitializeContinuation(const std::string& guid,
const std::string& signin_scoped_device_id,
const std::string& session_name);
std::string cache_guid_; std::string cache_guid_;
scoped_ptr<DeviceInfo> local_device_info_; scoped_ptr<DeviceInfo> local_device_info_;
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "chrome/browser/sync/glue/local_device_info_provider_impl.h" #include "chrome/browser/sync/glue/local_device_info_provider_impl.h"
#include "chrome/common/chrome_version_info.h"
#include "sync/util/get_session_name.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync { namespace browser_sync {
...@@ -72,6 +75,13 @@ TEST_F(LocalDeviceInfoProviderTest, GetLocalDeviceInfo) { ...@@ -72,6 +75,13 @@ TEST_F(LocalDeviceInfoProviderTest, GetLocalDeviceInfo) {
EXPECT_EQ(std::string(kLocalDeviceGuid), local_device_info->guid()); EXPECT_EQ(std::string(kLocalDeviceGuid), local_device_info->guid());
EXPECT_EQ(std::string(kSigninScopedDeviceId), EXPECT_EQ(std::string(kSigninScopedDeviceId),
local_device_info->signin_scoped_device_id()); local_device_info->signin_scoped_device_id());
EXPECT_EQ(syncer::GetSessionNameSynchronouslyForTesting(),
local_device_info->client_name());
chrome::VersionInfo version_info;
EXPECT_EQ(browser_sync::LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi(
version_info),
local_device_info->sync_user_agent());
} }
TEST_F(LocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) { TEST_F(LocalDeviceInfoProviderTest, GetLocalSyncCacheGUID) {
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "chrome/browser/sync/glue/device_info.h"
#include "chrome/browser/sync/glue/invalidation_adapter.h" #include "chrome/browser/sync/glue/invalidation_adapter.h"
#include "chrome/browser/sync/glue/local_device_info_provider_impl.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h" #include "chrome/browser/sync/glue/sync_backend_registrar.h"
#include "chrome/common/chrome_version_info.h" #include "chrome/common/chrome_version_info.h"
#include "components/invalidation/invalidation_util.h" #include "components/invalidation/invalidation_util.h"
...@@ -405,7 +405,7 @@ void SyncBackendHostCore::DoInitialize( ...@@ -405,7 +405,7 @@ void SyncBackendHostCore::DoInitialize(
// building the user agent may block on some platforms. // building the user agent may block on some platforms.
chrome::VersionInfo version_info; chrome::VersionInfo version_info;
options->http_bridge_factory->Init( options->http_bridge_factory->Init(
DeviceInfo::MakeUserAgentForSyncApi(version_info)); LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi(version_info));
// Blow away the partial or corrupt sync data folder before doing any more // Blow away the partial or corrupt sync data folder before doing any more
// initialization, if necessary. // initialization, if necessary.
......
...@@ -122,7 +122,7 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing( ...@@ -122,7 +122,7 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
base_specifics->set_session_tag(current_machine_tag()); base_specifics->set_session_tag(current_machine_tag());
sync_pb::SessionHeader* header_s = base_specifics->mutable_header(); sync_pb::SessionHeader* header_s = base_specifics->mutable_header();
header_s->set_client_name(current_session_name_); header_s->set_client_name(current_session_name_);
header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); header_s->set_device_type(local_device_info->device_type());
syncer::SyncData data = syncer::SyncData::CreateLocalData( syncer::SyncData data = syncer::SyncData::CreateLocalData(
current_machine_tag(), current_session_name_, specifics); current_machine_tag(), current_session_name_, specifics);
new_changes.push_back(syncer::SyncChange( new_changes.push_back(syncer::SyncChange(
...@@ -158,7 +158,11 @@ void SessionsSyncManager::AssociateWindows( ...@@ -158,7 +158,11 @@ void SessionsSyncManager::AssociateWindows(
SyncedSession* current_session = session_tracker_.GetSession(local_tag); SyncedSession* current_session = session_tracker_.GetSession(local_tag);
current_session->modified_time = base::Time::Now(); current_session->modified_time = base::Time::Now();
header_s->set_client_name(current_session_name_); header_s->set_client_name(current_session_name_);
header_s->set_device_type(DeviceInfo::GetLocalDeviceType()); // SessionDataTypeController ensures that the local device info
// is available before activating this datatype.
DCHECK(local_device_);
const DeviceInfo* local_device_info = local_device_->GetLocalDeviceInfo();
header_s->set_device_type(local_device_info->device_type());
session_tracker_.ResetSessionTracking(local_tag); session_tracker_.ResetSessionTracking(local_tag);
std::set<SyncedWindowDelegate*> windows = std::set<SyncedWindowDelegate*> windows =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment