Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/prefs/pref_hash_calculator.cc

Issue 231673002: Allow IO for the computation of PrefHashCalculator::legacy_device_id_instance_. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prefs/pref_hash_calculator.h" 5 #include "chrome/browser/prefs/pref_hash_calculator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/threading/thread_restrictions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/prefs/tracked/pref_hash_calculator_helper.h" 16 #include "chrome/browser/prefs/tracked/pref_hash_calculator_helper.h"
16 #include "crypto/hmac.h" 17 #include "crypto/hmac.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Calculates an HMAC of |message| using |key|, encoded as a hexadecimal string. 21 // Calculates an HMAC of |message| using |key|, encoded as a hexadecimal string.
21 std::string GetDigestString(const std::string& key, 22 std::string GetDigestString(const std::string& key,
22 const std::string& message) { 23 const std::string& message) {
23 crypto::HMAC hmac(crypto::HMAC::SHA256); 24 crypto::HMAC hmac(crypto::HMAC::SHA256);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 digest_string)) { 131 digest_string)) {
131 return VALID_SECURE_LEGACY; 132 return VALID_SECURE_LEGACY;
132 } 133 }
133 if (VerifyDigestString(seed_, value_as_string, digest_string)) 134 if (VerifyDigestString(seed_, value_as_string, digest_string))
134 return VALID_WEAK_LEGACY; 135 return VALID_WEAK_LEGACY;
135 return INVALID; 136 return INVALID;
136 } 137 }
137 138
138 std::string PrefHashCalculator::RetrieveLegacyDeviceId() const { 139 std::string PrefHashCalculator::RetrieveLegacyDeviceId() const {
139 if (!legacy_device_id_instance_) { 140 if (!legacy_device_id_instance_) {
141 // Allow IO on this thread to retrieve the legacy device ID. The result of
142 // this operation is stored in |legacy_device_id_instance_| and will thus
143 // only happen at most once per PrefHashCalculator. This is not ideal, but
144 // this value is required synchronously to be able to continue loading prefs
145 // for this profile. This profile should then be migrated to a modern device
146 // ID and subsequent loads of this profile shouldn't need to run this code
147 // ever again.
148 // TODO(gab): Remove this when the legacy device ID (M33) becomes
149 // irrelevant.
150 base::ThreadRestrictions::ScopedAllowIO allow_io;
140 legacy_device_id_instance_.reset( 151 legacy_device_id_instance_.reset(
141 new std::string(GenerateDeviceIdLikePrefMetricsServiceDid( 152 new std::string(GenerateDeviceIdLikePrefMetricsServiceDid(
142 get_legacy_device_id_callback_.Run(raw_device_id_)))); 153 get_legacy_device_id_callback_.Run(raw_device_id_))));
143 } 154 }
144 return *legacy_device_id_instance_; 155 return *legacy_device_id_instance_;
145 } 156 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698