| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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_UNITTEST_H_ |    5 #ifndef NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 
|    6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |    6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 
|    7  |    7  | 
|    8 #include <stdlib.h> |    8 #include <stdlib.h> | 
|    9  |    9  | 
|   10 #include <sstream> |   10 #include <sstream> | 
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  197         cancel_in_getcookiesblocked_(false), |  197         cancel_in_getcookiesblocked_(false), | 
|  198         cancel_in_setcookieblocked_(false), |  198         cancel_in_setcookieblocked_(false), | 
|  199         quit_on_complete_(true), |  199         quit_on_complete_(true), | 
|  200         quit_on_redirect_(false), |  200         quit_on_redirect_(false), | 
|  201         allow_certificate_errors_(false), |  201         allow_certificate_errors_(false), | 
|  202         response_started_count_(0), |  202         response_started_count_(0), | 
|  203         received_bytes_count_(0), |  203         received_bytes_count_(0), | 
|  204         received_redirect_count_(0), |  204         received_redirect_count_(0), | 
|  205         blocked_get_cookies_count_(0), |  205         blocked_get_cookies_count_(0), | 
|  206         blocked_set_cookie_count_(0), |  206         blocked_set_cookie_count_(0), | 
 |  207         set_cookie_count_(0), | 
|  207         received_data_before_response_(false), |  208         received_data_before_response_(false), | 
|  208         request_failed_(false), |  209         request_failed_(false), | 
|  209         have_certificate_errors_(false), |  210         have_certificate_errors_(false), | 
|  210         buf_(new net::IOBuffer(kBufferSize)) { |  211         buf_(new net::IOBuffer(kBufferSize)) { | 
|  211   } |  212   } | 
|  212  |  213  | 
|  213   virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url, |  214   virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url, | 
|  214                                   bool* defer_redirect) { |  215                                   bool* defer_redirect) { | 
|  215     received_redirect_count_++; |  216     received_redirect_count_++; | 
|  216     if (quit_on_redirect_) { |  217     if (quit_on_redirect_) { | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  299     // The caller can control whether it needs all SSL requests to go through, |  300     // The caller can control whether it needs all SSL requests to go through, | 
|  300     // independent of any possible errors, or whether it wants SSL errors to |  301     // independent of any possible errors, or whether it wants SSL errors to | 
|  301     // cancel the request. |  302     // cancel the request. | 
|  302     have_certificate_errors_ = true; |  303     have_certificate_errors_ = true; | 
|  303     if (allow_certificate_errors_) |  304     if (allow_certificate_errors_) | 
|  304       request->ContinueDespiteLastError(); |  305       request->ContinueDespiteLastError(); | 
|  305     else |  306     else | 
|  306       request->Cancel(); |  307       request->Cancel(); | 
|  307   } |  308   } | 
|  308  |  309  | 
|  309   virtual void OnGetCookiesBlocked(URLRequest* request) { |  310   virtual void OnGetCookies(URLRequest* request, bool blocked_by_policy) { | 
|  310     blocked_get_cookies_count_++; |  311     if (blocked_by_policy) { | 
|  311     if (cancel_in_getcookiesblocked_) |  312       blocked_get_cookies_count_++; | 
|  312       request->Cancel(); |  313       if (cancel_in_getcookiesblocked_) | 
 |  314         request->Cancel(); | 
 |  315     } | 
|  313   } |  316   } | 
|  314  |  317  | 
|  315   virtual void OnSetCookieBlocked(URLRequest* request) { |  318   virtual void OnSetCookie(URLRequest* request, | 
|  316     blocked_set_cookie_count_++; |  319                            const std::string& cookie_line, | 
|  317     if (cancel_in_setcookieblocked_) |  320                            bool blocked_by_policy) { | 
|  318       request->Cancel(); |  321     if (blocked_by_policy) { | 
 |  322       blocked_set_cookie_count_++; | 
 |  323       if (cancel_in_setcookieblocked_) | 
 |  324         request->Cancel(); | 
 |  325     } else { | 
 |  326       set_cookie_count_++; | 
 |  327     } | 
|  319   } |  328   } | 
|  320  |  329  | 
|  321   void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } |  330   void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } | 
|  322   void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; } |  331   void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; } | 
|  323   void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; } |  332   void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; } | 
|  324   void set_cancel_in_received_data_pending(bool val) { |  333   void set_cancel_in_received_data_pending(bool val) { | 
|  325     cancel_in_rd_pending_ = val; |  334     cancel_in_rd_pending_ = val; | 
|  326   } |  335   } | 
|  327   void set_cancel_in_get_cookies_blocked(bool val) { |  336   void set_cancel_in_get_cookies_blocked(bool val) { | 
|  328     cancel_in_getcookiesblocked_ = val; |  337     cancel_in_getcookiesblocked_ = val; | 
|  329   } |  338   } | 
|  330   void set_cancel_in_set_cookie_blocked(bool val) { |  339   void set_cancel_in_set_cookie_blocked(bool val) { | 
|  331     cancel_in_setcookieblocked_ = val; |  340     cancel_in_setcookieblocked_ = val; | 
|  332   } |  341   } | 
|  333   void set_quit_on_complete(bool val) { quit_on_complete_ = val; } |  342   void set_quit_on_complete(bool val) { quit_on_complete_ = val; } | 
|  334   void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; } |  343   void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; } | 
|  335   void set_allow_certificate_errors(bool val) { |  344   void set_allow_certificate_errors(bool val) { | 
|  336     allow_certificate_errors_ = val; |  345     allow_certificate_errors_ = val; | 
|  337   } |  346   } | 
|  338   void set_username(const std::wstring& u) { username_ = u; } |  347   void set_username(const std::wstring& u) { username_ = u; } | 
|  339   void set_password(const std::wstring& p) { password_ = p; } |  348   void set_password(const std::wstring& p) { password_ = p; } | 
|  340  |  349  | 
|  341   // query state |  350   // query state | 
|  342   const std::string& data_received() const { return data_received_; } |  351   const std::string& data_received() const { return data_received_; } | 
|  343   int bytes_received() const { return static_cast<int>(data_received_.size()); } |  352   int bytes_received() const { return static_cast<int>(data_received_.size()); } | 
|  344   int response_started_count() const { return response_started_count_; } |  353   int response_started_count() const { return response_started_count_; } | 
|  345   int received_redirect_count() const { return received_redirect_count_; } |  354   int received_redirect_count() const { return received_redirect_count_; } | 
|  346   int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } |  355   int blocked_get_cookies_count() const { return blocked_get_cookies_count_; } | 
|  347   int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } |  356   int blocked_set_cookie_count() const { return blocked_set_cookie_count_; } | 
 |  357   int set_cookie_count() const { return set_cookie_count_; } | 
|  348   bool received_data_before_response() const { |  358   bool received_data_before_response() const { | 
|  349     return received_data_before_response_; |  359     return received_data_before_response_; | 
|  350   } |  360   } | 
|  351   bool request_failed() const { return request_failed_; } |  361   bool request_failed() const { return request_failed_; } | 
|  352   bool have_certificate_errors() const { return have_certificate_errors_; } |  362   bool have_certificate_errors() const { return have_certificate_errors_; } | 
|  353  |  363  | 
|  354  private: |  364  private: | 
|  355   static const int kBufferSize = 4096; |  365   static const int kBufferSize = 4096; | 
|  356   // options for controlling behavior |  366   // options for controlling behavior | 
|  357   bool cancel_in_rr_; |  367   bool cancel_in_rr_; | 
|  358   bool cancel_in_rs_; |  368   bool cancel_in_rs_; | 
|  359   bool cancel_in_rd_; |  369   bool cancel_in_rd_; | 
|  360   bool cancel_in_rd_pending_; |  370   bool cancel_in_rd_pending_; | 
|  361   bool cancel_in_getcookiesblocked_; |  371   bool cancel_in_getcookiesblocked_; | 
|  362   bool cancel_in_setcookieblocked_; |  372   bool cancel_in_setcookieblocked_; | 
|  363   bool quit_on_complete_; |  373   bool quit_on_complete_; | 
|  364   bool quit_on_redirect_; |  374   bool quit_on_redirect_; | 
|  365   bool allow_certificate_errors_; |  375   bool allow_certificate_errors_; | 
|  366  |  376  | 
|  367   std::wstring username_; |  377   std::wstring username_; | 
|  368   std::wstring password_; |  378   std::wstring password_; | 
|  369  |  379  | 
|  370   // tracks status of callbacks |  380   // tracks status of callbacks | 
|  371   int response_started_count_; |  381   int response_started_count_; | 
|  372   int received_bytes_count_; |  382   int received_bytes_count_; | 
|  373   int received_redirect_count_; |  383   int received_redirect_count_; | 
|  374   int blocked_get_cookies_count_; |  384   int blocked_get_cookies_count_; | 
|  375   int blocked_set_cookie_count_; |  385   int blocked_set_cookie_count_; | 
 |  386   int set_cookie_count_; | 
|  376   bool received_data_before_response_; |  387   bool received_data_before_response_; | 
|  377   bool request_failed_; |  388   bool request_failed_; | 
|  378   bool have_certificate_errors_; |  389   bool have_certificate_errors_; | 
|  379   std::string data_received_; |  390   std::string data_received_; | 
|  380  |  391  | 
|  381   // our read buffer |  392   // our read buffer | 
|  382   scoped_refptr<net::IOBuffer> buf_; |  393   scoped_refptr<net::IOBuffer> buf_; | 
|  383 }; |  394 }; | 
|  384  |  395  | 
|  385 //----------------------------------------------------------------------------- |  396 //----------------------------------------------------------------------------- | 
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  751       return false; |  762       return false; | 
|  752  |  763  | 
|  753     return true; |  764     return true; | 
|  754   } |  765   } | 
|  755  |  766  | 
|  756  private: |  767  private: | 
|  757   ~FTPTestServer() {} |  768   ~FTPTestServer() {} | 
|  758 }; |  769 }; | 
|  759  |  770  | 
|  760 #endif  // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |  771 #endif  // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 
| OLD | NEW |