| 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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 // Key names on ResourceContext. | 28 // Key names on ResourceContext. |
| 29 const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; | 29 const char kBlobStorageContextKeyName[] = "content_blob_storage_context"; |
| 30 const char kStreamContextKeyName[] = "content_stream_context"; | 30 const char kStreamContextKeyName[] = "content_stream_context"; |
| 31 const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend"; | 31 const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend"; |
| 32 | 32 |
| 33 ResourceContext::ResourceContext() | 33 ResourceContext::ResourceContext() |
| 34 : media_device_id_salt_(CreateRandomMediaDeviceIDSalt()) { | 34 : media_device_id_salt_(CreateRandomMediaDeviceIDSalt()) { |
| 35 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get(); | |
| 36 if (rdhi) { | |
| 37 BrowserThread::PostTask( | |
| 38 BrowserThread::IO, FROM_HERE, | |
| 39 base::Bind(&ResourceDispatcherHostImpl::AddResourceContext, | |
| 40 base::Unretained(rdhi), this)); | |
| 41 } | |
| 42 } | 35 } |
| 43 | 36 |
| 44 ResourceContext::~ResourceContext() { | 37 ResourceContext::~ResourceContext() { |
| 45 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get(); | 38 if (ResourceDispatcherHostImpl::Get()) |
| 46 if (rdhi) { | 39 ResourceDispatcherHostImpl::Get()->CancelRequestsForContext(this); |
| 47 rdhi->CancelRequestsForContext(this); | |
| 48 rdhi->RemoveResourceContext(this); | |
| 49 } | |
| 50 } | 40 } |
| 51 | 41 |
| 52 std::string ResourceContext::GetMediaDeviceIDSalt() { | 42 std::string ResourceContext::GetMediaDeviceIDSalt() { |
| 53 return media_device_id_salt_; | 43 return media_device_id_salt_; |
| 54 } | 44 } |
| 55 | 45 |
| 56 std::unique_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() { | 46 std::unique_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() { |
| 57 return std::unique_ptr<net::ClientCertStore>(); | 47 return std::unique_ptr<net::ClientCertStore>(); |
| 58 } | 48 } |
| 59 | 49 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 99 |
| 110 resource_context->SetUserData( | 100 resource_context->SetUserData( |
| 111 kStreamContextKeyName, | 101 kStreamContextKeyName, |
| 112 new UserDataAdapter<StreamContext>( | 102 new UserDataAdapter<StreamContext>( |
| 113 StreamContext::GetFor(browser_context))); | 103 StreamContext::GetFor(browser_context))); |
| 114 | 104 |
| 115 resource_context->DetachUserDataThread(); | 105 resource_context->DetachUserDataThread(); |
| 116 } | 106 } |
| 117 | 107 |
| 118 } // namespace content | 108 } // namespace content |
| OLD | NEW |