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

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

Issue 2893233002: Network traffic annotation added to URLLoaderImpl. (Closed)
Patch Set: Comment addressed, Merged. Created 3 years, 6 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/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"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/global_request_id.h" 31 #include "content/public/browser/global_request_id.h"
32 #include "content/public/browser/navigation_data.h" 32 #include "content/public/browser/navigation_data.h"
33 #include "content/public/browser/navigation_ui_data.h" 33 #include "content/public/browser/navigation_ui_data.h"
34 #include "content/public/browser/ssl_status.h" 34 #include "content/public/browser/ssl_status.h"
35 #include "content/public/browser/stream_handle.h" 35 #include "content/public/browser/stream_handle.h"
36 #include "content/public/common/referrer.h" 36 #include "content/public/common/referrer.h"
37 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
38 #include "mojo/public/cpp/bindings/strong_binding.h" 38 #include "mojo/public/cpp/bindings/strong_binding.h"
39 #include "net/base/load_flags.h" 39 #include "net/base/load_flags.h"
40 #include "net/traffic_annotation/network_traffic_annotation.h"
40 #include "net/url_request/url_request_context.h" 41 #include "net/url_request/url_request_context.h"
41 42
42 namespace content { 43 namespace content {
43 44
44 namespace { 45 namespace {
45 46
46 // Request ID for browser initiated requests. We start at -2 on the same lines 47 // Request ID for browser initiated requests. We start at -2 on the same lines
47 // as ResourceDispatcherHostImpl. 48 // as ResourceDispatcherHostImpl.
48 int g_next_request_id = -2; 49 int g_next_request_id = -2;
49 50
50 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) { 51 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) {
51 DCHECK_CURRENTLY_ON(BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
52 FrameTreeNode* frame_tree_node = 53 FrameTreeNode* frame_tree_node =
53 FrameTreeNode::GloballyFindByID(frame_tree_node_id); 54 FrameTreeNode::GloballyFindByID(frame_tree_node_id);
54 if (!frame_tree_node) 55 if (!frame_tree_node)
55 return nullptr; 56 return nullptr;
56 57
57 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); 58 return WebContentsImpl::FromFrameTreeNode(frame_tree_node);
58 } 59 }
59 60
60 class AssociatedURLLoaderWrapper final : public mojom::URLLoader { 61 class AssociatedURLLoaderWrapper final : public mojom::URLLoader {
61 public: 62 public:
62 static void CreateLoaderAndStart(mojom::URLLoaderFactory* factory, 63 static void CreateLoaderAndStart(
63 mojom::URLLoaderRequest request, 64 mojom::URLLoaderFactory* factory,
64 uint32_t options, 65 mojom::URLLoaderRequest request,
65 const ResourceRequest& resource_request, 66 uint32_t options,
66 mojom::URLLoaderClientPtr client) { 67 const ResourceRequest& resource_request,
68 mojom::URLLoaderClientPtr client,
69 const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
67 mojom::URLLoaderAssociatedPtr associated_ptr; 70 mojom::URLLoaderAssociatedPtr associated_ptr;
68 mojom::URLLoaderAssociatedRequest associated_request = 71 mojom::URLLoaderAssociatedRequest associated_request =
69 mojo::MakeRequest(&associated_ptr); 72 mojo::MakeRequest(&associated_ptr);
70 factory->CreateLoaderAndStart(std::move(associated_request), 73 factory->CreateLoaderAndStart(
71 0 /* routing_id */, 0 /* request_id */, 74 std::move(associated_request), 0 /* routing_id */, 0 /* request_id */,
72 options, resource_request, std::move(client)); 75 options, resource_request, std::move(client), traffic_annotation);
73 mojo::MakeStrongBinding( 76 mojo::MakeStrongBinding(
74 base::MakeUnique<AssociatedURLLoaderWrapper>(std::move(associated_ptr)), 77 base::MakeUnique<AssociatedURLLoaderWrapper>(std::move(associated_ptr)),
75 std::move(request)); 78 std::move(request));
76 } 79 }
77 80
78 explicit AssociatedURLLoaderWrapper( 81 explicit AssociatedURLLoaderWrapper(
79 mojom::URLLoaderAssociatedPtr associated_ptr) 82 mojom::URLLoaderAssociatedPtr associated_ptr)
80 : associated_ptr_(std::move(associated_ptr)) {} 83 : associated_ptr_(std::move(associated_ptr)) {}
81 ~AssociatedURLLoaderWrapper() override {} 84 ~AssociatedURLLoaderWrapper() override {}
82 85
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 138 }
136 139
137 // Requests to WebUI scheme won't get redirected to/from other schemes 140 // Requests to WebUI scheme won't get redirected to/from other schemes
138 // or be intercepted, so we just let it go here. 141 // or be intercepted, so we just let it go here.
139 if (factory_for_webui.is_valid()) { 142 if (factory_for_webui.is_valid()) {
140 mojom::URLLoaderFactoryPtr factory_ptr; 143 mojom::URLLoaderFactoryPtr factory_ptr;
141 factory_ptr.Bind(std::move(factory_for_webui)); 144 factory_ptr.Bind(std::move(factory_for_webui));
142 AssociatedURLLoaderWrapper::CreateLoaderAndStart( 145 AssociatedURLLoaderWrapper::CreateLoaderAndStart(
143 factory_ptr.get(), std::move(url_loader_request), 146 factory_ptr.get(), std::move(url_loader_request),
144 mojom::kURLLoadOptionSendSSLInfo, *resource_request_, 147 mojom::kURLLoadOptionSendSSLInfo, *resource_request_,
145 std::move(url_loader_client_ptr_)); 148 std::move(url_loader_client_ptr_),
149 net::MutableNetworkTrafficAnnotationTag(NO_TRAFFIC_ANNOTATION_YET));
146 return; 150 return;
147 } 151 }
148 152
149 DCHECK(handlers_.empty()); 153 DCHECK(handlers_.empty());
150 if (service_worker_navigation_handle_core) { 154 if (service_worker_navigation_handle_core) {
151 RequestContextFrameType frame_type = 155 RequestContextFrameType frame_type =
152 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL 156 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL
153 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; 157 : REQUEST_CONTEXT_FRAME_TYPE_NESTED;
154 158
155 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext( 159 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 mojom::URLLoaderFactory* factory = nullptr; 211 mojom::URLLoaderFactory* factory = nullptr;
208 DCHECK_EQ(handlers_.size(), handler_index_); 212 DCHECK_EQ(handlers_.size(), handler_index_);
209 if (resource_request_->url.SchemeIs(url::kBlobScheme)) { 213 if (resource_request_->url.SchemeIs(url::kBlobScheme)) {
210 factory = url_loader_factory_getter_->GetBlobFactory()->get(); 214 factory = url_loader_factory_getter_->GetBlobFactory()->get();
211 } else { 215 } else {
212 factory = url_loader_factory_getter_->GetNetworkFactory()->get(); 216 factory = url_loader_factory_getter_->GetNetworkFactory()->get();
213 } 217 }
214 AssociatedURLLoaderWrapper::CreateLoaderAndStart( 218 AssociatedURLLoaderWrapper::CreateLoaderAndStart(
215 factory, std::move(url_loader_request_), 219 factory, std::move(url_loader_request_),
216 mojom::kURLLoadOptionSendSSLInfo, *resource_request_, 220 mojom::kURLLoadOptionSendSSLInfo, *resource_request_,
217 std::move(url_loader_client_ptr_)); 221 std::move(url_loader_client_ptr_),
222 net::MutableNetworkTrafficAnnotationTag(NO_TRAFFIC_ANNOTATION_YET));
218 } 223 }
219 224
220 private: 225 private:
221 std::vector<std::unique_ptr<URLLoaderRequestHandler>> handlers_; 226 std::vector<std::unique_ptr<URLLoaderRequestHandler>> handlers_;
222 size_t handler_index_ = 0; 227 size_t handler_index_ = 0;
223 228
224 std::unique_ptr<ResourceRequest> resource_request_; 229 std::unique_ptr<ResourceRequest> resource_request_;
225 ResourceContext* resource_context_; 230 ResourceContext* resource_context_;
226 231
227 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter_; 232 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter_;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", 399 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted",
395 this, "&NavigationURLLoaderNetworkService", this, 400 this, "&NavigationURLLoaderNetworkService", this,
396 "success", false); 401 "success", false);
397 402
398 delegate_->OnRequestFailed(completion_status.exists_in_cache, 403 delegate_->OnRequestFailed(completion_status.exists_in_cache,
399 completion_status.error_code); 404 completion_status.error_code);
400 } 405 }
401 } 406 }
402 407
403 } // namespace content 408 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler_unittest.cc ('k') | content/browser/loader/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698