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}
diff --git a/chrome/browser/sync/glue/device_info.h b/chrome/browser/sync/glue/device_info.h
index a46e650..3faf668 100644
--- a/chrome/browser/sync/glue/device_info.h
+++ b/chrome/browser/sync/glue/device_info.h
@@ -8,22 +8,20 @@
#include <string>
#include "base/basictypes.h"
-#include "base/bind.h"
+#include "base/callback.h"
#include "sync/protocol/sync.pb.h"
namespace base {
class DictionaryValue;
}
-namespace chrome {
-class VersionInfo;
-}
-
namespace browser_sync {
// A class that holds information regarding the properties of a device.
class DeviceInfo {
public:
+ typedef base::Callback<void(const std::string&)> GetClientNameCallback;
+
DeviceInfo(const std::string& guid,
const std::string& client_name,
const std::string& chrome_version,
@@ -46,7 +44,7 @@
// The user agent is the combination of OS type, chrome version and which
// channel of chrome(stable or beta). For more information see
- // |DeviceInfo::MakeUserAgentForSyncApi|.
+ // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
const std::string& sync_user_agent() const;
// Third party visible id for the device. See |public_id_| for more details.
@@ -78,36 +76,10 @@
// which extension APIs can expose to third party apps.
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.
- static void GetClientName(
- 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);
+ static void GetClientName(const GetClientNameCallback& callback);
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 client_name_;