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

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

Issue 2533953005: Standardize "net" category trace events (Closed)
Patch Set: Rebased Created 4 years 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 | « net/BUILD.gn ('k') | net/base/trace_constants.h » ('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 "base/trace_event/trace_event.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/trace_constants.h"
12 #include "net/proxy/proxy_info.h" 13 #include "net/proxy/proxy_info.h"
13 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 int NetworkDelegate::NotifyBeforeURLRequest( 18 int NetworkDelegate::NotifyBeforeURLRequest(
18 URLRequest* request, const CompletionCallback& callback, 19 URLRequest* request, const CompletionCallback& callback,
19 GURL* new_url) { 20 GURL* new_url) {
20 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 21 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyBeforeURLRequest");
21 "NetworkDelegate::NotifyBeforeURLRequest");
22 DCHECK(CalledOnValidThread()); 22 DCHECK(CalledOnValidThread());
23 DCHECK(request); 23 DCHECK(request);
24 DCHECK(!callback.is_null()); 24 DCHECK(!callback.is_null());
25 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 25 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
26 tracked_objects::ScopedTracker tracking_profile( 26 tracked_objects::ScopedTracker tracking_profile(
27 FROM_HERE_WITH_EXPLICIT_FUNCTION( 27 FROM_HERE_WITH_EXPLICIT_FUNCTION(
28 "475753 NetworkDelegate::OnBeforeURLRequest")); 28 "475753 NetworkDelegate::OnBeforeURLRequest"));
29 return OnBeforeURLRequest(request, callback, new_url); 29 return OnBeforeURLRequest(request, callback, new_url);
30 } 30 }
31 31
32 int NetworkDelegate::NotifyBeforeStartTransaction( 32 int NetworkDelegate::NotifyBeforeStartTransaction(
33 URLRequest* request, 33 URLRequest* request,
34 const CompletionCallback& callback, 34 const CompletionCallback& callback,
35 HttpRequestHeaders* headers) { 35 HttpRequestHeaders* headers) {
36 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 36 TRACE_EVENT0(kNetTracingCategory,
37 "NetworkDelegate::NotifyBeforeStartTransation"); 37 "NetworkDelegate::NotifyBeforeStartTransation");
38 DCHECK(CalledOnValidThread()); 38 DCHECK(CalledOnValidThread());
39 DCHECK(headers); 39 DCHECK(headers);
40 DCHECK(!callback.is_null()); 40 DCHECK(!callback.is_null());
41 return OnBeforeStartTransaction(request, callback, headers); 41 return OnBeforeStartTransaction(request, callback, headers);
42 } 42 }
43 43
44 void NetworkDelegate::NotifyBeforeSendHeaders( 44 void NetworkDelegate::NotifyBeforeSendHeaders(
45 URLRequest* request, 45 URLRequest* request,
46 const ProxyInfo& proxy_info, 46 const ProxyInfo& proxy_info,
47 const ProxyRetryInfoMap& proxy_retry_info, 47 const ProxyRetryInfoMap& proxy_retry_info,
48 HttpRequestHeaders* headers) { 48 HttpRequestHeaders* headers) {
49 DCHECK(CalledOnValidThread()); 49 DCHECK(CalledOnValidThread());
50 DCHECK(headers); 50 DCHECK(headers);
51 OnBeforeSendHeaders(request, proxy_info, proxy_retry_info, headers); 51 OnBeforeSendHeaders(request, proxy_info, proxy_retry_info, headers);
52 } 52 }
53 53
54 void NetworkDelegate::NotifyStartTransaction( 54 void NetworkDelegate::NotifyStartTransaction(
55 URLRequest* request, 55 URLRequest* request,
56 const HttpRequestHeaders& headers) { 56 const HttpRequestHeaders& headers) {
57 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 57 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyStartTransaction");
58 "NetworkDelegate::NotifyStartTransaction");
59 DCHECK(CalledOnValidThread()); 58 DCHECK(CalledOnValidThread());
60 OnStartTransaction(request, headers); 59 OnStartTransaction(request, headers);
61 } 60 }
62 61
63 int NetworkDelegate::NotifyHeadersReceived( 62 int NetworkDelegate::NotifyHeadersReceived(
64 URLRequest* request, 63 URLRequest* request,
65 const CompletionCallback& callback, 64 const CompletionCallback& callback,
66 const HttpResponseHeaders* original_response_headers, 65 const HttpResponseHeaders* original_response_headers,
67 scoped_refptr<HttpResponseHeaders>* override_response_headers, 66 scoped_refptr<HttpResponseHeaders>* override_response_headers,
68 GURL* allowed_unsafe_redirect_url) { 67 GURL* allowed_unsafe_redirect_url) {
69 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 68 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyHeadersReceived");
70 "NetworkDelegate::NotifyHeadersReceived");
71 DCHECK(CalledOnValidThread()); 69 DCHECK(CalledOnValidThread());
72 DCHECK(original_response_headers); 70 DCHECK(original_response_headers);
73 DCHECK(!callback.is_null()); 71 DCHECK(!callback.is_null());
74 return OnHeadersReceived(request, 72 return OnHeadersReceived(request,
75 callback, 73 callback,
76 original_response_headers, 74 original_response_headers,
77 override_response_headers, 75 override_response_headers,
78 allowed_unsafe_redirect_url); 76 allowed_unsafe_redirect_url);
79 } 77 }
80 78
81 void NetworkDelegate::NotifyResponseStarted(URLRequest* request, 79 void NetworkDelegate::NotifyResponseStarted(URLRequest* request,
82 int net_error) { 80 int net_error) {
83 DCHECK(CalledOnValidThread()); 81 DCHECK(CalledOnValidThread());
84 DCHECK(request); 82 DCHECK(request);
85 83
86 OnResponseStarted(request, net_error); 84 OnResponseStarted(request, net_error);
87 } 85 }
88 86
89 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, 87 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request,
90 int64_t bytes_received) { 88 int64_t bytes_received) {
91 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 89 TRACE_EVENT0(kNetTracingCategory,
92 "NetworkDelegate::NotifyNetworkBytesReceived"); 90 "NetworkDelegate::NotifyNetworkBytesReceived");
93 DCHECK(CalledOnValidThread()); 91 DCHECK(CalledOnValidThread());
94 DCHECK_GT(bytes_received, 0); 92 DCHECK_GT(bytes_received, 0);
95 OnNetworkBytesReceived(request, bytes_received); 93 OnNetworkBytesReceived(request, bytes_received);
96 } 94 }
97 95
98 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, 96 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request,
99 int64_t bytes_sent) { 97 int64_t bytes_sent) {
100 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
101 DCHECK_GT(bytes_sent, 0); 99 DCHECK_GT(bytes_sent, 0);
102 OnNetworkBytesSent(request, bytes_sent); 100 OnNetworkBytesSent(request, bytes_sent);
103 } 101 }
104 102
105 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, 103 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
106 const GURL& new_location) { 104 const GURL& new_location) {
107 DCHECK(CalledOnValidThread()); 105 DCHECK(CalledOnValidThread());
108 DCHECK(request); 106 DCHECK(request);
109 OnBeforeRedirect(request, new_location); 107 OnBeforeRedirect(request, new_location);
110 } 108 }
111 109
112 void NetworkDelegate::NotifyCompleted(URLRequest* request, 110 void NetworkDelegate::NotifyCompleted(URLRequest* request,
113 bool started, 111 bool started,
114 int net_error) { 112 int net_error) {
115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 113 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyCompleted");
116 "NetworkDelegate::NotifyCompleted");
117 DCHECK(CalledOnValidThread()); 114 DCHECK(CalledOnValidThread());
118 DCHECK(request); 115 DCHECK(request);
119 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 116 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
120 tracked_objects::ScopedTracker tracking_profile( 117 tracked_objects::ScopedTracker tracking_profile(
121 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); 118 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted"));
122 119
123 OnCompleted(request, started, net_error); 120 OnCompleted(request, started, net_error);
124 } 121 }
125 122
126 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { 123 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
127 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 124 TRACE_EVENT0(kNetTracingCategory,
128 "NetworkDelegate::NotifyURLRequestDestroyed"); 125 "NetworkDelegate::NotifyURLRequestDestroyed");
129 DCHECK(CalledOnValidThread()); 126 DCHECK(CalledOnValidThread());
130 DCHECK(request); 127 DCHECK(request);
131 OnURLRequestDestroyed(request); 128 OnURLRequestDestroyed(request);
132 } 129 }
133 130
134 void NetworkDelegate::NotifyPACScriptError(int line_number, 131 void NetworkDelegate::NotifyPACScriptError(int line_number,
135 const base::string16& error) { 132 const base::string16& error) {
136 DCHECK(CalledOnValidThread()); 133 DCHECK(CalledOnValidThread());
137 OnPACScriptError(line_number, error); 134 OnPACScriptError(line_number, error);
(...skipping 25 matching lines...) Expand all
163 160
164 bool NetworkDelegate::CanAccessFile(const URLRequest& request, 161 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
165 const base::FilePath& path) const { 162 const base::FilePath& path) const {
166 DCHECK(CalledOnValidThread()); 163 DCHECK(CalledOnValidThread());
167 return OnCanAccessFile(request, path); 164 return OnCanAccessFile(request, path);
168 } 165 }
169 166
170 bool NetworkDelegate::CanEnablePrivacyMode( 167 bool NetworkDelegate::CanEnablePrivacyMode(
171 const GURL& url, 168 const GURL& url,
172 const GURL& first_party_for_cookies) const { 169 const GURL& first_party_for_cookies) const {
173 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 170 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::CanEnablePrivacyMode");
174 "NetworkDelegate::CanEnablePrivacyMode");
175 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
176 return OnCanEnablePrivacyMode(url, first_party_for_cookies); 172 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
177 } 173 }
178 174
179 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const { 175 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const {
180 return OnAreExperimentalCookieFeaturesEnabled(); 176 return OnAreExperimentalCookieFeaturesEnabled();
181 } 177 }
182 178
183 bool NetworkDelegate::AreStrictSecureCookiesEnabled() const { 179 bool NetworkDelegate::AreStrictSecureCookiesEnabled() const {
184 return OnAreStrictSecureCookiesEnabled(); 180 return OnAreStrictSecureCookiesEnabled();
(...skipping 22 matching lines...) Expand all
207 int net_error) { 203 int net_error) {
208 OnCompleted(request, started); 204 OnCompleted(request, started);
209 } 205 }
210 206
211 // Deprecated. 207 // Deprecated.
212 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) { 208 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) {
213 NOTREACHED(); 209 NOTREACHED();
214 } 210 }
215 211
216 } // namespace net 212 } // namespace net
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/base/trace_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698