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

Side by Side Diff: net/base/network_delegate.cc

Issue 1834273002: Add TRACE_EVENT macros to net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments. Created 4 years, 8 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
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | net/base/network_quality_estimator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/base/network_delegate.h" 5 #include "net/base/network_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/profiler/scoped_tracker.h" 8 #include "base/profiler/scoped_tracker.h"
9 #include "base/trace_event/trace_event.h"
9 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 #include "net/proxy/proxy_info.h" 12 #include "net/proxy/proxy_info.h"
12 #include "net/url_request/url_request.h" 13 #include "net/url_request/url_request.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 int NetworkDelegate::NotifyBeforeURLRequest( 17 int NetworkDelegate::NotifyBeforeURLRequest(
17 URLRequest* request, const CompletionCallback& callback, 18 URLRequest* request, const CompletionCallback& callback,
18 GURL* new_url) { 19 GURL* new_url) {
20 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
21 "NetworkDelegate::NotifyBeforeURLRequest");
19 DCHECK(CalledOnValidThread()); 22 DCHECK(CalledOnValidThread());
20 DCHECK(request); 23 DCHECK(request);
21 DCHECK(!callback.is_null()); 24 DCHECK(!callback.is_null());
22 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 25 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
23 tracked_objects::ScopedTracker tracking_profile( 26 tracked_objects::ScopedTracker tracking_profile(
24 FROM_HERE_WITH_EXPLICIT_FUNCTION( 27 FROM_HERE_WITH_EXPLICIT_FUNCTION(
25 "475753 NetworkDelegate::OnBeforeURLRequest")); 28 "475753 NetworkDelegate::OnBeforeURLRequest"));
26 return OnBeforeURLRequest(request, callback, new_url); 29 return OnBeforeURLRequest(request, callback, new_url);
27 } 30 }
28 31
29 int NetworkDelegate::NotifyBeforeSendHeaders( 32 int NetworkDelegate::NotifyBeforeSendHeaders(
30 URLRequest* request, const CompletionCallback& callback, 33 URLRequest* request, const CompletionCallback& callback,
31 HttpRequestHeaders* headers) { 34 HttpRequestHeaders* headers) {
35 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
36 "NetworkDelegate::NotifyBeforeSendHeaders");
32 DCHECK(CalledOnValidThread()); 37 DCHECK(CalledOnValidThread());
33 DCHECK(headers); 38 DCHECK(headers);
34 DCHECK(!callback.is_null()); 39 DCHECK(!callback.is_null());
35 return OnBeforeSendHeaders(request, callback, headers); 40 return OnBeforeSendHeaders(request, callback, headers);
36 } 41 }
37 42
38 void NetworkDelegate::NotifyBeforeSendProxyHeaders( 43 void NetworkDelegate::NotifyBeforeSendProxyHeaders(
39 URLRequest* request, 44 URLRequest* request,
40 const ProxyInfo& proxy_info, 45 const ProxyInfo& proxy_info,
41 HttpRequestHeaders* headers) { 46 HttpRequestHeaders* headers) {
42 DCHECK(CalledOnValidThread()); 47 DCHECK(CalledOnValidThread());
43 DCHECK(headers); 48 DCHECK(headers);
44 OnBeforeSendProxyHeaders(request, proxy_info, headers); 49 OnBeforeSendProxyHeaders(request, proxy_info, headers);
45 } 50 }
46 51
47 void NetworkDelegate::NotifySendHeaders(URLRequest* request, 52 void NetworkDelegate::NotifySendHeaders(URLRequest* request,
48 const HttpRequestHeaders& headers) { 53 const HttpRequestHeaders& headers) {
54 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
55 "NetworkDelegate::NotifySendHeaders");
49 DCHECK(CalledOnValidThread()); 56 DCHECK(CalledOnValidThread());
50 OnSendHeaders(request, headers); 57 OnSendHeaders(request, headers);
51 } 58 }
52 59
53 int NetworkDelegate::NotifyHeadersReceived( 60 int NetworkDelegate::NotifyHeadersReceived(
54 URLRequest* request, 61 URLRequest* request,
55 const CompletionCallback& callback, 62 const CompletionCallback& callback,
56 const HttpResponseHeaders* original_response_headers, 63 const HttpResponseHeaders* original_response_headers,
57 scoped_refptr<HttpResponseHeaders>* override_response_headers, 64 scoped_refptr<HttpResponseHeaders>* override_response_headers,
58 GURL* allowed_unsafe_redirect_url) { 65 GURL* allowed_unsafe_redirect_url) {
66 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
67 "NetworkDelegate::NotifyHeadersReceived");
59 DCHECK(CalledOnValidThread()); 68 DCHECK(CalledOnValidThread());
60 DCHECK(original_response_headers); 69 DCHECK(original_response_headers);
61 DCHECK(!callback.is_null()); 70 DCHECK(!callback.is_null());
62 return OnHeadersReceived(request, 71 return OnHeadersReceived(request,
63 callback, 72 callback,
64 original_response_headers, 73 original_response_headers,
65 override_response_headers, 74 override_response_headers,
66 allowed_unsafe_redirect_url); 75 allowed_unsafe_redirect_url);
67 } 76 }
68 77
69 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) { 78 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
70 DCHECK(CalledOnValidThread()); 79 DCHECK(CalledOnValidThread());
71 DCHECK(request); 80 DCHECK(request);
72 OnResponseStarted(request); 81 OnResponseStarted(request);
73 } 82 }
74 83
75 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, 84 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request,
76 int64_t bytes_received) { 85 int64_t bytes_received) {
86 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
87 "NetworkDelegate::NotifyNetworkBytesReceived");
77 DCHECK(CalledOnValidThread()); 88 DCHECK(CalledOnValidThread());
78 DCHECK_GT(bytes_received, 0); 89 DCHECK_GT(bytes_received, 0);
79 OnNetworkBytesReceived(request, bytes_received); 90 OnNetworkBytesReceived(request, bytes_received);
80 } 91 }
81 92
82 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, 93 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request,
83 int64_t bytes_sent) { 94 int64_t bytes_sent) {
84 DCHECK(CalledOnValidThread()); 95 DCHECK(CalledOnValidThread());
85 DCHECK_GT(bytes_sent, 0); 96 DCHECK_GT(bytes_sent, 0);
86 OnNetworkBytesSent(request, bytes_sent); 97 OnNetworkBytesSent(request, bytes_sent);
87 } 98 }
88 99
89 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, 100 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
90 const GURL& new_location) { 101 const GURL& new_location) {
91 DCHECK(CalledOnValidThread()); 102 DCHECK(CalledOnValidThread());
92 DCHECK(request); 103 DCHECK(request);
93 OnBeforeRedirect(request, new_location); 104 OnBeforeRedirect(request, new_location);
94 } 105 }
95 106
96 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) { 107 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) {
108 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
109 "NetworkDelegate::NotifyCompleted");
97 DCHECK(CalledOnValidThread()); 110 DCHECK(CalledOnValidThread());
98 DCHECK(request); 111 DCHECK(request);
99 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 112 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
100 tracked_objects::ScopedTracker tracking_profile( 113 tracked_objects::ScopedTracker tracking_profile(
101 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); 114 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted"));
102 OnCompleted(request, started); 115 OnCompleted(request, started);
103 } 116 }
104 117
105 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { 118 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
119 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
120 "NetworkDelegate::NotifyURLRequestDestroyed");
106 DCHECK(CalledOnValidThread()); 121 DCHECK(CalledOnValidThread());
107 DCHECK(request); 122 DCHECK(request);
108 OnURLRequestDestroyed(request); 123 OnURLRequestDestroyed(request);
109 } 124 }
110 125
111 void NetworkDelegate::NotifyPACScriptError(int line_number, 126 void NetworkDelegate::NotifyPACScriptError(int line_number,
112 const base::string16& error) { 127 const base::string16& error) {
113 DCHECK(CalledOnValidThread()); 128 DCHECK(CalledOnValidThread());
114 OnPACScriptError(line_number, error); 129 OnPACScriptError(line_number, error);
115 } 130 }
(...skipping 24 matching lines...) Expand all
140 155
141 bool NetworkDelegate::CanAccessFile(const URLRequest& request, 156 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
142 const base::FilePath& path) const { 157 const base::FilePath& path) const {
143 DCHECK(CalledOnValidThread()); 158 DCHECK(CalledOnValidThread());
144 return OnCanAccessFile(request, path); 159 return OnCanAccessFile(request, path);
145 } 160 }
146 161
147 bool NetworkDelegate::CanEnablePrivacyMode( 162 bool NetworkDelegate::CanEnablePrivacyMode(
148 const GURL& url, 163 const GURL& url,
149 const GURL& first_party_for_cookies) const { 164 const GURL& first_party_for_cookies) const {
165 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
166 "NetworkDelegate::CanEnablePrivacyMode");
150 DCHECK(CalledOnValidThread()); 167 DCHECK(CalledOnValidThread());
151 return OnCanEnablePrivacyMode(url, first_party_for_cookies); 168 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
152 } 169 }
153 170
154 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const { 171 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const {
155 return OnAreExperimentalCookieFeaturesEnabled(); 172 return OnAreExperimentalCookieFeaturesEnabled();
156 } 173 }
157 174
158 bool NetworkDelegate::AreStrictSecureCookiesEnabled() const { 175 bool NetworkDelegate::AreStrictSecureCookiesEnabled() const {
159 return OnAreStrictSecureCookiesEnabled(); 176 return OnAreStrictSecureCookiesEnabled();
160 } 177 }
161 178
162 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( 179 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader(
163 const URLRequest& request, 180 const URLRequest& request,
164 const GURL& target_url, 181 const GURL& target_url,
165 const GURL& referrer_url) const { 182 const GURL& referrer_url) const {
166 DCHECK(CalledOnValidThread()); 183 DCHECK(CalledOnValidThread());
167 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( 184 return OnCancelURLRequestWithPolicyViolatingReferrerHeader(
168 request, target_url, referrer_url); 185 request, target_url, referrer_url);
169 } 186 }
170 187
171 } // namespace net 188 } // namespace net
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | net/base/network_quality_estimator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698