| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void set_cancel_in_set_cookie_blocked(bool val) { | 114 void set_cancel_in_set_cookie_blocked(bool val) { |
| 115 cancel_in_setcookieblocked_ = val; | 115 cancel_in_setcookieblocked_ = val; |
| 116 } | 116 } |
| 117 void set_quit_on_complete(bool val) { quit_on_complete_ = val; } | 117 void set_quit_on_complete(bool val) { quit_on_complete_ = val; } |
| 118 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; } | 118 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; } |
| 119 void set_allow_certificate_errors(bool val) { | 119 void set_allow_certificate_errors(bool val) { |
| 120 allow_certificate_errors_ = val; | 120 allow_certificate_errors_ = val; |
| 121 } | 121 } |
| 122 void set_username(const string16& u) { username_ = u; } | 122 void set_username(const string16& u) { username_ = u; } |
| 123 void set_password(const string16& p) { password_ = p; } | 123 void set_password(const string16& p) { password_ = p; } |
| 124 void set_tls_username(const string16& u) { tls_username_ = u; } |
| 125 void set_tls_password(const string16& p) { tls_password_ = p; } |
| 124 | 126 |
| 125 // query state | 127 // query state |
| 126 const std::string& data_received() const { return data_received_; } | 128 const std::string& data_received() const { return data_received_; } |
| 127 int bytes_received() const { return static_cast<int>(data_received_.size()); } | 129 int bytes_received() const { return static_cast<int>(data_received_.size()); } |
| 128 int response_started_count() const { return response_started_count_; } | 130 int response_started_count() const { return response_started_count_; } |
| 129 int received_redirect_count() const { return received_redirect_count_; } | 131 int received_redirect_count() const { return received_redirect_count_; } |
| 130 int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } | 132 int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } |
| 131 int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } | 133 int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } |
| 132 int set_cookie_count() const { return set_cookie_count_; } | 134 int set_cookie_count() const { return set_cookie_count_; } |
| 133 bool received_data_before_response() const { | 135 bool received_data_before_response() const { |
| 134 return received_data_before_response_; | 136 return received_data_before_response_; |
| 135 } | 137 } |
| 136 bool request_failed() const { return request_failed_; } | 138 bool request_failed() const { return request_failed_; } |
| 137 bool have_certificate_errors() const { return have_certificate_errors_; } | 139 bool have_certificate_errors() const { return have_certificate_errors_; } |
| 138 | 140 |
| 139 // net::URLRequest::Delegate: | 141 // net::URLRequest::Delegate: |
| 140 virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url, | 142 virtual void OnReceivedRedirect(net::URLRequest* request, const GURL& new_url, |
| 141 bool* defer_redirect); | 143 bool* defer_redirect); |
| 142 virtual void OnAuthRequired(net::URLRequest* request, | 144 virtual void OnAuthRequired(net::URLRequest* request, |
| 143 net::AuthChallengeInfo* auth_info); | 145 net::AuthChallengeInfo* auth_info); |
| 146 virtual void OnTLSLoginRequired(net::URLRequest* request, |
| 147 net::AuthChallengeInfo* login_request_info); |
| 144 virtual void OnSSLCertificateError(net::URLRequest* request, | 148 virtual void OnSSLCertificateError(net::URLRequest* request, |
| 145 int cert_error, | 149 int cert_error, |
| 146 net::X509Certificate* cert); | 150 net::X509Certificate* cert); |
| 147 virtual void OnGetCookies(net::URLRequest* request, bool blocked_by_policy); | 151 virtual void OnGetCookies(net::URLRequest* request, bool blocked_by_policy); |
| 148 virtual void OnSetCookie(net::URLRequest* request, | 152 virtual void OnSetCookie(net::URLRequest* request, |
| 149 const std::string& cookie_line, | 153 const std::string& cookie_line, |
| 150 const net::CookieOptions& options, | 154 const net::CookieOptions& options, |
| 151 bool blocked_by_policy); | 155 bool blocked_by_policy); |
| 152 virtual void OnResponseStarted(net::URLRequest* request); | 156 virtual void OnResponseStarted(net::URLRequest* request); |
| 153 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); | 157 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); |
| 154 | 158 |
| 155 private: | 159 private: |
| 156 static const int kBufferSize = 4096; | 160 static const int kBufferSize = 4096; |
| 157 | 161 |
| 158 virtual void OnResponseCompleted(net::URLRequest* request); | 162 virtual void OnResponseCompleted(net::URLRequest* request); |
| 159 | 163 |
| 160 // options for controlling behavior | 164 // options for controlling behavior |
| 161 bool cancel_in_rr_; | 165 bool cancel_in_rr_; |
| 162 bool cancel_in_rs_; | 166 bool cancel_in_rs_; |
| 163 bool cancel_in_rd_; | 167 bool cancel_in_rd_; |
| 164 bool cancel_in_rd_pending_; | 168 bool cancel_in_rd_pending_; |
| 165 bool cancel_in_getcookiesblocked_; | 169 bool cancel_in_getcookiesblocked_; |
| 166 bool cancel_in_setcookieblocked_; | 170 bool cancel_in_setcookieblocked_; |
| 167 bool quit_on_complete_; | 171 bool quit_on_complete_; |
| 168 bool quit_on_redirect_; | 172 bool quit_on_redirect_; |
| 169 bool allow_certificate_errors_; | 173 bool allow_certificate_errors_; |
| 170 | 174 |
| 171 string16 username_; | 175 string16 username_; |
| 172 string16 password_; | 176 string16 password_; |
| 177 string16 tls_username_; |
| 178 string16 tls_password_; |
| 173 | 179 |
| 174 // tracks status of callbacks | 180 // tracks status of callbacks |
| 175 int response_started_count_; | 181 int response_started_count_; |
| 176 int received_bytes_count_; | 182 int received_bytes_count_; |
| 177 int received_redirect_count_; | 183 int received_redirect_count_; |
| 178 int blocked_get_cookies_count_; | 184 int blocked_get_cookies_count_; |
| 179 int blocked_set_cookie_count_; | 185 int blocked_set_cookie_count_; |
| 180 int set_cookie_count_; | 186 int set_cookie_count_; |
| 181 bool received_data_before_response_; | 187 bool received_data_before_response_; |
| 182 bool request_failed_; | 188 bool request_failed_; |
| 183 bool have_certificate_errors_; | 189 bool have_certificate_errors_; |
| 184 std::string data_received_; | 190 std::string data_received_; |
| 185 | 191 |
| 186 // our read buffer | 192 // our read buffer |
| 187 scoped_refptr<net::IOBuffer> buf_; | 193 scoped_refptr<net::IOBuffer> buf_; |
| 188 }; | 194 }; |
| 189 | 195 |
| 190 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 196 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |