X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fprefs%2Fpref_hash_calculator.cc;h=331ce36485fe6a9150935b05f2b69b3a66066d88;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=2f36018a11fd129e298cbf7a8f2fe219bf2f8054;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/prefs/pref_hash_calculator.cc b/src/chrome/browser/prefs/pref_hash_calculator.cc index 2f36018..331ce36 100644 --- a/src/chrome/browser/prefs/pref_hash_calculator.cc +++ b/src/chrome/browser/prefs/pref_hash_calculator.cc @@ -11,9 +11,7 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" -#include "base/threading/thread_restrictions.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/pref_hash_calculator_helper.h" #include "crypto/hmac.h" namespace { @@ -82,11 +80,13 @@ 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()) return std::string(); - return StringToLowerASCII( + return base::StringToLowerASCII( GetDigestString(original_device_id, "PrefMetricsService")); } @@ -95,18 +95,8 @@ std::string GenerateDeviceIdLikePrefMetricsServiceDid( PrefHashCalculator::PrefHashCalculator(const std::string& seed, const std::string& device_id) : seed_(seed), - device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)), - raw_device_id_(device_id), - get_legacy_device_id_callback_(base::Bind(&GetLegacyDeviceId)) {} - -PrefHashCalculator::PrefHashCalculator( - const std::string& seed, - const std::string& device_id, - const GetLegacyDeviceIdCallback& get_legacy_device_id_callback) - : seed_(seed), - device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)), - raw_device_id_(device_id), - get_legacy_device_id_callback_(get_legacy_device_id_callback) {} + device_id_(device_id), + legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) {} PrefHashCalculator::~PrefHashCalculator() {} @@ -126,31 +116,9 @@ PrefHashCalculator::ValidationResult PrefHashCalculator::Validate( return VALID; } if (VerifyDigestString(seed_, - GetMessage(RetrieveLegacyDeviceId(), path, - value_as_string), + GetMessage(legacy_device_id_, path, value_as_string), digest_string)) { return VALID_SECURE_LEGACY; } - if (VerifyDigestString(seed_, value_as_string, digest_string)) - return VALID_WEAK_LEGACY; return INVALID; } - -std::string PrefHashCalculator::RetrieveLegacyDeviceId() const { - if (!legacy_device_id_instance_) { - // Allow IO on this thread to retrieve the legacy device ID. The result of - // this operation is stored in |legacy_device_id_instance_| and will thus - // only happen at most once per PrefHashCalculator. This is not ideal, but - // this value is required synchronously to be able to continue loading prefs - // for this profile. This profile should then be migrated to a modern device - // ID and subsequent loads of this profile shouldn't need to run this code - // ever again. - // TODO(gab): Remove this when the legacy device ID (M33) becomes - // irrelevant. - base::ThreadRestrictions::ScopedAllowIO allow_io; - legacy_device_id_instance_.reset( - new std::string(GenerateDeviceIdLikePrefMetricsServiceDid( - get_legacy_device_id_callback_.Run(raw_device_id_)))); - } - return *legacy_device_id_instance_; -}