Skip to content

Commit

Permalink
Remove unused device_last_updated from SharingSyncPreference
Browse files Browse the repository at this point in the history
- device_last_updated is unused after https://crrev.com/c/1742158, but
  still causing prefs::kSharingSyncedDevices to update on every reboot

Bug: 1006153
Change-Id: I62e86791a58e8c5ca63ae9127895ecb4b813b1d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835578
Commit-Queue: Alex Chau <alexchau@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702029}
  • Loading branch information
Alex Chau authored and Commit Bot committed Oct 2, 2019
1 parent 02b8b8c commit be9e81d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
13 changes: 3 additions & 10 deletions chrome/browser/sharing/sharing_sync_preference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const char kDeviceFcmToken[] = "device_fcm_token";
const char kDeviceP256dh[] = "device_p256dh";
const char kDeviceAuthSecret[] = "device_auth_secret";
const char kDeviceCapabilities[] = "device_capabilities";
const char kDeviceLastUpdated[] = "device_last_updated";

const char kRegistrationAuthorizedEntity[] = "registration_authorized_entity";
const char kRegistrationFcmToken[] = "registration_fcm_token";
Expand Down Expand Up @@ -162,16 +161,12 @@ SharingSyncPreference::GetSyncedDevice(const std::string& guid) const {
void SharingSyncPreference::SetSyncDevice(const std::string& guid,
const Device& device) {
DictionaryPrefUpdate update(prefs_, prefs::kSharingSyncedDevices);
update->SetKey(guid, DeviceToValue(device, base::Time::Now()));
update->SetKey(guid, DeviceToValue(device));
}

void SharingSyncPreference::RemoveDevice(const std::string& guid) {
DictionaryPrefUpdate update(prefs_, prefs::kSharingSyncedDevices);
// Clear all values of device with |guid| by setting its value to an empty
// entry that only contains a timestamp so other devices can merge it.
base::Value cleared(base::Value::Type::DICTIONARY);
cleared.SetKey(kDeviceLastUpdated, base::CreateTimeValue(base::Time::Now()));
update->SetKey(guid, std::move(cleared));
update->RemoveKey(guid);
}

base::Optional<SharingSyncPreference::FCMRegistration>
Expand Down Expand Up @@ -226,8 +221,7 @@ void SharingSyncPreference::ClearFCMRegistration() {
}

// static
base::Value SharingSyncPreference::DeviceToValue(const Device& device,
base::Time timestamp) {
base::Value SharingSyncPreference::DeviceToValue(const Device& device) {
std::string base64_p256dh, base64_auth_secret;
base::Base64Encode(device.p256dh, &base64_p256dh);
base::Base64Encode(device.auth_secret, &base64_auth_secret);
Expand All @@ -243,7 +237,6 @@ base::Value SharingSyncPreference::DeviceToValue(const Device& device,
result.SetStringKey(kDeviceP256dh, base64_p256dh);
result.SetStringKey(kDeviceAuthSecret, base64_auth_secret);
result.SetIntKey(kDeviceCapabilities, capabilities);
result.SetKey(kDeviceLastUpdated, base::CreateTimeValue(timestamp));
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/sharing/sharing_sync_preference.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SharingSyncPreference {
private:
friend class SharingSyncPreferenceTest;

static base::Value DeviceToValue(const Device& device, base::Time timestamp);
static base::Value DeviceToValue(const Device& device);

static base::Optional<Device> ValueToDevice(const base::Value& value);

Expand Down
7 changes: 0 additions & 7 deletions chrome/browser/sharing/sharing_sync_preference_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ class SharingSyncPreferenceTest : public testing::Test {
kDeviceAuthToken, kClickToCallEnabled));
}

static base::Value CreateRandomDevice(base::Time timestamp) {
return SharingSyncPreference::DeviceToValue(
{base::GenerateGUID(), kDeviceP256dh, kDeviceAuthToken,
kClickToCallEnabled},
timestamp);
}

sync_preferences::TestingPrefServiceSyncable prefs_;
SharingSyncPreference sharing_sync_preference_;
};
Expand Down

0 comments on commit be9e81d

Please sign in to comment.