diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 10:43:31 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 10:43:31 +0000 |
commit | d0c1412146f356ca61f1dd02f47e87a9498d018c (patch) | |
tree | 38bc466cef0989d52130efe94e3f46f435849d7b /chrome/browser/chromeos/settings | |
parent | aa455ba14c262bb41b602a7798c1e0a865613e88 (diff) | |
download | chromium_src-d0c1412146f356ca61f1dd02f47e87a9498d018c.zip chromium_src-d0c1412146f356ca61f1dd02f47e87a9498d018c.tar.gz chromium_src-d0c1412146f356ca61f1dd02f47e87a9498d018c.tar.bz2 |
Fix queued writes in DeviceSettingsProvider.
The check for pending operations was bad, which would lead to pending changes accumulating. Props to pastarmovj for debugging this and proposing the fix.
BUG=chromium:149983
TEST=unit tests, see bug report.
Review URL: https://codereview.chromium.org/10950032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/settings')
-rw-r--r-- | chrome/browser/chromeos/settings/device_settings_provider.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/settings/device_settings_provider_unittest.cc | 23 |
2 files changed, 24 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/settings/device_settings_provider.cc b/chrome/browser/chromeos/settings/device_settings_provider.cc index 1a6b56b..1a8034b 100644 --- a/chrome/browser/chromeos/settings/device_settings_provider.cc +++ b/chrome/browser/chromeos/settings/device_settings_provider.cc @@ -658,11 +658,8 @@ void DeviceSettingsProvider::UpdateAndProceedStoring() { UpdateFromService(); // Trigger the next change if necessary. - if (trusted_status_ == TRUSTED && - !store_callback_factory_.HasWeakPtrs() && - !pending_changes_.empty()) { + if (trusted_status_ == TRUSTED && !pending_changes_.empty()) SetInPolicy(); - } } bool DeviceSettingsProvider::UpdateFromService() { diff --git a/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc b/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc index 3835748..72c697e 100644 --- a/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc +++ b/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc @@ -204,6 +204,29 @@ TEST_F(DeviceSettingsProviderTest, SetPrefSucceed) { EXPECT_TRUE(bool_value); } +TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { + owner_key_util_->SetPrivateKey(policy_.signing_key()); + device_settings_service_.SetUsername(policy_.policy_data().username()); + device_settings_test_helper_.Flush(); + + EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); + + base::StringValue value1("beta"); + provider_->Set(kReleaseChannel, value1); + base::StringValue value2("dev"); + provider_->Set(kReleaseChannel, value2); + + // Let the changes propagate through the system. + device_settings_test_helper_.set_policy_blob(std::string()); + device_settings_test_helper_.Flush(); + + // Verify the second change has been applied. + const base::Value* saved_value = provider_->Get(kReleaseChannel); + EXPECT_TRUE(value2.Equals(saved_value)); + + Mock::VerifyAndClearExpectations(this); +} + TEST_F(DeviceSettingsProviderTest, PolicyRetrievalFailedBadSignature) { owner_key_util_->SetPublicKeyFromPrivateKey(policy_.signing_key()); policy_.policy().set_policy_data_signature("bad signature"); |