Chromium Code Reviews| Index: content/browser/resource_context_impl.cc |
| diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc |
| index e7aa29b9570d5706018be8032db33507b15392f9..adaa057163845a0ce2abadb33746dd40e7e62046 100644 |
| --- a/content/browser/resource_context_impl.cc |
| +++ b/content/browser/resource_context_impl.cc |
| @@ -6,9 +6,13 @@ |
| #include <stdint.h> |
| +#include <string> |
|
jam
2016/06/14 16:20:33
nit: no need to add, this is in the header
Guido Urdaneta
2016/06/14 17:30:57
Done.
|
| + |
| +#include "base/base64.h" |
| #include "base/bind.h" |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/rand_util.h" |
| #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| #include "content/browser/loader/resource_request_info_impl.h" |
| @@ -23,22 +27,13 @@ using base::UserDataAdapter; |
| namespace content { |
| -namespace { |
| - |
| // Key names on ResourceContext. |
| const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; |
| const char kStreamContextKeyName[] = "content_stream_context"; |
| const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend"; |
| -// Used by the default implementation of GetMediaDeviceIDSalt, below. |
| -std::string ReturnEmptySalt() { |
| - return std::string(); |
| -} |
| - |
| -} // namespace |
| - |
| - |
| -ResourceContext::ResourceContext() { |
| +ResourceContext::ResourceContext() |
| + : media_device_id_salt_(CreateRandomMediaDeviceIDSalt()) { |
| ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get(); |
| if (rdhi) { |
| BrowserThread::PostTask( |
| @@ -59,8 +54,8 @@ ResourceContext::~ResourceContext() { |
| DetachUserDataThread(); |
| } |
| -ResourceContext::SaltCallback ResourceContext::GetMediaDeviceIDSalt() { |
| - return base::Bind(&ReturnEmptySalt); |
| +const std::string ResourceContext::GetMediaDeviceIDSalt() { |
| + return media_device_id_salt_; |
| } |
| std::unique_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() { |
| @@ -76,6 +71,14 @@ void ResourceContext::CreateKeygenHandler( |
| new net::KeygenHandler(key_size_in_bits, challenge_string, url))); |
| } |
| +// static |
| +std::string ResourceContext::CreateRandomMediaDeviceIDSalt() { |
| + std::string salt; |
| + base::Base64Encode(base::RandBytesAsString(16), &salt); |
| + DCHECK(!salt.empty()); |
| + return salt; |
| +} |
| + |
| ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( |
| const ResourceContext* resource_context) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |