OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/navigation_url_loader_network_service.h" | 5 #include "content/browser/loader/navigation_url_loader_network_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
11 #include "content/browser/appcache/appcache_navigation_handle.h" | 11 #include "content/browser/appcache/appcache_navigation_handle.h" |
12 #include "content/browser/appcache/appcache_navigation_handle_core.h" | |
13 #include "content/browser/appcache/appcache_request_handler.h" | |
14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
15 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
16 #include "content/browser/frame_host/navigation_request_info.h" | 14 #include "content/browser/frame_host/navigation_request_info.h" |
17 #include "content/browser/loader/navigation_resource_handler.h" | 15 #include "content/browser/loader/navigation_resource_handler.h" |
18 #include "content/browser/loader/navigation_resource_throttle.h" | 16 #include "content/browser/loader/navigation_resource_throttle.h" |
19 #include "content/browser/loader/navigation_url_loader_delegate.h" | 17 #include "content/browser/loader/navigation_url_loader_delegate.h" |
20 #include "content/browser/resource_context_impl.h" | 18 #include "content/browser/resource_context_impl.h" |
21 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 19 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
22 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " | 20 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " |
23 #include "content/browser/service_worker/service_worker_request_handler.h" | 21 #include "content/browser/service_worker/service_worker_request_handler.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 url_loader_factory_ptr = | 84 url_loader_factory_ptr = |
87 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( | 85 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( |
88 *resource_request, resource_context, | 86 *resource_request, resource_context, |
89 service_worker_navigation_handle_core, blob_storage_context, | 87 service_worker_navigation_handle_core, blob_storage_context, |
90 request_info->begin_params.skip_service_worker, resource_type, | 88 request_info->begin_params.skip_service_worker, resource_type, |
91 request_info->begin_params.request_context_type, frame_type, | 89 request_info->begin_params.request_context_type, frame_type, |
92 request_info->are_ancestors_secure, | 90 request_info->are_ancestors_secure, |
93 request_info->common_params.post_data, web_contents_getter); | 91 request_info->common_params.post_data, web_contents_getter); |
94 } | 92 } |
95 | 93 |
96 // TODO(scottmg): We need to rework AppCache to have it return a | |
97 // URLLoaderFactoryPtr[Info] here. We should also try to have it return | |
98 // synchronously in as many cases as possible (especially when there's no | |
99 // AppCache) to simplify and speed the common case. | |
100 if (false /*appcache_handle_core*/) { | |
101 AppCacheRequestHandler::InitializeForNavigationNetworkService( | |
102 std::move(resource_request), resource_context, appcache_handle_core, | |
103 resource_type, | |
104 base::Callback<void( | |
105 mojom::URLLoaderFactoryPtrInfo, | |
106 std::unique_ptr<ResourceRequest>)>() /* TODO(ananta) */); | |
107 return; | |
108 } | |
109 | |
110 // If we haven't gotten one from the above, then use the one the UI thread | 94 // If we haven't gotten one from the above, then use the one the UI thread |
111 // gave us, or otherwise fallback to the default. | 95 // gave us, or otherwise fallback to the default. |
112 mojom::URLLoaderFactory* factory; | 96 mojom::URLLoaderFactory* factory; |
113 if (url_loader_factory_ptr) { | 97 if (url_loader_factory_ptr) { |
114 factory = url_loader_factory_ptr.get(); | 98 factory = url_loader_factory_ptr.get(); |
115 } else { | 99 } else { |
116 if (factory_from_ui.is_valid()) { | 100 if (factory_from_ui.is_valid()) { |
117 url_loader_factory_ptr.Bind(std::move(factory_from_ui)); | 101 url_loader_factory_ptr.Bind(std::move(factory_from_ui)); |
118 factory = url_loader_factory_ptr.get(); | 102 factory = url_loader_factory_ptr.get(); |
119 } else { | 103 } else { |
120 factory = url_loader_factory_getter->GetNetworkFactory()->get(); | 104 if (appcache_handle_core) { |
jam
2017/05/17 16:51:12
doesn't have to be here, but we should really only
ananta
2017/05/17 18:14:09
That is going to be touch tricky to do at the mome
ananta
2017/05/17 20:45:27
Scratch that. I added code in the AppCacheURLLoade
| |
105 factory = url_loader_factory_getter->GetAppCacheFactory()->get(); | |
kinuko
2017/05/17 16:54:30
So we almost always take this path after this patc
ananta
2017/05/17 18:14:09
Yes.
| |
106 } else { | |
107 factory = url_loader_factory_getter->GetNetworkFactory()->get(); | |
108 } | |
121 } | 109 } |
122 } | 110 } |
123 | 111 |
124 factory->CreateLoaderAndStart( | 112 factory->CreateLoaderAndStart( |
125 std::move(url_loader_request), 0 /* routing_id? */, 0 /* request_id? */, | 113 std::move(url_loader_request), 0 /* routing_id? */, 0 /* request_id? */, |
126 mojom::kURLLoadOptionSendSSLInfo, *resource_request, | 114 mojom::kURLLoadOptionSendSSLInfo, *resource_request, |
127 std::move(url_loader_client_to_pass)); | 115 std::move(url_loader_client_to_pass)); |
128 } | 116 } |
129 | 117 |
130 } // namespace | 118 } // namespace |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", | 269 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
282 this, "&NavigationURLLoaderNetworkService", this, | 270 this, "&NavigationURLLoaderNetworkService", this, |
283 "success", false); | 271 "success", false); |
284 | 272 |
285 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 273 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
286 completion_status.error_code); | 274 completion_status.error_code); |
287 } | 275 } |
288 } | 276 } |
289 | 277 |
290 } // namespace content | 278 } // namespace content |
OLD | NEW |