| 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 <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 void set_can_throttle_requests(bool val) { can_throttle_requests_ = val; } | 268 void set_can_throttle_requests(bool val) { can_throttle_requests_ = val; } |
| 269 bool can_throttle_requests() const { return can_throttle_requests_; } | 269 bool can_throttle_requests() const { return can_throttle_requests_; } |
| 270 | 270 |
| 271 void set_cancel_request_with_policy_violating_referrer(bool val) { | 271 void set_cancel_request_with_policy_violating_referrer(bool val) { |
| 272 cancel_request_with_policy_violating_referrer_ = val; | 272 cancel_request_with_policy_violating_referrer_ = val; |
| 273 } | 273 } |
| 274 | 274 |
| 275 int observed_before_proxy_headers_sent_callbacks() const { | 275 int observed_before_proxy_headers_sent_callbacks() const { |
| 276 return observed_before_proxy_headers_sent_callbacks_; | 276 return observed_before_proxy_headers_sent_callbacks_; |
| 277 } | 277 } |
| 278 int before_send_headers_count() const { return before_send_headers_count_; } |
| 279 int headers_received_count() const { return headers_received_count_; } |
| 278 | 280 |
| 279 // Last observed proxy in proxy header sent callback. | 281 // Last observed proxy in proxy header sent callback. |
| 280 HostPortPair last_observed_proxy() { | 282 HostPortPair last_observed_proxy() { |
| 281 return last_observed_proxy_; | 283 return last_observed_proxy_; |
| 282 } | 284 } |
| 283 | 285 |
| 286 void set_can_be_intercepted_on_error(bool can_be_intercepted_on_error) { |
| 287 will_be_intercepted_on_next_error_ = can_be_intercepted_on_error; |
| 288 } |
| 289 |
| 284 protected: | 290 protected: |
| 285 // NetworkDelegate: | 291 // NetworkDelegate: |
| 286 int OnBeforeURLRequest(URLRequest* request, | 292 int OnBeforeURLRequest(URLRequest* request, |
| 287 const CompletionCallback& callback, | 293 const CompletionCallback& callback, |
| 288 GURL* new_url) override; | 294 GURL* new_url) override; |
| 289 int OnBeforeSendHeaders(URLRequest* request, | 295 int OnBeforeSendHeaders(URLRequest* request, |
| 290 const CompletionCallback& callback, | 296 const CompletionCallback& callback, |
| 291 HttpRequestHeaders* headers) override; | 297 HttpRequestHeaders* headers) override; |
| 292 void OnBeforeSendProxyHeaders(net::URLRequest* request, | 298 void OnBeforeSendProxyHeaders(net::URLRequest* request, |
| 293 const net::ProxyInfo& proxy_info, | 299 const net::ProxyInfo& proxy_info, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 int error_count_; | 342 int error_count_; |
| 337 int created_requests_; | 343 int created_requests_; |
| 338 int destroyed_requests_; | 344 int destroyed_requests_; |
| 339 int completed_requests_; | 345 int completed_requests_; |
| 340 int canceled_requests_; | 346 int canceled_requests_; |
| 341 int cookie_options_bit_mask_; | 347 int cookie_options_bit_mask_; |
| 342 int blocked_get_cookies_count_; | 348 int blocked_get_cookies_count_; |
| 343 int blocked_set_cookie_count_; | 349 int blocked_set_cookie_count_; |
| 344 int set_cookie_count_; | 350 int set_cookie_count_; |
| 345 int observed_before_proxy_headers_sent_callbacks_; | 351 int observed_before_proxy_headers_sent_callbacks_; |
| 352 int before_send_headers_count_; |
| 353 int headers_received_count_; |
| 346 // Last observed proxy in before proxy header sent callback. | 354 // Last observed proxy in before proxy header sent callback. |
| 347 HostPortPair last_observed_proxy_; | 355 HostPortPair last_observed_proxy_; |
| 348 | 356 |
| 349 // NetworkDelegate callbacks happen in a particular order (e.g. | 357 // NetworkDelegate callbacks happen in a particular order (e.g. |
| 350 // OnBeforeURLRequest is always called before OnBeforeSendHeaders). | 358 // OnBeforeURLRequest is always called before OnBeforeSendHeaders). |
| 351 // This bit-set indicates for each request id (key) what events may be sent | 359 // This bit-set indicates for each request id (key) what events may be sent |
| 352 // next. | 360 // next. |
| 353 std::map<int, int> next_states_; | 361 std::map<int, int> next_states_; |
| 354 | 362 |
| 355 // A log that records for each request id (key) the order in which On... | 363 // A log that records for each request id (key) the order in which On... |
| 356 // functions were called. | 364 // functions were called. |
| 357 std::map<int, std::string> event_order_; | 365 std::map<int, std::string> event_order_; |
| 358 | 366 |
| 359 LoadTimingInfo load_timing_info_before_redirect_; | 367 LoadTimingInfo load_timing_info_before_redirect_; |
| 360 bool has_load_timing_info_before_redirect_; | 368 bool has_load_timing_info_before_redirect_; |
| 361 | 369 |
| 362 LoadTimingInfo load_timing_info_before_auth_; | 370 LoadTimingInfo load_timing_info_before_auth_; |
| 363 bool has_load_timing_info_before_auth_; | 371 bool has_load_timing_info_before_auth_; |
| 364 | 372 |
| 365 bool can_access_files_; // true by default | 373 bool can_access_files_; // true by default |
| 366 bool can_throttle_requests_; // true by default | 374 bool can_throttle_requests_; // true by default |
| 367 bool cancel_request_with_policy_violating_referrer_; // false by default | 375 bool cancel_request_with_policy_violating_referrer_; // false by default |
| 376 bool will_be_intercepted_on_next_error_; |
| 368 }; | 377 }; |
| 369 | 378 |
| 370 // Overrides the host used by the LocalHttpTestServer in | 379 // Overrides the host used by the LocalHttpTestServer in |
| 371 // url_request_unittest.cc . This is used by the chrome_frame_net_tests due to | 380 // url_request_unittest.cc . This is used by the chrome_frame_net_tests due to |
| 372 // a mysterious bug when tests execute over the loopback adapter. See | 381 // a mysterious bug when tests execute over the loopback adapter. See |
| 373 // http://crbug.com/114369 . | 382 // http://crbug.com/114369 . |
| 374 class ScopedCustomUrlRequestTestHttpHost { | 383 class ScopedCustomUrlRequestTestHttpHost { |
| 375 public: | 384 public: |
| 376 // Sets the host name to be used. The previous hostname will be stored and | 385 // Sets the host name to be used. The previous hostname will be stored and |
| 377 // restored upon destruction. Note that if the lifetimes of two or more | 386 // restored upon destruction. Note that if the lifetimes of two or more |
| (...skipping 26 matching lines...) Expand all Loading... |
| 404 NetworkDelegate* network_delegate) const override; | 413 NetworkDelegate* network_delegate) const override; |
| 405 void set_main_intercept_job(URLRequestJob* job); | 414 void set_main_intercept_job(URLRequestJob* job); |
| 406 | 415 |
| 407 private: | 416 private: |
| 408 mutable URLRequestJob* main_intercept_job_; | 417 mutable URLRequestJob* main_intercept_job_; |
| 409 }; | 418 }; |
| 410 | 419 |
| 411 } // namespace net | 420 } // namespace net |
| 412 | 421 |
| 413 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 422 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |