OLD | NEW |
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 <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "net/cookies/cookie_monster.h" | 31 #include "net/cookies/cookie_monster.h" |
32 #include "net/disk_cache/disk_cache.h" | 32 #include "net/disk_cache/disk_cache.h" |
33 #include "net/ftp/ftp_network_layer.h" | 33 #include "net/ftp/ftp_network_layer.h" |
34 #include "net/http/http_auth_handler_factory.h" | 34 #include "net/http/http_auth_handler_factory.h" |
35 #include "net/http/http_cache.h" | 35 #include "net/http/http_cache.h" |
36 #include "net/http/http_network_layer.h" | 36 #include "net/http/http_network_layer.h" |
37 #include "net/http/http_network_session.h" | 37 #include "net/http/http_network_session.h" |
38 #include "net/http/http_request_headers.h" | 38 #include "net/http/http_request_headers.h" |
39 #include "net/proxy/proxy_service.h" | 39 #include "net/proxy/proxy_service.h" |
40 #include "net/ssl/ssl_config_service_defaults.h" | 40 #include "net/ssl/ssl_config_service_defaults.h" |
| 41 #include "net/url_request/http_protocol_handler.h" |
41 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
42 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
43 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
44 #include "net/url_request/url_request_context_storage.h" | 45 #include "net/url_request/url_request_context_storage.h" |
| 46 #include "net/url_request/url_request_interceptor.h" |
45 #include "net/url_request/url_request_job_factory.h" | 47 #include "net/url_request/url_request_job_factory.h" |
46 #include "url/url_util.h" | 48 #include "url/url_util.h" |
47 | 49 |
48 using base::TimeDelta; | 50 using base::TimeDelta; |
49 | 51 |
50 namespace net { | 52 namespace net { |
51 | 53 |
52 //----------------------------------------------------------------------------- | 54 //----------------------------------------------------------------------------- |
53 | 55 |
54 class TestURLRequestContext : public URLRequestContext { | 56 class TestURLRequestContext : public URLRequestContext { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 bool has_load_timing_info_before_auth_; | 400 bool has_load_timing_info_before_auth_; |
399 | 401 |
400 bool can_access_files_; // true by default | 402 bool can_access_files_; // true by default |
401 bool experimental_cookie_features_enabled_; // false by default | 403 bool experimental_cookie_features_enabled_; // false by default |
402 bool cancel_request_with_policy_violating_referrer_; // false by default | 404 bool cancel_request_with_policy_violating_referrer_; // false by default |
403 bool will_be_intercepted_on_next_error_; | 405 bool will_be_intercepted_on_next_error_; |
404 }; | 406 }; |
405 | 407 |
406 //----------------------------------------------------------------------------- | 408 //----------------------------------------------------------------------------- |
407 | 409 |
408 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once. | 410 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once, |
409 class TestJobInterceptor : public URLRequestJobFactory::ProtocolHandler { | 411 // and falls back to a normal HttpProtocolHandler implementation if no pre-built |
| 412 // URLRequestJob is present. |
| 413 class TestJobInterceptor : public URLRequestInterceptor { |
410 public: | 414 public: |
411 TestJobInterceptor(); | 415 TestJobInterceptor(); |
412 ~TestJobInterceptor() override; | 416 ~TestJobInterceptor() override; |
413 | 417 |
414 URLRequestJob* MaybeCreateJob( | 418 URLRequestJob* MaybeInterceptRequest( |
| 419 URLRequest* request, |
| 420 NetworkDelegate* network_delegate) const override; |
| 421 URLRequestJob* MaybeInterceptRedirect(URLRequest* request, |
| 422 NetworkDelegate* network_delegate, |
| 423 const GURL& location) const override; |
| 424 URLRequestJob* MaybeInterceptResponse( |
415 URLRequest* request, | 425 URLRequest* request, |
416 NetworkDelegate* network_delegate) const override; | 426 NetworkDelegate* network_delegate) const override; |
417 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); | 427 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); |
418 | 428 |
419 private: | 429 private: |
420 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; | 430 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; |
421 }; | 431 }; |
422 | 432 |
423 } // namespace net | 433 } // namespace net |
424 | 434 |
425 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 435 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
OLD | NEW |