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

Side by Side Diff: net/url_request/url_request_test_util.h

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/url_request/url_request_test_job.cc ('k') | net/url_request/url_request_throttler_entry.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 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
6 #define NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 //----------------------------------------------------------------------------- 51 //-----------------------------------------------------------------------------
52 52
53 class TestURLRequestContext : public URLRequestContext { 53 class TestURLRequestContext : public URLRequestContext {
54 public: 54 public:
55 TestURLRequestContext(); 55 TestURLRequestContext();
56 // Default constructor like TestURLRequestContext() but does not call 56 // Default constructor like TestURLRequestContext() but does not call
57 // Init() in case |delay_initialization| is true. This allows modifying the 57 // Init() in case |delay_initialization| is true. This allows modifying the
58 // URLRequestContext before it is constructed completely. If 58 // URLRequestContext before it is constructed completely. If
59 // |delay_initialization| is true, Init() needs be be called manually. 59 // |delay_initialization| is true, Init() needs be be called manually.
60 explicit TestURLRequestContext(bool delay_initialization); 60 explicit TestURLRequestContext(bool delay_initialization);
61 virtual ~TestURLRequestContext(); 61 ~TestURLRequestContext() override;
62 62
63 void Init(); 63 void Init();
64 64
65 ClientSocketFactory* client_socket_factory() { 65 ClientSocketFactory* client_socket_factory() {
66 return client_socket_factory_; 66 return client_socket_factory_;
67 } 67 }
68 void set_client_socket_factory(ClientSocketFactory* factory) { 68 void set_client_socket_factory(ClientSocketFactory* factory) {
69 client_socket_factory_ = factory; 69 client_socket_factory_ = factory;
70 } 70 }
71 71
(...skipping 29 matching lines...) Expand all
101 // |network_task_runner| must not be NULL. 101 // |network_task_runner| must not be NULL.
102 explicit TestURLRequestContextGetter( 102 explicit TestURLRequestContextGetter(
103 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner); 103 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
104 104
105 // Use to pass a pre-initialized |context|. 105 // Use to pass a pre-initialized |context|.
106 TestURLRequestContextGetter( 106 TestURLRequestContextGetter(
107 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, 107 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
108 scoped_ptr<TestURLRequestContext> context); 108 scoped_ptr<TestURLRequestContext> context);
109 109
110 // URLRequestContextGetter implementation. 110 // URLRequestContextGetter implementation.
111 virtual TestURLRequestContext* GetURLRequestContext() override; 111 TestURLRequestContext* GetURLRequestContext() override;
112 virtual scoped_refptr<base::SingleThreadTaskRunner> 112 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
113 GetNetworkTaskRunner() const override; 113 const override;
114 114
115 protected: 115 protected:
116 virtual ~TestURLRequestContextGetter(); 116 ~TestURLRequestContextGetter() override;
117 117
118 private: 118 private:
119 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 119 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
120 scoped_ptr<TestURLRequestContext> context_; 120 scoped_ptr<TestURLRequestContext> context_;
121 }; 121 };
122 122
123 //----------------------------------------------------------------------------- 123 //-----------------------------------------------------------------------------
124 124
125 class TestDelegate : public URLRequest::Delegate { 125 class TestDelegate : public URLRequest::Delegate {
126 public: 126 public:
127 TestDelegate(); 127 TestDelegate();
128 virtual ~TestDelegate(); 128 ~TestDelegate() override;
129 129
130 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } 130 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; }
131 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; } 131 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; }
132 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; } 132 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; }
133 void set_cancel_in_received_data_pending(bool val) { 133 void set_cancel_in_received_data_pending(bool val) {
134 cancel_in_rd_pending_ = val; 134 cancel_in_rd_pending_ = val;
135 } 135 }
136 void set_quit_on_complete(bool val) { quit_on_complete_ = val; } 136 void set_quit_on_complete(bool val) { quit_on_complete_ = val; }
137 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; } 137 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; }
138 void set_quit_on_network_start(bool val) { 138 void set_quit_on_network_start(bool val) {
(...skipping 23 matching lines...) Expand all
162 return certificate_errors_are_fatal_; 162 return certificate_errors_are_fatal_;
163 } 163 }
164 bool auth_required_called() const { return auth_required_; } 164 bool auth_required_called() const { return auth_required_; }
165 bool have_full_request_headers() const { return have_full_request_headers_; } 165 bool have_full_request_headers() const { return have_full_request_headers_; }
166 const HttpRequestHeaders& full_request_headers() const { 166 const HttpRequestHeaders& full_request_headers() const {
167 return full_request_headers_; 167 return full_request_headers_;
168 } 168 }
169 void ClearFullRequestHeaders(); 169 void ClearFullRequestHeaders();
170 170
171 // URLRequest::Delegate: 171 // URLRequest::Delegate:
172 virtual void OnReceivedRedirect(URLRequest* request, 172 void OnReceivedRedirect(URLRequest* request,
173 const RedirectInfo& redirect_info, 173 const RedirectInfo& redirect_info,
174 bool* defer_redirect) override; 174 bool* defer_redirect) override;
175 virtual void OnBeforeNetworkStart(URLRequest* request, bool* defer) override; 175 void OnBeforeNetworkStart(URLRequest* request, bool* defer) override;
176 virtual void OnAuthRequired(URLRequest* request, 176 void OnAuthRequired(URLRequest* request,
177 AuthChallengeInfo* auth_info) override; 177 AuthChallengeInfo* auth_info) override;
178 // NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true. 178 // NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true.
179 // (Unit tests use this as a post-condition.) But for policy, this method 179 // (Unit tests use this as a post-condition.) But for policy, this method
180 // consults |allow_certificate_errors_|. 180 // consults |allow_certificate_errors_|.
181 virtual void OnSSLCertificateError(URLRequest* request, 181 void OnSSLCertificateError(URLRequest* request,
182 const SSLInfo& ssl_info, 182 const SSLInfo& ssl_info,
183 bool fatal) override; 183 bool fatal) override;
184 virtual void OnResponseStarted(URLRequest* request) override; 184 void OnResponseStarted(URLRequest* request) override;
185 virtual void OnReadCompleted(URLRequest* request, 185 void OnReadCompleted(URLRequest* request, int bytes_read) override;
186 int bytes_read) override;
187 186
188 private: 187 private:
189 static const int kBufferSize = 4096; 188 static const int kBufferSize = 4096;
190 189
191 virtual void OnResponseCompleted(URLRequest* request); 190 virtual void OnResponseCompleted(URLRequest* request);
192 191
193 // options for controlling behavior 192 // options for controlling behavior
194 bool cancel_in_rr_; 193 bool cancel_in_rr_;
195 bool cancel_in_rs_; 194 bool cancel_in_rs_;
196 bool cancel_in_rd_; 195 bool cancel_in_rd_;
(...skipping 25 matching lines...) Expand all
222 //----------------------------------------------------------------------------- 221 //-----------------------------------------------------------------------------
223 222
224 class TestNetworkDelegate : public NetworkDelegate { 223 class TestNetworkDelegate : public NetworkDelegate {
225 public: 224 public:
226 enum Options { 225 enum Options {
227 NO_GET_COOKIES = 1 << 0, 226 NO_GET_COOKIES = 1 << 0,
228 NO_SET_COOKIE = 1 << 1, 227 NO_SET_COOKIE = 1 << 1,
229 }; 228 };
230 229
231 TestNetworkDelegate(); 230 TestNetworkDelegate();
232 virtual ~TestNetworkDelegate(); 231 ~TestNetworkDelegate() override;
233 232
234 // Writes the LoadTimingInfo during the most recent call to OnBeforeRedirect. 233 // Writes the LoadTimingInfo during the most recent call to OnBeforeRedirect.
235 bool GetLoadTimingInfoBeforeRedirect( 234 bool GetLoadTimingInfoBeforeRedirect(
236 LoadTimingInfo* load_timing_info_before_redirect) const; 235 LoadTimingInfo* load_timing_info_before_redirect) const;
237 236
238 // Same as GetLoadTimingInfoBeforeRedirect, except for calls to 237 // Same as GetLoadTimingInfoBeforeRedirect, except for calls to
239 // AuthRequiredResponse. 238 // AuthRequiredResponse.
240 bool GetLoadTimingInfoBeforeAuth( 239 bool GetLoadTimingInfoBeforeAuth(
241 LoadTimingInfo* load_timing_info_before_auth) const; 240 LoadTimingInfo* load_timing_info_before_auth) const;
242 241
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return observed_before_proxy_headers_sent_callbacks_; 276 return observed_before_proxy_headers_sent_callbacks_;
278 } 277 }
279 278
280 // Last observed proxy in proxy header sent callback. 279 // Last observed proxy in proxy header sent callback.
281 HostPortPair last_observed_proxy() { 280 HostPortPair last_observed_proxy() {
282 return last_observed_proxy_; 281 return last_observed_proxy_;
283 } 282 }
284 283
285 protected: 284 protected:
286 // NetworkDelegate: 285 // NetworkDelegate:
287 virtual int OnBeforeURLRequest(URLRequest* request, 286 int OnBeforeURLRequest(URLRequest* request,
288 const CompletionCallback& callback, 287 const CompletionCallback& callback,
289 GURL* new_url) override; 288 GURL* new_url) override;
290 virtual int OnBeforeSendHeaders(URLRequest* request, 289 int OnBeforeSendHeaders(URLRequest* request,
291 const CompletionCallback& callback, 290 const CompletionCallback& callback,
292 HttpRequestHeaders* headers) override; 291 HttpRequestHeaders* headers) override;
293 virtual void OnBeforeSendProxyHeaders( 292 void OnBeforeSendProxyHeaders(net::URLRequest* request,
294 net::URLRequest* request, 293 const net::ProxyInfo& proxy_info,
295 const net::ProxyInfo& proxy_info, 294 net::HttpRequestHeaders* headers) override;
296 net::HttpRequestHeaders* headers) override; 295 void OnSendHeaders(URLRequest* request,
297 virtual void OnSendHeaders(URLRequest* request, 296 const HttpRequestHeaders& headers) override;
298 const HttpRequestHeaders& headers) override; 297 int OnHeadersReceived(
299 virtual int OnHeadersReceived(
300 URLRequest* request, 298 URLRequest* request,
301 const CompletionCallback& callback, 299 const CompletionCallback& callback,
302 const HttpResponseHeaders* original_response_headers, 300 const HttpResponseHeaders* original_response_headers,
303 scoped_refptr<HttpResponseHeaders>* override_response_headers, 301 scoped_refptr<HttpResponseHeaders>* override_response_headers,
304 GURL* allowed_unsafe_redirect_url) override; 302 GURL* allowed_unsafe_redirect_url) override;
305 virtual void OnBeforeRedirect(URLRequest* request, 303 void OnBeforeRedirect(URLRequest* request, const GURL& new_location) override;
306 const GURL& new_location) override; 304 void OnResponseStarted(URLRequest* request) override;
307 virtual void OnResponseStarted(URLRequest* request) override; 305 void OnRawBytesRead(const URLRequest& request, int bytes_read) override;
308 virtual void OnRawBytesRead(const URLRequest& request, 306 void OnCompleted(URLRequest* request, bool started) override;
309 int bytes_read) override; 307 void OnURLRequestDestroyed(URLRequest* request) override;
310 virtual void OnCompleted(URLRequest* request, bool started) override; 308 void OnPACScriptError(int line_number, const base::string16& error) override;
311 virtual void OnURLRequestDestroyed(URLRequest* request) override; 309 NetworkDelegate::AuthRequiredResponse OnAuthRequired(
312 virtual void OnPACScriptError(int line_number,
313 const base::string16& error) override;
314 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired(
315 URLRequest* request, 310 URLRequest* request,
316 const AuthChallengeInfo& auth_info, 311 const AuthChallengeInfo& auth_info,
317 const AuthCallback& callback, 312 const AuthCallback& callback,
318 AuthCredentials* credentials) override; 313 AuthCredentials* credentials) override;
319 virtual bool OnCanGetCookies(const URLRequest& request, 314 bool OnCanGetCookies(const URLRequest& request,
320 const CookieList& cookie_list) override; 315 const CookieList& cookie_list) override;
321 virtual bool OnCanSetCookie(const URLRequest& request, 316 bool OnCanSetCookie(const URLRequest& request,
322 const std::string& cookie_line, 317 const std::string& cookie_line,
323 CookieOptions* options) override; 318 CookieOptions* options) override;
324 virtual bool OnCanAccessFile(const URLRequest& request, 319 bool OnCanAccessFile(const URLRequest& request,
325 const base::FilePath& path) const override; 320 const base::FilePath& path) const override;
326 virtual bool OnCanThrottleRequest( 321 bool OnCanThrottleRequest(const URLRequest& request) const override;
327 const URLRequest& request) const override; 322 int OnBeforeSocketStreamConnect(SocketStream* stream,
328 virtual int OnBeforeSocketStreamConnect( 323 const CompletionCallback& callback) override;
329 SocketStream* stream, 324 bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
330 const CompletionCallback& callback) override;
331 virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
332 const URLRequest& request, 325 const URLRequest& request,
333 const GURL& target_url, 326 const GURL& target_url,
334 const GURL& referrer_url) const override; 327 const GURL& referrer_url) const override;
335 328
336 void InitRequestStatesIfNew(int request_id); 329 void InitRequestStatesIfNew(int request_id);
337 330
338 GURL redirect_on_headers_received_url_; 331 GURL redirect_on_headers_received_url_;
339 // URL marked as safe for redirection at the onHeadersReceived stage. 332 // URL marked as safe for redirection at the onHeadersReceived stage.
340 GURL allowed_unsafe_redirect_url_; 333 GURL allowed_unsafe_redirect_url_;
341 334
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); 392 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost);
400 }; 393 };
401 394
402 //----------------------------------------------------------------------------- 395 //-----------------------------------------------------------------------------
403 396
404 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once. 397 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once.
405 class TestJobInterceptor : public URLRequestJobFactory::ProtocolHandler { 398 class TestJobInterceptor : public URLRequestJobFactory::ProtocolHandler {
406 public: 399 public:
407 TestJobInterceptor(); 400 TestJobInterceptor();
408 401
409 virtual URLRequestJob* MaybeCreateJob( 402 URLRequestJob* MaybeCreateJob(
410 URLRequest* request, 403 URLRequest* request,
411 NetworkDelegate* network_delegate) const override; 404 NetworkDelegate* network_delegate) const override;
412 void set_main_intercept_job(URLRequestJob* job); 405 void set_main_intercept_job(URLRequestJob* job);
413 406
414 private: 407 private:
415 mutable URLRequestJob* main_intercept_job_; 408 mutable URLRequestJob* main_intercept_job_;
416 }; 409 };
417 410
418 } // namespace net 411 } // namespace net
419 412
420 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 413 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_job.cc ('k') | net/url_request/url_request_throttler_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698