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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 bool has_load_timing_info_before_auth_; | 404 bool has_load_timing_info_before_auth_; |
403 | 405 |
404 bool can_access_files_; // true by default | 406 bool can_access_files_; // true by default |
405 bool experimental_cookie_features_enabled_; // false by default | 407 bool experimental_cookie_features_enabled_; // false by default |
406 bool cancel_request_with_policy_violating_referrer_; // false by default | 408 bool cancel_request_with_policy_violating_referrer_; // false by default |
407 bool will_be_intercepted_on_next_error_; | 409 bool will_be_intercepted_on_next_error_; |
408 }; | 410 }; |
409 | 411 |
410 //----------------------------------------------------------------------------- | 412 //----------------------------------------------------------------------------- |
411 | 413 |
412 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once. | 414 // A simple ProtocolHandler that returns a pre-built URLRequestJob only once, |
413 class TestJobInterceptor : public URLRequestJobFactory::ProtocolHandler { | 415 // and falls back to a normal HttpProtocolHandler implementation if no pre-built |
| 416 // URLRequestJob is present. |
| 417 class TestJobInterceptor : public URLRequestInterceptor { |
414 public: | 418 public: |
415 TestJobInterceptor(); | 419 TestJobInterceptor(); |
416 ~TestJobInterceptor() override; | 420 ~TestJobInterceptor() override; |
417 | 421 |
418 URLRequestJob* MaybeCreateJob( | 422 URLRequestJob* MaybeInterceptRequest( |
| 423 URLRequest* request, |
| 424 NetworkDelegate* network_delegate) const override; |
| 425 URLRequestJob* MaybeInterceptRedirect(URLRequest* request, |
| 426 NetworkDelegate* network_delegate, |
| 427 const GURL& location) const override; |
| 428 URLRequestJob* MaybeInterceptResponse( |
419 URLRequest* request, | 429 URLRequest* request, |
420 NetworkDelegate* network_delegate) const override; | 430 NetworkDelegate* network_delegate) const override; |
421 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); | 431 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); |
422 | 432 |
423 private: | 433 private: |
424 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; | 434 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; |
425 }; | 435 }; |
426 | 436 |
427 } // namespace net | 437 } // namespace net |
428 | 438 |
429 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 439 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
OLD | NEW |