diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-29 17:35:33 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-29 17:35:33 +0000 |
commit | 02a63db901e14b550815e592016c27fa395cb7b6 (patch) | |
tree | 759edc3bbcfad3f23d7d183bf044e3da1f005f35 /chrome/browser | |
parent | 4bcf155e3abceea60b8b9daa88846545212071e1 (diff) | |
download | chromium_src-02a63db901e14b550815e592016c27fa395cb7b6.zip chromium_src-02a63db901e14b550815e592016c27fa395cb7b6.tar.gz chromium_src-02a63db901e14b550815e592016c27fa395cb7b6.tar.bz2 |
Migrate away from the PrefMetricsService-based device ID in PrefHashCalculator.
This means that Settings.TrackedPreferenceUnchanged will be bucketed as Settings.TrackedPreferenceMigratedLegacyDeviceId for some time while this migration occurs, no others UMA stat should be affected.
BUG=396707
Review URL: https://codereview.chromium.org/414833003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/prefs/pref_hash_calculator.cc | 10 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_hash_calculator.h | 1 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_hash_calculator_unittest.cc | 20 |
3 files changed, 20 insertions, 11 deletions
diff --git a/chrome/browser/prefs/pref_hash_calculator.cc b/chrome/browser/prefs/pref_hash_calculator.cc index 5f3855e..0afbfa5 100644 --- a/chrome/browser/prefs/pref_hash_calculator.cc +++ b/chrome/browser/prefs/pref_hash_calculator.cc @@ -80,6 +80,8 @@ std::string GetMessage(const std::string& device_id, // Generates a device ID based on the input device ID. The derived device ID has // no useful properties beyond those of the input device ID except that it is // consistent with previous implementations. +// TODO(gab): Remove this once UMA reports for +// Settings.TrackedPreferenceMigratedLegacyDeviceId become insignificant. std::string GenerateDeviceIdLikePrefMetricsServiceDid( const std::string& original_device_id) { if (original_device_id.empty()) @@ -93,7 +95,8 @@ std::string GenerateDeviceIdLikePrefMetricsServiceDid( PrefHashCalculator::PrefHashCalculator(const std::string& seed, const std::string& device_id) : seed_(seed), - device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) {} + device_id_(device_id), + legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) {} PrefHashCalculator::~PrefHashCalculator() {} @@ -112,5 +115,10 @@ PrefHashCalculator::ValidationResult PrefHashCalculator::Validate( digest_string)) { return VALID; } + if (VerifyDigestString(seed_, + GetMessage(legacy_device_id_, path, value_as_string), + digest_string)) { + return VALID_SECURE_LEGACY; + } return INVALID; } diff --git a/chrome/browser/prefs/pref_hash_calculator.h b/chrome/browser/prefs/pref_hash_calculator.h index a354a42..f1a88ef 100644 --- a/chrome/browser/prefs/pref_hash_calculator.h +++ b/chrome/browser/prefs/pref_hash_calculator.h @@ -44,6 +44,7 @@ class PrefHashCalculator { private: const std::string seed_; const std::string device_id_; + const std::string legacy_device_id_; DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator); }; diff --git a/chrome/browser/prefs/pref_hash_calculator_unittest.cc b/chrome/browser/prefs/pref_hash_calculator_unittest.cc index 4d5fe7d..3306a70 100644 --- a/chrome/browser/prefs/pref_hash_calculator_unittest.cc +++ b/chrome/browser/prefs/pref_hash_calculator_unittest.cc @@ -124,43 +124,43 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { // Test every value type independently. Intentionally omits TYPE_BINARY which // isn't even allowed in JSONWriter's input. static const char kExpectedNullValue[] = - "C2871D0AC76176E39948C50A9A562B863E610FDA90C675A6A8AD16B4DC4F53DC"; + "82A9F3BBC7F9FF84C76B033C854E79EEB162783FA7B3E99FF9372FA8E12C44F7"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", null_value.get(), kExpectedNullValue)); static const char kExpectedBooleanValue[] = - "A326E2F405CFE05D08289CDADD9DB4F529592F0945A8CE204289E4C930D8AA43"; + "A520D8F43EA307B0063736DC9358C330539D0A29417580514C8B9862632C4CCC"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", bool_value.get(), kExpectedBooleanValue)); static const char kExpectedIntegerValue[] = - "4B69938F802A2A26D69467F3E1E4A474F6323C64EFC54DBDB4A5708A7D005042"; + "8D60DA1F10BF5AA29819D2D66D7CCEF9AABC5DA93C11A0D2BD21078D63D83682"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", int_value.get(), kExpectedIntegerValue)); static const char kExpectedDoubleValue[] = - "1734C9C745B9C92D896B9A710994BF1B56D55BFB0F00C207EC995152AF02F08F"; + "C9D94772516125BEEDAE68C109D44BC529E719EE020614E894CC7FB4098C545D"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", double_value.get(), kExpectedDoubleValue)); static const char kExpectedStringValue[] = - "154D15522C856AA944BFA5A9E3FFB46925BF2B95A10199564651CA1C13E98433"; + "05ACCBD3B05C45C36CD06190F63EC577112311929D8380E26E5F13182EB68318"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", string_value.get(), kExpectedStringValue)); static const char kExpectedDictValue[] = - "597CECCBF930AF1FFABAC6AF3851C062867C134B4D5A06BDB3B03B988A182CBB"; + "7A84DCC710D796C771F789A4DA82C952095AA956B6F1667EE42D0A19ECAA3C4A"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", dict_value.get(), kExpectedDictValue)); static const char kExpectedListValue[] = - "4E2CC0A9B8DF8C5049C53E8B139007792EC6295239545BC99BBF9CDE8A2F5E30"; + "8D5A25972DF5AE20D041C780E7CA54E40F614AD53513A0724EE8D62D4F992740"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", list_value.get(), kExpectedListValue)); @@ -175,13 +175,13 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { everything.Set("list", list_value.release()); everything.Set("dict", dict_value.release()); static const char kExpectedEverythingValue[] = - "5A9D15E4D2FA909007EDE6A18605735E3EB712E2EDE83D6735CE5DD96A5AFBAA"; + "B97D09BE7005693574DCBDD03D8D9E44FB51F4008B73FB56A49A9FA671A1999B"; EXPECT_EQ(PrefHashCalculator::VALID, PrefHashCalculator(kSeed, kDeviceId).Validate( "pref.path", &everything, kExpectedEverythingValue)); } -TEST(PrefHashCalculatorTest, TestCompatibilityWithPrefMetricsService) { +TEST(PrefHashCalculatorTest, TestCompatibilityWithLegacyPrefMetricsServiceId) { static const char kSeed[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, @@ -200,7 +200,7 @@ TEST(PrefHashCalculatorTest, TestCompatibilityWithPrefMetricsService) { base::ListValue startup_urls; startup_urls.Set(0, new base::StringValue("http://www.chromium.org/")); - EXPECT_EQ(PrefHashCalculator::VALID, + EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY, PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId). Validate("session.startup_urls", &startup_urls, kExpectedValue)); } |