Commit cdc47716 authored by Himanshu Jaju's avatar Himanshu Jaju Committed by Commit Bot

Rename session_name to personalized_device_name.

This change would be followed up by transport mode name changes.

Bug: 1009454
Change-Id: I53041f711e157df69ef03218539032229cb9fc64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845391Reviewed-by: default avatarRamya Nagarajan <ramyan@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarAlex Chau <alexchau@chromium.org>
Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704107}
parent f1adddf6
......@@ -122,14 +122,15 @@ std::unique_ptr<syncer::EntityData> CopyToEntityData(
base::Optional<syncer::ModelError> ParseLocalEntriesOnBackendSequence(
base::Time now,
std::map<std::string, std::unique_ptr<SendTabToSelfEntry>>* entries,
std::string* local_session_name,
std::string* local_personalizable_device_name,
std::unique_ptr<ModelTypeStore::RecordList> record_list) {
DCHECK(entries);
DCHECK(entries->empty());
DCHECK(local_session_name);
DCHECK(local_personalizable_device_name);
DCHECK(record_list);
*local_session_name = syncer::GetSessionNameBlocking();
*local_personalizable_device_name =
syncer::GetPersonalizableDeviceNameBlocking();
for (const syncer::ModelTypeStore::Record& r : *record_list) {
auto specifics = std::make_unique<SendTabToSelfLocal>();
......
......@@ -131,17 +131,17 @@ std::unique_ptr<DeviceInfoSpecifics> MakeLocalDeviceSpecifics(
// parameter is first for binding purposes.
base::Optional<ModelError> ParseSpecificsOnBackendSequence(
ClientIdToSpecifics* all_data,
std::string* local_session_name,
std::string* local_personalizable_device_name,
std::unique_ptr<ModelTypeStore::RecordList> record_list) {
DCHECK(all_data);
DCHECK(all_data->empty());
DCHECK(local_session_name);
DCHECK(local_personalizable_device_name);
DCHECK(record_list);
// For convenience, we get the session name (i.e. local device name) here,
// For convenience, we get the user personalized local device name here,
// since we're running on the backend sequence, because the function is
// blocking.
*local_session_name = GetSessionNameBlocking();
*local_personalizable_device_name = GetPersonalizableDeviceNameBlocking();
for (const Record& r : *record_list) {
std::unique_ptr<DeviceInfoSpecifics> specifics =
......@@ -210,7 +210,7 @@ base::Optional<ModelError> DeviceInfoSyncBridge::MergeSyncData(
DCHECK(!local_cache_guid_.empty());
local_device_info_provider_->Initialize(local_cache_guid_,
local_session_name_);
local_personalizable_device_name_);
std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
for (const auto& change : entity_data) {
......@@ -402,24 +402,25 @@ void DeviceInfoSyncBridge::OnStoreCreated(
auto all_data = std::make_unique<ClientIdToSpecifics>();
ClientIdToSpecifics* all_data_copy = all_data.get();
auto local_session_name = std::make_unique<std::string>();
std::string* local_session_name_copy = local_session_name.get();
auto local_personalizable_device_name = std::make_unique<std::string>();
std::string* local_personalizable_device_name_copy =
local_personalizable_device_name.get();
store_->ReadAllDataAndPreprocess(
base::BindOnce(&ParseSpecificsOnBackendSequence,
base::Unretained(all_data_copy),
base::Unretained(local_session_name_copy)),
base::Unretained(local_personalizable_device_name_copy)),
base::BindOnce(&DeviceInfoSyncBridge::OnReadAllData,
weak_ptr_factory_.GetWeakPtr(), std::move(all_data),
std::move(local_session_name)));
std::move(local_personalizable_device_name)));
}
void DeviceInfoSyncBridge::OnReadAllData(
std::unique_ptr<ClientIdToSpecifics> all_data,
std::unique_ptr<std::string> local_session_name,
std::unique_ptr<std::string> local_personalizable_device_name,
const base::Optional<syncer::ModelError>& error) {
DCHECK(all_data);
DCHECK(local_session_name);
DCHECK(local_personalizable_device_name);
if (error) {
change_processor()->ReportError(*error);
......@@ -427,7 +428,8 @@ void DeviceInfoSyncBridge::OnReadAllData(
}
all_data_ = std::move(*all_data);
local_session_name_ = std::move(*local_session_name);
local_personalizable_device_name_ =
std::move(*local_personalizable_device_name);
store_->ReadAllMetadata(
base::BindOnce(&DeviceInfoSyncBridge::OnReadAllMetadata,
......@@ -479,7 +481,7 @@ void DeviceInfoSyncBridge::OnReadAllMetadata(
// initialize the provider immediately.
local_cache_guid_ = local_cache_guid_in_metadata;
local_device_info_provider_->Initialize(local_cache_guid_,
local_session_name_);
local_personalizable_device_name_);
// This probably isn't strictly needed, but in case the cache_guid has changed
// we save the new one to prefs.
......
......@@ -140,7 +140,7 @@ class DeviceInfoSyncBridge : public ModelTypeSyncBridge,
local_device_info_provider_;
std::string local_cache_guid_;
std::string local_session_name_;
std::string local_personalizable_device_name_;
ClientIdToSpecifics all_data_;
// Registered observers, not owned.
......
......@@ -14,7 +14,7 @@
namespace syncer {
// Declared here but defined in platform-specific files.
std::string GetSessionNameInternal();
std::string GetPersonalizableDeviceNameInternal();
sync_pb::SyncEnums::DeviceType GetLocalDeviceType() {
#if defined(OS_CHROMEOS)
......@@ -34,17 +34,17 @@ sync_pb::SyncEnums::DeviceType GetLocalDeviceType() {
#endif
}
std::string GetSessionNameBlocking() {
std::string GetPersonalizableDeviceNameBlocking() {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
std::string session_name = GetSessionNameInternal();
std::string device_name = GetPersonalizableDeviceNameInternal();
if (session_name == "Unknown" || session_name.empty()) {
session_name = base::SysInfo::OperatingSystemName();
if (device_name == "Unknown" || device_name.empty()) {
device_name = base::SysInfo::OperatingSystemName();
}
DCHECK(base::IsStringUTF8(session_name));
return session_name;
DCHECK(base::IsStringUTF8(device_name));
return device_name;
}
} // namespace syncer
......@@ -13,7 +13,7 @@ namespace syncer {
sync_pb::SyncEnums::DeviceType GetLocalDeviceType();
std::string GetSessionNameBlocking();
std::string GetPersonalizableDeviceNameBlocking();
} // namespace syncer
......
......@@ -8,7 +8,7 @@
namespace syncer {
std::string GetSessionNameInternal() {
std::string GetPersonalizableDeviceNameInternal() {
base::android::BuildInfo* android_build_info =
base::android::BuildInfo::GetInstance();
return android_build_info->model();
......
......@@ -10,7 +10,7 @@
namespace syncer {
std::string GetSessionNameInternal() {
std::string GetPersonalizableDeviceNameInternal() {
return base::SysNSStringToUTF8([[UIDevice currentDevice] name]);
}
......
......@@ -15,7 +15,7 @@
namespace syncer {
std::string GetSessionNameInternal() {
std::string GetPersonalizableDeviceNameInternal() {
#if defined(OS_CHROMEOS)
switch (chromeos::GetDeviceType()) {
case chromeos::DeviceType::kChromebase:
......
......@@ -18,7 +18,7 @@ namespace syncer {
// possible. See http://www.cocoadev.com/index.pl?MacintoshModels for
// an example list of models. If an error occurs trying to read the
// model, this simply returns "Unknown".
std::string GetSessionNameInternal() {
std::string GetPersonalizableDeviceNameInternal() {
// Do not use NSHost currentHost, as it's very slow. http://crbug.com/138570
SCDynamicStoreContext context = {0, NULL, NULL, NULL};
base::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate(
......
......@@ -18,30 +18,30 @@
namespace syncer {
namespace {
// Call GetSessionNameBlocking and make sure its return
// Call GetPersonalizableDeviceNameBlocking and make sure its return
// value looks sane.
TEST(GetSessionNameTest, GetSessionNameBlocking) {
const std::string& session_name = GetSessionNameBlocking();
TEST(GetSessionNameTest, GetPersonalizableDeviceNameBlocking) {
const std::string& session_name = GetPersonalizableDeviceNameBlocking();
EXPECT_FALSE(session_name.empty());
}
#if defined(OS_CHROMEOS)
// Call GetSessionNameBlocking on ChromeOS where the board type
// is CHROMEBOOK and make sure the return value is "Chromebook".
TEST(GetSessionNameTest, GetSessionNameBlockingChromebook) {
// Call GetPersonalizableDeviceNameBlocking on ChromeOS where the
// board type is CHROMEBOOK and make sure the return value is "Chromebook".
TEST(GetSessionNameTest, GetPersonalizableDeviceNameBlockingChromebook) {
const char* kLsbRelease = "DEVICETYPE=CHROMEBOOK\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
const std::string& session_name = GetSessionNameBlocking();
const std::string& session_name = GetPersonalizableDeviceNameBlocking();
EXPECT_EQ("Chromebook", session_name);
}
// Call GetSessionNameBlocking on ChromeOS where the board type
// is a CHROMEBOX and make sure the return value is "Chromebox".
TEST(GetSessionNameTest, GetSessionNameBlockingChromebox) {
// Call GetPersonalizableDeviceNameBlocking on ChromeOS where the
// board type is a CHROMEBOX and make sure the return value is "Chromebox".
TEST(GetSessionNameTest, GetPersonalizableDeviceNameBlockingChromebox) {
const char* kLsbRelease = "DEVICETYPE=CHROMEBOX\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
const std::string& session_name = GetSessionNameBlocking();
const std::string& session_name = GetPersonalizableDeviceNameBlocking();
EXPECT_EQ("Chromebox", session_name);
}
......
......@@ -12,7 +12,7 @@
namespace syncer {
std::string GetSessionNameInternal() {
std::string GetPersonalizableDeviceNameInternal() {
wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
DWORD size = base::size(computer_name);
if (::GetComputerNameW(computer_name, &size)) {
......
......@@ -121,7 +121,7 @@ base::Optional<syncer::ModelError> ParseInitialDataOnBackendSequence(
(*initial_data)[storage_key] = std::move(specifics);
}
*session_name = syncer::GetSessionNameBlocking();
*session_name = syncer::GetPersonalizableDeviceNameBlocking();
return base::nullopt;
}
......
......@@ -196,7 +196,7 @@ TEST_F(SessionStoreOpenTest, ShouldCreateStore) {
completion.Wait();
ASSERT_THAT(completion.GetResult(), NotNull());
EXPECT_THAT(completion.GetResult()->local_session_info().client_name,
Eq(syncer::GetSessionNameBlocking()));
Eq(syncer::GetPersonalizableDeviceNameBlocking()));
EXPECT_THAT(session_sync_prefs_.GetSyncSessionsGUID(),
Eq(std::string("session_sync") + kCacheGuid));
}
......
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