OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/renderer_host/pepper/device_id_fetcher.h" | 5 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/task_scheduler/post_task.h" | 10 #include "base/task_scheduler/post_task.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 crypto::RandBytes(salt_bytes, arraysize(salt_bytes)); | 120 crypto::RandBytes(salt_bytes, arraysize(salt_bytes)); |
121 // Since it will be stored in a string pref, convert it to hex. | 121 // Since it will be stored in a string pref, convert it to hex. |
122 salt = base::HexEncode(salt_bytes, arraysize(salt_bytes)); | 122 salt = base::HexEncode(salt_bytes, arraysize(salt_bytes)); |
123 profile->GetPrefs()->SetString(prefs::kDRMSalt, salt); | 123 profile->GetPrefs()->SetString(prefs::kDRMSalt, salt); |
124 } | 124 } |
125 | 125 |
126 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
127 // Try the legacy path first for ChromeOS. We pass the new salt in as well | 127 // Try the legacy path first for ChromeOS. We pass the new salt in as well |
128 // in case the legacy id doesn't exist. | 128 // in case the legacy id doesn't exist. |
129 base::PostTaskWithTraits(FROM_HERE, | 129 base::PostTaskWithTraits(FROM_HERE, |
130 base::TaskTraits().MayBlock().WithPriority( | 130 {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
131 base::TaskPriority::BACKGROUND), | |
132 base::Bind(&DeviceIDFetcher::LegacyComputeAsync, | 131 base::Bind(&DeviceIDFetcher::LegacyComputeAsync, |
133 this, profile->GetPath(), salt)); | 132 this, profile->GetPath(), salt)); |
134 #else | 133 #else |
135 // Get the machine ID and call ComputeOnUIThread with salt + machine_id. | 134 // Get the machine ID and call ComputeOnUIThread with salt + machine_id. |
136 GetMachineIDAsync( | 135 GetMachineIDAsync( |
137 base::Bind(&DeviceIDFetcher::ComputeOnUIThread, this, salt)); | 136 base::Bind(&DeviceIDFetcher::ComputeOnUIThread, this, salt)); |
138 #endif | 137 #endif |
139 } | 138 } |
140 | 139 |
141 void DeviceIDFetcher::ComputeOnUIThread(const std::string& salt, | 140 void DeviceIDFetcher::ComputeOnUIThread(const std::string& salt, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 BrowserThread::IO, | 206 BrowserThread::IO, |
208 FROM_HERE, | 207 FROM_HERE, |
209 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); | 208 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); |
210 return; | 209 return; |
211 } | 210 } |
212 in_progress_ = false; | 211 in_progress_ = false; |
213 callback_.Run(id, result); | 212 callback_.Run(id, result); |
214 } | 213 } |
215 | 214 |
216 } // namespace chrome | 215 } // namespace chrome |
OLD | NEW |