| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 bool have_certificate_errors() const { return have_certificate_errors_; } | 173 bool have_certificate_errors() const { return have_certificate_errors_; } |
| 174 bool certificate_errors_are_fatal() const { | 174 bool certificate_errors_are_fatal() const { |
| 175 return certificate_errors_are_fatal_; | 175 return certificate_errors_are_fatal_; |
| 176 } | 176 } |
| 177 bool auth_required_called() const { return auth_required_; } | 177 bool auth_required_called() const { return auth_required_; } |
| 178 bool have_full_request_headers() const { return have_full_request_headers_; } | 178 bool have_full_request_headers() const { return have_full_request_headers_; } |
| 179 const HttpRequestHeaders& full_request_headers() const { | 179 const HttpRequestHeaders& full_request_headers() const { |
| 180 return full_request_headers_; | 180 return full_request_headers_; |
| 181 } | 181 } |
| 182 void ClearFullRequestHeaders(); | 182 void ClearFullRequestHeaders(); |
| 183 int request_status() const { return request_status_; } |
| 183 | 184 |
| 184 // URLRequest::Delegate: | 185 // URLRequest::Delegate: |
| 185 void OnReceivedRedirect(URLRequest* request, | 186 void OnReceivedRedirect(URLRequest* request, |
| 186 const RedirectInfo& redirect_info, | 187 const RedirectInfo& redirect_info, |
| 187 bool* defer_redirect) override; | 188 bool* defer_redirect) override; |
| 188 void OnAuthRequired(URLRequest* request, | 189 void OnAuthRequired(URLRequest* request, |
| 189 AuthChallengeInfo* auth_info) override; | 190 AuthChallengeInfo* auth_info) override; |
| 190 // NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true. | 191 // NOTE: |fatal| causes |certificate_errors_are_fatal_| to be set to true. |
| 191 // (Unit tests use this as a post-condition.) But for policy, this method | 192 // (Unit tests use this as a post-condition.) But for policy, this method |
| 192 // consults |allow_certificate_errors_|. | 193 // consults |allow_certificate_errors_|. |
| 193 void OnSSLCertificateError(URLRequest* request, | 194 void OnSSLCertificateError(URLRequest* request, |
| 194 const SSLInfo& ssl_info, | 195 const SSLInfo& ssl_info, |
| 195 bool fatal) override; | 196 bool fatal) override; |
| 197 void OnResponseStarted(URLRequest* request, int net_error) override; |
| 198 // Deprecated. |
| 196 void OnResponseStarted(URLRequest* request) override; | 199 void OnResponseStarted(URLRequest* request) override; |
| 197 void OnReadCompleted(URLRequest* request, int bytes_read) override; | 200 void OnReadCompleted(URLRequest* request, int bytes_read) override; |
| 198 | 201 |
| 199 private: | 202 private: |
| 200 static const int kBufferSize = 4096; | 203 static const int kBufferSize = 4096; |
| 201 | 204 |
| 202 virtual void OnResponseCompleted(URLRequest* request); | 205 virtual void OnResponseCompleted(URLRequest* request); |
| 203 | 206 |
| 204 // options for controlling behavior | 207 // options for controlling behavior |
| 205 bool cancel_in_rr_; | 208 bool cancel_in_rr_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 218 int received_redirect_count_; | 221 int received_redirect_count_; |
| 219 bool received_data_before_response_; | 222 bool received_data_before_response_; |
| 220 bool request_failed_; | 223 bool request_failed_; |
| 221 bool have_certificate_errors_; | 224 bool have_certificate_errors_; |
| 222 bool certificate_errors_are_fatal_; | 225 bool certificate_errors_are_fatal_; |
| 223 bool auth_required_; | 226 bool auth_required_; |
| 224 std::string data_received_; | 227 std::string data_received_; |
| 225 bool have_full_request_headers_; | 228 bool have_full_request_headers_; |
| 226 HttpRequestHeaders full_request_headers_; | 229 HttpRequestHeaders full_request_headers_; |
| 227 | 230 |
| 231 // tracks status of request |
| 232 int request_status_; |
| 233 |
| 228 // our read buffer | 234 // our read buffer |
| 229 scoped_refptr<IOBuffer> buf_; | 235 scoped_refptr<IOBuffer> buf_; |
| 236 |
| 237 // Temporarly used to distinguish old and new code. |
| 238 bool old_; |
| 230 }; | 239 }; |
| 231 | 240 |
| 232 //----------------------------------------------------------------------------- | 241 //----------------------------------------------------------------------------- |
| 233 | 242 |
| 234 class TestNetworkDelegate : public NetworkDelegateImpl { | 243 class TestNetworkDelegate : public NetworkDelegateImpl { |
| 235 public: | 244 public: |
| 236 enum Options { | 245 enum Options { |
| 237 NO_GET_COOKIES = 1 << 0, | 246 NO_GET_COOKIES = 1 << 0, |
| 238 NO_SET_COOKIE = 1 << 1, | 247 NO_SET_COOKIE = 1 << 1, |
| 239 }; | 248 }; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 HttpRequestHeaders* headers) override; | 329 HttpRequestHeaders* headers) override; |
| 321 void OnStartTransaction(URLRequest* request, | 330 void OnStartTransaction(URLRequest* request, |
| 322 const HttpRequestHeaders& headers) override; | 331 const HttpRequestHeaders& headers) override; |
| 323 int OnHeadersReceived( | 332 int OnHeadersReceived( |
| 324 URLRequest* request, | 333 URLRequest* request, |
| 325 const CompletionCallback& callback, | 334 const CompletionCallback& callback, |
| 326 const HttpResponseHeaders* original_response_headers, | 335 const HttpResponseHeaders* original_response_headers, |
| 327 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 336 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 328 GURL* allowed_unsafe_redirect_url) override; | 337 GURL* allowed_unsafe_redirect_url) override; |
| 329 void OnBeforeRedirect(URLRequest* request, const GURL& new_location) override; | 338 void OnBeforeRedirect(URLRequest* request, const GURL& new_location) override; |
| 339 void OnResponseStarted(URLRequest* request, int net_error) override; |
| 340 // Deprecated. |
| 330 void OnResponseStarted(URLRequest* request) override; | 341 void OnResponseStarted(URLRequest* request) override; |
| 331 void OnNetworkBytesReceived(URLRequest* request, | 342 void OnNetworkBytesReceived(URLRequest* request, |
| 332 int64_t bytes_received) override; | 343 int64_t bytes_received) override; |
| 333 void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) override; | 344 void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) override; |
| 345 void OnCompleted(URLRequest* request, bool started, int net_error) override; |
| 346 // Deprecated. |
| 334 void OnCompleted(URLRequest* request, bool started) override; | 347 void OnCompleted(URLRequest* request, bool started) override; |
| 335 void OnURLRequestDestroyed(URLRequest* request) override; | 348 void OnURLRequestDestroyed(URLRequest* request) override; |
| 336 void OnPACScriptError(int line_number, const base::string16& error) override; | 349 void OnPACScriptError(int line_number, const base::string16& error) override; |
| 337 NetworkDelegate::AuthRequiredResponse OnAuthRequired( | 350 NetworkDelegate::AuthRequiredResponse OnAuthRequired( |
| 338 URLRequest* request, | 351 URLRequest* request, |
| 339 const AuthChallengeInfo& auth_info, | 352 const AuthChallengeInfo& auth_info, |
| 340 const AuthCallback& callback, | 353 const AuthCallback& callback, |
| 341 AuthCredentials* credentials) override; | 354 AuthCredentials* credentials) override; |
| 342 bool OnCanGetCookies(const URLRequest& request, | 355 bool OnCanGetCookies(const URLRequest& request, |
| 343 const CookieList& cookie_list) override; | 356 const CookieList& cookie_list) override; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 NetworkDelegate* network_delegate) const override; | 425 NetworkDelegate* network_delegate) const override; |
| 413 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); | 426 void set_main_intercept_job(std::unique_ptr<URLRequestJob> job); |
| 414 | 427 |
| 415 private: | 428 private: |
| 416 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; | 429 mutable std::unique_ptr<URLRequestJob> main_intercept_job_; |
| 417 }; | 430 }; |
| 418 | 431 |
| 419 } // namespace net | 432 } // namespace net |
| 420 | 433 |
| 421 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 434 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |