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

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

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 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
« no previous file with comments | « net/base/network_delegate.h ('k') | net/base/priority_queue.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/base/trace_constants.h"
13 #include "net/proxy/proxy_info.h" 13 #include "net/proxy/proxy_info.h"
14 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 NetworkDelegate::~NetworkDelegate() {
19 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
20 }
21
18 int NetworkDelegate::NotifyBeforeURLRequest( 22 int NetworkDelegate::NotifyBeforeURLRequest(
19 URLRequest* request, const CompletionCallback& callback, 23 URLRequest* request, const CompletionCallback& callback,
20 GURL* new_url) { 24 GURL* new_url) {
21 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyBeforeURLRequest"); 25 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyBeforeURLRequest");
22 DCHECK(CalledOnValidThread()); 26 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
23 DCHECK(request); 27 DCHECK(request);
24 DCHECK(!callback.is_null()); 28 DCHECK(!callback.is_null());
25 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 29 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
26 tracked_objects::ScopedTracker tracking_profile( 30 tracked_objects::ScopedTracker tracking_profile(
27 FROM_HERE_WITH_EXPLICIT_FUNCTION( 31 FROM_HERE_WITH_EXPLICIT_FUNCTION(
28 "475753 NetworkDelegate::OnBeforeURLRequest")); 32 "475753 NetworkDelegate::OnBeforeURLRequest"));
29 return OnBeforeURLRequest(request, callback, new_url); 33 return OnBeforeURLRequest(request, callback, new_url);
30 } 34 }
31 35
32 int NetworkDelegate::NotifyBeforeStartTransaction( 36 int NetworkDelegate::NotifyBeforeStartTransaction(
33 URLRequest* request, 37 URLRequest* request,
34 const CompletionCallback& callback, 38 const CompletionCallback& callback,
35 HttpRequestHeaders* headers) { 39 HttpRequestHeaders* headers) {
36 TRACE_EVENT0(kNetTracingCategory, 40 TRACE_EVENT0(kNetTracingCategory,
37 "NetworkDelegate::NotifyBeforeStartTransation"); 41 "NetworkDelegate::NotifyBeforeStartTransation");
38 DCHECK(CalledOnValidThread()); 42 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
39 DCHECK(headers); 43 DCHECK(headers);
40 DCHECK(!callback.is_null()); 44 DCHECK(!callback.is_null());
41 return OnBeforeStartTransaction(request, callback, headers); 45 return OnBeforeStartTransaction(request, callback, headers);
42 } 46 }
43 47
44 void NetworkDelegate::NotifyBeforeSendHeaders( 48 void NetworkDelegate::NotifyBeforeSendHeaders(
45 URLRequest* request, 49 URLRequest* request,
46 const ProxyInfo& proxy_info, 50 const ProxyInfo& proxy_info,
47 const ProxyRetryInfoMap& proxy_retry_info, 51 const ProxyRetryInfoMap& proxy_retry_info,
48 HttpRequestHeaders* headers) { 52 HttpRequestHeaders* headers) {
49 DCHECK(CalledOnValidThread()); 53 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
50 DCHECK(headers); 54 DCHECK(headers);
51 OnBeforeSendHeaders(request, proxy_info, proxy_retry_info, headers); 55 OnBeforeSendHeaders(request, proxy_info, proxy_retry_info, headers);
52 } 56 }
53 57
54 void NetworkDelegate::NotifyStartTransaction( 58 void NetworkDelegate::NotifyStartTransaction(
55 URLRequest* request, 59 URLRequest* request,
56 const HttpRequestHeaders& headers) { 60 const HttpRequestHeaders& headers) {
57 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyStartTransaction"); 61 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyStartTransaction");
58 DCHECK(CalledOnValidThread()); 62 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
59 OnStartTransaction(request, headers); 63 OnStartTransaction(request, headers);
60 } 64 }
61 65
62 int NetworkDelegate::NotifyHeadersReceived( 66 int NetworkDelegate::NotifyHeadersReceived(
63 URLRequest* request, 67 URLRequest* request,
64 const CompletionCallback& callback, 68 const CompletionCallback& callback,
65 const HttpResponseHeaders* original_response_headers, 69 const HttpResponseHeaders* original_response_headers,
66 scoped_refptr<HttpResponseHeaders>* override_response_headers, 70 scoped_refptr<HttpResponseHeaders>* override_response_headers,
67 GURL* allowed_unsafe_redirect_url) { 71 GURL* allowed_unsafe_redirect_url) {
68 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyHeadersReceived"); 72 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyHeadersReceived");
69 DCHECK(CalledOnValidThread()); 73 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
70 DCHECK(original_response_headers); 74 DCHECK(original_response_headers);
71 DCHECK(!callback.is_null()); 75 DCHECK(!callback.is_null());
72 return OnHeadersReceived(request, 76 return OnHeadersReceived(request,
73 callback, 77 callback,
74 original_response_headers, 78 original_response_headers,
75 override_response_headers, 79 override_response_headers,
76 allowed_unsafe_redirect_url); 80 allowed_unsafe_redirect_url);
77 } 81 }
78 82
79 void NetworkDelegate::NotifyResponseStarted(URLRequest* request, 83 void NetworkDelegate::NotifyResponseStarted(URLRequest* request,
80 int net_error) { 84 int net_error) {
81 DCHECK(CalledOnValidThread()); 85 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
82 DCHECK(request); 86 DCHECK(request);
83 87
84 OnResponseStarted(request, net_error); 88 OnResponseStarted(request, net_error);
85 } 89 }
86 90
87 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, 91 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request,
88 int64_t bytes_received) { 92 int64_t bytes_received) {
89 TRACE_EVENT0(kNetTracingCategory, 93 TRACE_EVENT0(kNetTracingCategory,
90 "NetworkDelegate::NotifyNetworkBytesReceived"); 94 "NetworkDelegate::NotifyNetworkBytesReceived");
91 DCHECK(CalledOnValidThread()); 95 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
92 DCHECK_GT(bytes_received, 0); 96 DCHECK_GT(bytes_received, 0);
93 OnNetworkBytesReceived(request, bytes_received); 97 OnNetworkBytesReceived(request, bytes_received);
94 } 98 }
95 99
96 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, 100 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request,
97 int64_t bytes_sent) { 101 int64_t bytes_sent) {
98 DCHECK(CalledOnValidThread()); 102 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
99 DCHECK_GT(bytes_sent, 0); 103 DCHECK_GT(bytes_sent, 0);
100 OnNetworkBytesSent(request, bytes_sent); 104 OnNetworkBytesSent(request, bytes_sent);
101 } 105 }
102 106
103 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, 107 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
104 const GURL& new_location) { 108 const GURL& new_location) {
105 DCHECK(CalledOnValidThread()); 109 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
106 DCHECK(request); 110 DCHECK(request);
107 OnBeforeRedirect(request, new_location); 111 OnBeforeRedirect(request, new_location);
108 } 112 }
109 113
110 void NetworkDelegate::NotifyCompleted(URLRequest* request, 114 void NetworkDelegate::NotifyCompleted(URLRequest* request,
111 bool started, 115 bool started,
112 int net_error) { 116 int net_error) {
113 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyCompleted"); 117 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::NotifyCompleted");
114 DCHECK(CalledOnValidThread()); 118 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
115 DCHECK(request); 119 DCHECK(request);
116 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. 120 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
117 tracked_objects::ScopedTracker tracking_profile( 121 tracked_objects::ScopedTracker tracking_profile(
118 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); 122 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted"));
119 123
120 OnCompleted(request, started, net_error); 124 OnCompleted(request, started, net_error);
121 } 125 }
122 126
123 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { 127 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
124 TRACE_EVENT0(kNetTracingCategory, 128 TRACE_EVENT0(kNetTracingCategory,
125 "NetworkDelegate::NotifyURLRequestDestroyed"); 129 "NetworkDelegate::NotifyURLRequestDestroyed");
126 DCHECK(CalledOnValidThread()); 130 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
127 DCHECK(request); 131 DCHECK(request);
128 OnURLRequestDestroyed(request); 132 OnURLRequestDestroyed(request);
129 } 133 }
130 134
131 void NetworkDelegate::NotifyPACScriptError(int line_number, 135 void NetworkDelegate::NotifyPACScriptError(int line_number,
132 const base::string16& error) { 136 const base::string16& error) {
133 DCHECK(CalledOnValidThread()); 137 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
134 OnPACScriptError(line_number, error); 138 OnPACScriptError(line_number, error);
135 } 139 }
136 140
137 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired( 141 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired(
138 URLRequest* request, 142 URLRequest* request,
139 const AuthChallengeInfo& auth_info, 143 const AuthChallengeInfo& auth_info,
140 const AuthCallback& callback, 144 const AuthCallback& callback,
141 AuthCredentials* credentials) { 145 AuthCredentials* credentials) {
142 DCHECK(CalledOnValidThread()); 146 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
143 return OnAuthRequired(request, auth_info, callback, credentials); 147 return OnAuthRequired(request, auth_info, callback, credentials);
144 } 148 }
145 149
146 bool NetworkDelegate::CanGetCookies(const URLRequest& request, 150 bool NetworkDelegate::CanGetCookies(const URLRequest& request,
147 const CookieList& cookie_list) { 151 const CookieList& cookie_list) {
148 DCHECK(CalledOnValidThread()); 152 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
149 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SEND_COOKIES)); 153 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SEND_COOKIES));
150 return OnCanGetCookies(request, cookie_list); 154 return OnCanGetCookies(request, cookie_list);
151 } 155 }
152 156
153 bool NetworkDelegate::CanSetCookie(const URLRequest& request, 157 bool NetworkDelegate::CanSetCookie(const URLRequest& request,
154 const std::string& cookie_line, 158 const std::string& cookie_line,
155 CookieOptions* options) { 159 CookieOptions* options) {
156 DCHECK(CalledOnValidThread()); 160 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
157 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SAVE_COOKIES)); 161 DCHECK(!(request.load_flags() & LOAD_DO_NOT_SAVE_COOKIES));
158 return OnCanSetCookie(request, cookie_line, options); 162 return OnCanSetCookie(request, cookie_line, options);
159 } 163 }
160 164
161 bool NetworkDelegate::CanAccessFile(const URLRequest& request, 165 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
162 const base::FilePath& original_path, 166 const base::FilePath& original_path,
163 const base::FilePath& absolute_path) const { 167 const base::FilePath& absolute_path) const {
164 DCHECK(CalledOnValidThread()); 168 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
165 return OnCanAccessFile(request, original_path, absolute_path); 169 return OnCanAccessFile(request, original_path, absolute_path);
166 } 170 }
167 171
168 bool NetworkDelegate::CanEnablePrivacyMode( 172 bool NetworkDelegate::CanEnablePrivacyMode(
169 const GURL& url, 173 const GURL& url,
170 const GURL& first_party_for_cookies) const { 174 const GURL& first_party_for_cookies) const {
171 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::CanEnablePrivacyMode"); 175 TRACE_EVENT0(kNetTracingCategory, "NetworkDelegate::CanEnablePrivacyMode");
172 DCHECK(CalledOnValidThread()); 176 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
173 return OnCanEnablePrivacyMode(url, first_party_for_cookies); 177 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
174 } 178 }
175 179
176 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const { 180 bool NetworkDelegate::AreExperimentalCookieFeaturesEnabled() const {
177 return OnAreExperimentalCookieFeaturesEnabled(); 181 return OnAreExperimentalCookieFeaturesEnabled();
178 } 182 }
179 183
180 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( 184 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader(
181 const URLRequest& request, 185 const URLRequest& request,
182 const GURL& target_url, 186 const GURL& target_url,
183 const GURL& referrer_url) const { 187 const GURL& referrer_url) const {
184 DCHECK(CalledOnValidThread()); 188 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
185 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( 189 return OnCancelURLRequestWithPolicyViolatingReferrerHeader(
186 request, target_url, referrer_url); 190 request, target_url, referrer_url);
187 } 191 }
188 192
189 bool NetworkDelegate::CanQueueReportingReport(const url::Origin& origin) const { 193 bool NetworkDelegate::CanQueueReportingReport(const url::Origin& origin) const {
190 DCHECK(CalledOnValidThread()); 194 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
191 return OnCanQueueReportingReport(origin); 195 return OnCanQueueReportingReport(origin);
192 } 196 }
193 197
194 bool NetworkDelegate::CanSendReportingReport(const url::Origin& origin) const { 198 bool NetworkDelegate::CanSendReportingReport(const url::Origin& origin) const {
195 DCHECK(CalledOnValidThread()); 199 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
196 return OnCanSendReportingReport(origin); 200 return OnCanSendReportingReport(origin);
197 } 201 }
198 202
199 bool NetworkDelegate::CanSetReportingClient(const url::Origin& origin, 203 bool NetworkDelegate::CanSetReportingClient(const url::Origin& origin,
200 const GURL& endpoint) const { 204 const GURL& endpoint) const {
201 DCHECK(CalledOnValidThread()); 205 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
202 return OnCanSetReportingClient(origin, endpoint); 206 return OnCanSetReportingClient(origin, endpoint);
203 } 207 }
204 208
205 bool NetworkDelegate::CanUseReportingClient(const url::Origin& origin, 209 bool NetworkDelegate::CanUseReportingClient(const url::Origin& origin,
206 const GURL& endpoint) const { 210 const GURL& endpoint) const {
207 DCHECK(CalledOnValidThread()); 211 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
208 return OnCanUseReportingClient(origin, endpoint); 212 return OnCanUseReportingClient(origin, endpoint);
209 } 213 }
210 214
211 void NetworkDelegate::OnResponseStarted(URLRequest* request, int net_error) { 215 void NetworkDelegate::OnResponseStarted(URLRequest* request, int net_error) {
212 OnResponseStarted(request); 216 OnResponseStarted(request);
213 } 217 }
214 218
215 // Deprecated 219 // Deprecated
216 void NetworkDelegate::OnResponseStarted(URLRequest* request) { 220 void NetworkDelegate::OnResponseStarted(URLRequest* request) {
217 NOTREACHED(); 221 NOTREACHED();
218 } 222 }
219 223
220 void NetworkDelegate::OnCompleted(URLRequest* request, 224 void NetworkDelegate::OnCompleted(URLRequest* request,
221 bool started, 225 bool started,
222 int net_error) { 226 int net_error) {
223 OnCompleted(request, started); 227 OnCompleted(request, started);
224 } 228 }
225 229
226 // Deprecated. 230 // Deprecated.
227 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) { 231 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) {
228 NOTREACHED(); 232 NOTREACHED();
229 } 233 }
230 234
231 } // namespace net 235 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_delegate.h ('k') | net/base/priority_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698