Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: content/browser/loader/navigation_url_loader_network_service.cc

Issue 2874163004: Add support in the network service for different contexts. (Closed)
Patch Set: fixes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
13 #include "content/browser/frame_host/frame_tree_node.h" 13 #include "content/browser/frame_host/frame_tree_node.h"
14 #include "content/browser/frame_host/navigation_request_info.h" 14 #include "content/browser/frame_host/navigation_request_info.h"
15 #include "content/browser/loader/navigation_resource_handler.h" 15 #include "content/browser/loader/navigation_resource_handler.h"
16 #include "content/browser/loader/navigation_resource_throttle.h" 16 #include "content/browser/loader/navigation_resource_throttle.h"
17 #include "content/browser/loader/navigation_url_loader_delegate.h" 17 #include "content/browser/loader/navigation_url_loader_delegate.h"
18 #include "content/browser/storage_partition_impl.h"
18 #include "content/browser/webui/url_data_manager_backend.h" 19 #include "content/browser/webui/url_data_manager_backend.h"
19 #include "content/browser/webui/web_ui_url_loader_factory.h" 20 #include "content/browser/webui/web_ui_url_loader_factory.h"
21 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/global_request_id.h" 23 #include "content/public/browser/global_request_id.h"
22 #include "content/public/browser/navigation_data.h" 24 #include "content/public/browser/navigation_data.h"
23 #include "content/public/browser/navigation_ui_data.h" 25 #include "content/public/browser/navigation_ui_data.h"
24 #include "content/public/browser/ssl_status.h" 26 #include "content/public/browser/ssl_status.h"
25 #include "content/public/browser/stream_handle.h" 27 #include "content/public/browser/stream_handle.h"
26 #include "content/public/common/referrer.h" 28 #include "content/public/common/referrer.h"
27 #include "content/public/common/service_manager_connection.h"
28 #include "content/public/common/service_names.mojom.h"
29 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
30 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
31 #include "net/url_request/url_request_context.h" 31 #include "net/url_request/url_request_context.h"
32 #include "services/service_manager/public/cpp/connector.h"
33 32
34 namespace content { 33 namespace content {
35 34
36 namespace { 35 namespace {
37 36
38 static base::LazyInstance<mojom::URLLoaderFactoryPtr>::Leaky 37 static base::LazyInstance<mojom::URLLoaderFactoryPtr>::Leaky
39 g_url_loader_factory = LAZY_INSTANCE_INITIALIZER; 38 g_url_loader_factory = LAZY_INSTANCE_INITIALIZER;
40 39
41 // This function is called on the IO thread for POST/PUT requests for 40 // This function is called on the IO thread for POST/PUT requests for
42 // attaching blob information to the request body. 41 // attaching blob information to the request body.
(...skipping 17 matching lines...) Expand all
60 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( 59 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
61 ResourceContext* resource_context, 60 ResourceContext* resource_context,
62 StoragePartition* storage_partition, 61 StoragePartition* storage_partition,
63 std::unique_ptr<NavigationRequestInfo> request_info, 62 std::unique_ptr<NavigationRequestInfo> request_info,
64 std::unique_ptr<NavigationUIData> navigation_ui_data, 63 std::unique_ptr<NavigationUIData> navigation_ui_data,
65 ServiceWorkerNavigationHandle* service_worker_handle, 64 ServiceWorkerNavigationHandle* service_worker_handle,
66 AppCacheNavigationHandle* appcache_handle, 65 AppCacheNavigationHandle* appcache_handle,
67 NavigationURLLoaderDelegate* delegate) 66 NavigationURLLoaderDelegate* delegate)
68 : delegate_(delegate), 67 : delegate_(delegate),
69 binding_(this), 68 binding_(this),
69 storage_partition_(static_cast<StoragePartitionImpl*>(storage_partition)),
70 request_info_(std::move(request_info)), 70 request_info_(std::move(request_info)),
71 weak_factory_(this) { 71 weak_factory_(this) {
72 DCHECK_CURRENTLY_ON(BrowserThread::UI); 72 DCHECK_CURRENTLY_ON(BrowserThread::UI);
73 73
74 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( 74 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1(
75 "navigation", "Navigation timeToResponseStarted", this, 75 "navigation", "Navigation timeToResponseStarted", this,
76 request_info_->common_params.navigation_start, "FrameTreeNode id", 76 request_info_->common_params.navigation_start, "FrameTreeNode id",
77 request_info_->frame_tree_node_id); 77 request_info_->frame_tree_node_id);
78 78
79 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. 79 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 0 /* routing_id? */, 0 /* request_id? */, 231 0 /* routing_id? */, 0 /* request_id? */,
232 mojom::kURLLoadOptionSendSSLInfo, *request, 232 mojom::kURLLoadOptionSendSSLInfo, *request,
233 std::move(url_loader_client_ptr_to_pass)); 233 std::move(url_loader_client_ptr_to_pass));
234 } 234 }
235 235
236 mojom::URLLoaderFactory* 236 mojom::URLLoaderFactory*
237 NavigationURLLoaderNetworkService::GetURLLoaderFactory() { 237 NavigationURLLoaderNetworkService::GetURLLoaderFactory() {
238 // TODO(yzshen): We will need the ability to customize the factory per frame 238 // TODO(yzshen): We will need the ability to customize the factory per frame
239 // e.g., for appcache or service worker. 239 // e.g., for appcache or service worker.
240 if (!g_url_loader_factory.Get()) { 240 if (!g_url_loader_factory.Get()) {
241 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( 241 storage_partition_->network_context()->CreateURLLoaderFactory(
242 mojom::kNetworkServiceName, &g_url_loader_factory.Get()); 242 MakeRequest(&g_url_loader_factory.Get()), 0);
243 } 243 }
244 244
245 return g_url_loader_factory.Get().get(); 245 return g_url_loader_factory.Get().get();
246 } 246 }
247 247
248 } // namespace content 248 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698