OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/loader/resource_requester_info.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "content/browser/appcache/chrome_appcache_service.h" |
| 10 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "storage/browser/fileapi/file_system_context.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 ResourceRequesterInfo::ResourceRequesterInfo( |
| 18 RequesterType type, |
| 19 int child_id, |
| 20 ChromeAppCacheService* appcache_service, |
| 21 ChromeBlobStorageContext* blob_storage_context, |
| 22 storage::FileSystemContext* file_system_context, |
| 23 ServiceWorkerContextWrapper* service_worker_context, |
| 24 const GetContextsCallback& get_contexts_callback) |
| 25 : type_(type), |
| 26 child_id_(child_id), |
| 27 appcache_service_(appcache_service), |
| 28 blob_storage_context_(blob_storage_context), |
| 29 file_system_context_(file_system_context), |
| 30 service_worker_context_(service_worker_context), |
| 31 get_contexts_callback_(get_contexts_callback) {} |
| 32 |
| 33 ResourceRequesterInfo::~ResourceRequesterInfo() {} |
| 34 |
| 35 void ResourceRequesterInfo::set_filter( |
| 36 base::WeakPtr<ResourceMessageFilter> filter) { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 38 DCHECK_EQ(RequesterType::RENDERER, type_); |
| 39 filter_ = filter; |
| 40 } |
| 41 |
| 42 void ResourceRequesterInfo::GetContexts( |
| 43 ResourceType resource_type, |
| 44 ResourceContext** resource_context, |
| 45 net::URLRequestContext** request_context) const { |
| 46 get_contexts_callback_.Run(resource_type, resource_context, request_context); |
| 47 } |
| 48 |
| 49 scoped_refptr<ResourceRequesterInfo> ResourceRequesterInfo::CreateForRenderer( |
| 50 int child_id, |
| 51 ChromeAppCacheService* appcache_service, |
| 52 ChromeBlobStorageContext* blob_storage_context, |
| 53 storage::FileSystemContext* file_system_context, |
| 54 ServiceWorkerContextWrapper* service_worker_context, |
| 55 const GetContextsCallback& get_contexts_callback) { |
| 56 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo( |
| 57 RequesterType::RENDERER, child_id, appcache_service, blob_storage_context, |
| 58 file_system_context, service_worker_context, get_contexts_callback)); |
| 59 } |
| 60 |
| 61 scoped_refptr<ResourceRequesterInfo> |
| 62 ResourceRequesterInfo::CreateForRendererTesting(int child_id) { |
| 63 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo( |
| 64 RequesterType::RENDERER, child_id, nullptr /* appcache_service */, |
| 65 nullptr /* blob_storage_context */, nullptr /* file_system_context */, |
| 66 nullptr /*service_worker_context */, GetContextsCallback())); |
| 67 } |
| 68 |
| 69 scoped_refptr<ResourceRequesterInfo> |
| 70 ResourceRequesterInfo::CreateForBrowserSideNavigation( |
| 71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
| 72 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo( |
| 73 RequesterType::BROWSER_SIDE_NAVIGATION, -1, |
| 74 nullptr /* appcache_service */, nullptr /* blob_storage_context */, |
| 75 nullptr /* file_system_context */, service_worker_context.get(), |
| 76 GetContextsCallback())); |
| 77 } |
| 78 |
| 79 scoped_refptr<ResourceRequesterInfo> |
| 80 ResourceRequesterInfo::CreateForDownloadOrPageSave(int child_id) { |
| 81 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo( |
| 82 RequesterType::DOWNLOAD_OR_PAGE_SAVE, child_id, |
| 83 nullptr /* appcache_service */, nullptr /* blob_storage_context */, |
| 84 nullptr /* file_system_context */, nullptr /*service_worker_context */, |
| 85 GetContextsCallback())); |
| 86 } |
| 87 |
| 88 } // namespace content |
OLD | NEW |