OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/loader/resource_requester_info.h" | 5 #include "content/browser/loader/resource_requester_info.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "content/browser/appcache/chrome_appcache_service.h" | 8 #include "content/browser/appcache/chrome_appcache_service.h" |
9 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 9 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
10 #include "content/browser/loader/resource_message_filter.h" | 10 #include "content/browser/loader/resource_message_filter.h" |
11 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
12 #include "content/public/browser/resource_context.h" | 12 #include "content/public/browser/resource_context.h" |
13 #include "content/public/common/browser_side_navigation_policy.h" | 13 #include "content/public/common/browser_side_navigation_policy.h" |
14 #include "storage/browser/fileapi/file_system_context.h" | 14 #include "storage/browser/fileapi/file_system_context.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 void GetContextsCallbackForNavigationPreload( | 20 void GetContextsCallbackForNavigationPreload( |
21 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, | 21 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, |
22 ResourceType resource_type, | 22 ResourceType resource_type, |
23 ResourceContext** resource_context_out, | 23 ResourceContext** resource_context_out, |
24 net::URLRequestContext** request_context_out) { | 24 net::URLRequestContext** request_context_out) { |
25 *resource_context_out = service_worker_context->resource_context(); | 25 *resource_context_out = service_worker_context->resource_context(); |
26 *request_context_out = | 26 *request_context_out = |
27 service_worker_context->resource_context()->GetRequestContext(); | 27 service_worker_context->resource_context()->GetRequestContext(); |
28 } | 28 } |
29 | |
30 } | 29 } |
31 | 30 |
32 ResourceRequesterInfo::ResourceRequesterInfo( | 31 ResourceRequesterInfo::ResourceRequesterInfo( |
33 RequesterType type, | 32 RequesterType type, |
34 int child_id, | 33 int child_id, |
35 ChromeAppCacheService* appcache_service, | 34 ChromeAppCacheService* appcache_service, |
36 ChromeBlobStorageContext* blob_storage_context, | 35 ChromeBlobStorageContext* blob_storage_context, |
37 storage::FileSystemContext* file_system_context, | 36 storage::FileSystemContext* file_system_context, |
38 ServiceWorkerContextWrapper* service_worker_context, | 37 ServiceWorkerContextWrapper* service_worker_context, |
39 const GetContextsCallback& get_contexts_callback) | 38 const GetContextsCallback& get_contexts_callback) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ResourceRequesterInfo::CreateForBrowserSideNavigation( | 95 ResourceRequesterInfo::CreateForBrowserSideNavigation( |
97 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { | 96 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
98 return base::WrapUnique(new ResourceRequesterInfo( | 97 return base::WrapUnique(new ResourceRequesterInfo( |
99 RequesterType::BROWSER_SIDE_NAVIGATION, -1, | 98 RequesterType::BROWSER_SIDE_NAVIGATION, -1, |
100 nullptr /* appcache_service */, nullptr /* blob_storage_context */, | 99 nullptr /* appcache_service */, nullptr /* blob_storage_context */, |
101 nullptr /* file_system_context */, service_worker_context.get(), | 100 nullptr /* file_system_context */, service_worker_context.get(), |
102 GetContextsCallback())); | 101 GetContextsCallback())); |
103 } | 102 } |
104 | 103 |
105 std::unique_ptr<ResourceRequesterInfo> | 104 std::unique_ptr<ResourceRequesterInfo> |
106 ResourceRequesterInfo::CreateForDownloadOrPageSave(int child_id) { | 105 ResourceRequesterInfo::CreateForDownloadOrPageSave( |
| 106 int child_id, |
| 107 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { |
107 return base::WrapUnique(new ResourceRequesterInfo( | 108 return base::WrapUnique(new ResourceRequesterInfo( |
108 RequesterType::DOWNLOAD_OR_PAGE_SAVE, child_id, | 109 RequesterType::DOWNLOAD_OR_PAGE_SAVE, child_id, |
109 nullptr /* appcache_service */, nullptr /* blob_storage_context */, | 110 nullptr /* appcache_service */, nullptr /* blob_storage_context */, |
110 nullptr /* file_system_context */, nullptr /*service_worker_context */, | 111 nullptr /* file_system_context */, service_worker_context.get(), |
111 GetContextsCallback())); | 112 GetContextsCallback())); |
112 } | 113 } |
113 | 114 |
114 std::unique_ptr<ResourceRequesterInfo> | 115 std::unique_ptr<ResourceRequesterInfo> |
115 ResourceRequesterInfo::CreateForNavigationPreload( | 116 ResourceRequesterInfo::CreateForNavigationPreload( |
116 const ResourceRequesterInfo& original_request_info) { | 117 const ResourceRequesterInfo& original_request_info) { |
117 if (IsBrowserSideNavigationEnabled()) | 118 if (IsBrowserSideNavigationEnabled()) |
118 DCHECK(original_request_info.IsBrowserSideNavigation()); | 119 DCHECK(original_request_info.IsBrowserSideNavigation()); |
119 else | 120 else |
120 DCHECK(original_request_info.IsRenderer()); | 121 DCHECK(original_request_info.IsRenderer()); |
121 DCHECK(original_request_info.service_worker_context()); | 122 DCHECK(original_request_info.service_worker_context()); |
122 | 123 |
123 return base::WrapUnique(new ResourceRequesterInfo( | 124 return base::WrapUnique(new ResourceRequesterInfo( |
124 RequesterType::NAVIGATION_PRELOAD, -1, nullptr /* appcache_service */, | 125 RequesterType::NAVIGATION_PRELOAD, -1, nullptr /* appcache_service */, |
125 nullptr /* blob_storage_context */, nullptr /* file_system_context */, | 126 nullptr /* blob_storage_context */, nullptr /* file_system_context */, |
126 original_request_info.service_worker_context(), | 127 original_request_info.service_worker_context(), |
127 base::Bind(&GetContextsCallbackForNavigationPreload, | 128 base::Bind(&GetContextsCallbackForNavigationPreload, |
128 scoped_refptr<ServiceWorkerContextWrapper>( | 129 scoped_refptr<ServiceWorkerContextWrapper>( |
129 original_request_info.service_worker_context())))); | 130 original_request_info.service_worker_context())))); |
130 } | 131 } |
131 | 132 |
132 } // namespace content | 133 } // namespace content |
OLD | NEW |