| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/resource_context_impl.h" | 5 #include "content/browser/resource_context_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 16 #include "content/browser/loader/resource_request_info_impl.h" | 16 #include "content/browser/loader/resource_request_info_impl.h" |
| 17 #include "content/browser/streams/stream_context.h" | 17 #include "content/browser/streams/stream_context.h" |
| 18 #include "content/browser/webui/url_data_manager_backend.h" | 18 #include "content/browser/webui/url_data_manager_backend.h" |
| 19 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "net/base/keygen_handler.h" | |
| 22 | 21 |
| 23 using base::UserDataAdapter; | 22 using base::UserDataAdapter; |
| 24 | 23 |
| 25 namespace content { | 24 namespace content { |
| 26 | 25 |
| 27 // Key names on ResourceContext. | 26 // Key names on ResourceContext. |
| 28 const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; | 27 const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; |
| 29 const char kStreamContextKeyName[] = "content_stream_context"; | 28 const char kStreamContextKeyName[] = "content_stream_context"; |
| 30 const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend"; | 29 const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend"; |
| 31 | 30 |
| 32 ResourceContext::ResourceContext() | 31 ResourceContext::ResourceContext() |
| 33 : media_device_id_salt_(CreateRandomMediaDeviceIDSalt()) { | 32 : media_device_id_salt_(CreateRandomMediaDeviceIDSalt()) { |
| 34 } | 33 } |
| 35 | 34 |
| 36 ResourceContext::~ResourceContext() { | 35 ResourceContext::~ResourceContext() { |
| 37 if (ResourceDispatcherHostImpl::Get()) | 36 if (ResourceDispatcherHostImpl::Get()) |
| 38 ResourceDispatcherHostImpl::Get()->CancelRequestsForContext(this); | 37 ResourceDispatcherHostImpl::Get()->CancelRequestsForContext(this); |
| 39 } | 38 } |
| 40 | 39 |
| 41 std::string ResourceContext::GetMediaDeviceIDSalt() { | 40 std::string ResourceContext::GetMediaDeviceIDSalt() { |
| 42 return media_device_id_salt_; | 41 return media_device_id_salt_; |
| 43 } | 42 } |
| 44 | 43 |
| 45 void ResourceContext::CreateKeygenHandler( | |
| 46 uint32_t key_size_in_bits, | |
| 47 const std::string& challenge_string, | |
| 48 const GURL& url, | |
| 49 const base::Callback<void(std::unique_ptr<net::KeygenHandler>)>& callback) { | |
| 50 callback.Run(base::MakeUnique<net::KeygenHandler>(key_size_in_bits, | |
| 51 challenge_string, url)); | |
| 52 } | |
| 53 | |
| 54 // static | 44 // static |
| 55 std::string ResourceContext::CreateRandomMediaDeviceIDSalt() { | 45 std::string ResourceContext::CreateRandomMediaDeviceIDSalt() { |
| 56 std::string salt; | 46 std::string salt; |
| 57 base::Base64Encode(base::RandBytesAsString(16), &salt); | 47 base::Base64Encode(base::RandBytesAsString(16), &salt); |
| 58 DCHECK(!salt.empty()); | 48 DCHECK(!salt.empty()); |
| 59 return salt; | 49 return salt; |
| 60 } | 50 } |
| 61 | 51 |
| 62 ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( | 52 ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( |
| 63 const ResourceContext* resource_context) { | 53 const ResourceContext* resource_context) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 94 | 84 |
| 95 resource_context->SetUserData( | 85 resource_context->SetUserData( |
| 96 kStreamContextKeyName, | 86 kStreamContextKeyName, |
| 97 new UserDataAdapter<StreamContext>( | 87 new UserDataAdapter<StreamContext>( |
| 98 StreamContext::GetFor(browser_context))); | 88 StreamContext::GetFor(browser_context))); |
| 99 | 89 |
| 100 resource_context->DetachUserDataThread(); | 90 resource_context->DetachUserDataThread(); |
| 101 } | 91 } |
| 102 | 92 |
| 103 } // namespace content | 93 } // namespace content |
| OLD | NEW |