| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 int response_started_count() const { return response_started_count_; } | 113 int response_started_count() const { return response_started_count_; } |
| 114 int received_redirect_count() const { return received_redirect_count_; } | 114 int received_redirect_count() const { return received_redirect_count_; } |
| 115 int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } | 115 int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } |
| 116 int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } | 116 int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } |
| 117 int set_cookie_count() const { return set_cookie_count_; } | 117 int set_cookie_count() const { return set_cookie_count_; } |
| 118 bool received_data_before_response() const { | 118 bool received_data_before_response() const { |
| 119 return received_data_before_response_; | 119 return received_data_before_response_; |
| 120 } | 120 } |
| 121 bool request_failed() const { return request_failed_; } | 121 bool request_failed() const { return request_failed_; } |
| 122 bool have_certificate_errors() const { return have_certificate_errors_; } | 122 bool have_certificate_errors() const { return have_certificate_errors_; } |
| 123 bool is_hsts_host() const { return is_hsts_host_; } | 123 bool certificate_errors_are_fatal() const { |
| 124 return certificate_errors_are_fatal_; |
| 125 } |
| 124 bool auth_required_called() const { return auth_required_; } | 126 bool auth_required_called() const { return auth_required_; } |
| 125 | 127 |
| 126 // net::URLRequest::Delegate: | 128 // net::URLRequest::Delegate: |
| 127 virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url, | 129 virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url, |
| 128 bool* defer_redirect) OVERRIDE; | 130 bool* defer_redirect) OVERRIDE; |
| 129 virtual void OnAuthRequired(net::URLRequest* request, | 131 virtual void OnAuthRequired(net::URLRequest* request, |
| 130 net::AuthChallengeInfo* auth_info) OVERRIDE; | 132 net::AuthChallengeInfo* auth_info) OVERRIDE; |
| 133 // NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true. |
| 134 // (Unit tests use this as a post-condition.) But for policy, this method |
| 135 // consults |allow_certificate_errors_|. |
| 131 virtual void OnSSLCertificateError(net::URLRequest* request, | 136 virtual void OnSSLCertificateError(net::URLRequest* request, |
| 132 const net::SSLInfo& ssl_info, | 137 const net::SSLInfo& ssl_info, |
| 133 bool is_hsts_host) OVERRIDE; | 138 bool fatal) OVERRIDE; |
| 134 virtual bool CanGetCookies(const net::URLRequest* request, | 139 virtual bool CanGetCookies(const net::URLRequest* request, |
| 135 const net::CookieList& cookie_list) const OVERRIDE; | 140 const net::CookieList& cookie_list) const OVERRIDE; |
| 136 virtual bool CanSetCookie(const net::URLRequest* request, | 141 virtual bool CanSetCookie(const net::URLRequest* request, |
| 137 const std::string& cookie_line, | 142 const std::string& cookie_line, |
| 138 net::CookieOptions* options) const OVERRIDE; | 143 net::CookieOptions* options) const OVERRIDE; |
| 139 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | 144 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; |
| 140 virtual void OnReadCompleted(net::URLRequest* request, | 145 virtual void OnReadCompleted(net::URLRequest* request, |
| 141 int bytes_read) OVERRIDE; | 146 int bytes_read) OVERRIDE; |
| 142 | 147 |
| 143 private: | 148 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 159 // tracks status of callbacks | 164 // tracks status of callbacks |
| 160 int response_started_count_; | 165 int response_started_count_; |
| 161 int received_bytes_count_; | 166 int received_bytes_count_; |
| 162 int received_redirect_count_; | 167 int received_redirect_count_; |
| 163 mutable int blocked_get_cookies_count_; | 168 mutable int blocked_get_cookies_count_; |
| 164 mutable int blocked_set_cookie_count_; | 169 mutable int blocked_set_cookie_count_; |
| 165 mutable int set_cookie_count_; | 170 mutable int set_cookie_count_; |
| 166 bool received_data_before_response_; | 171 bool received_data_before_response_; |
| 167 bool request_failed_; | 172 bool request_failed_; |
| 168 bool have_certificate_errors_; | 173 bool have_certificate_errors_; |
| 169 bool is_hsts_host_; | 174 bool certificate_errors_are_fatal_; |
| 170 bool auth_required_; | 175 bool auth_required_; |
| 171 std::string data_received_; | 176 std::string data_received_; |
| 172 | 177 |
| 173 // our read buffer | 178 // our read buffer |
| 174 scoped_refptr<net::IOBuffer> buf_; | 179 scoped_refptr<net::IOBuffer> buf_; |
| 175 }; | 180 }; |
| 176 | 181 |
| 177 //----------------------------------------------------------------------------- | 182 //----------------------------------------------------------------------------- |
| 178 | 183 |
| 179 class TestNetworkDelegate : public net::NetworkDelegate { | 184 class TestNetworkDelegate : public net::NetworkDelegate { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // This bit-set indicates for each request id (key) what events may be sent | 236 // This bit-set indicates for each request id (key) what events may be sent |
| 232 // next. | 237 // next. |
| 233 std::map<int, int> next_states_; | 238 std::map<int, int> next_states_; |
| 234 | 239 |
| 235 // A log that records for each request id (key) the order in which On... | 240 // A log that records for each request id (key) the order in which On... |
| 236 // functions were called. | 241 // functions were called. |
| 237 std::map<int, std::string> event_order_; | 242 std::map<int, std::string> event_order_; |
| 238 }; | 243 }; |
| 239 | 244 |
| 240 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 245 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |