| 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 |
| 11 #include <sstream> | 11 #include <sstream> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "googleurl/src/url_util.h" |
| 20 #include "net/base/cert_verifier.h" | 21 #include "net/base/cert_verifier.h" |
| 21 #include "net/base/cookie_monster.h" | 22 #include "net/base/cookie_monster.h" |
| 22 #include "net/base/host_resolver.h" | 23 #include "net/base/host_resolver.h" |
| 23 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 24 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 25 #include "net/base/network_delegate.h" | 26 #include "net/base/network_delegate.h" |
| 26 #include "net/base/ssl_config_service_defaults.h" | 27 #include "net/base/ssl_config_service_defaults.h" |
| 27 #include "net/disk_cache/disk_cache.h" | 28 #include "net/disk_cache/disk_cache.h" |
| 28 #include "net/ftp/ftp_network_layer.h" | 29 #include "net/ftp/ftp_network_layer.h" |
| 29 #include "net/http/http_auth_handler_factory.h" | 30 #include "net/http/http_auth_handler_factory.h" |
| 30 #include "net/http/http_cache.h" | 31 #include "net/http/http_cache.h" |
| 31 #include "net/http/http_network_layer.h" | 32 #include "net/http/http_network_layer.h" |
| 33 #include "net/proxy/proxy_service.h" |
| 32 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
| 33 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 34 #include "net/url_request/url_request_context_storage.h" | 36 #include "net/url_request/url_request_context_storage.h" |
| 35 #include "net/proxy/proxy_service.h" | |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include "googleurl/src/url_util.h" | |
| 38 | 38 |
| 39 using base::TimeDelta; | 39 using base::TimeDelta; |
| 40 | 40 |
| 41 namespace net { | 41 namespace net { |
| 42 class HostPortPair; | 42 class HostPortPair; |
| 43 } | 43 } |
| 44 | 44 |
| 45 //----------------------------------------------------------------------------- | 45 //----------------------------------------------------------------------------- |
| 46 | 46 |
| 47 class TestURLRequestContext : public net::URLRequestContext { | 47 class TestURLRequestContext : public net::URLRequestContext { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 scoped_refptr<net::IOBuffer> buf_; | 174 scoped_refptr<net::IOBuffer> buf_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 //----------------------------------------------------------------------------- | 177 //----------------------------------------------------------------------------- |
| 178 | 178 |
| 179 class TestNetworkDelegate : public net::NetworkDelegate { | 179 class TestNetworkDelegate : public net::NetworkDelegate { |
| 180 public: | 180 public: |
| 181 TestNetworkDelegate(); | 181 TestNetworkDelegate(); |
| 182 virtual ~TestNetworkDelegate(); | 182 virtual ~TestNetworkDelegate(); |
| 183 | 183 |
| 184 int last_os_error() const { return last_os_error_; } | 184 int last_error() const { return last_error_; } |
| 185 int error_count() const { return error_count_; } | 185 int error_count() const { return error_count_; } |
| 186 int created_requests() const { return created_requests_; } | 186 int created_requests() const { return created_requests_; } |
| 187 int destroyed_requests() const { return destroyed_requests_; } | 187 int destroyed_requests() const { return destroyed_requests_; } |
| 188 int completed_requests() const { return completed_requests_; } | 188 int completed_requests() const { return completed_requests_; } |
| 189 | 189 |
| 190 protected: | 190 protected: |
| 191 // net::NetworkDelegate: | 191 // net::NetworkDelegate: |
| 192 virtual int OnBeforeURLRequest(net::URLRequest* request, | 192 virtual int OnBeforeURLRequest(net::URLRequest* request, |
| 193 net::CompletionCallback* callback, | 193 net::CompletionCallback* callback, |
| 194 GURL* new_url); | 194 GURL* new_url); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 205 virtual void OnURLRequestDestroyed(net::URLRequest* request); | 205 virtual void OnURLRequestDestroyed(net::URLRequest* request); |
| 206 virtual void OnHttpTransactionDestroyed(uint64 request_id); | 206 virtual void OnHttpTransactionDestroyed(uint64 request_id); |
| 207 virtual net::URLRequestJob* OnMaybeCreateURLRequestJob( | 207 virtual net::URLRequestJob* OnMaybeCreateURLRequestJob( |
| 208 net::URLRequest* request); | 208 net::URLRequest* request); |
| 209 virtual void OnPACScriptError(int line_number, const string16& error); | 209 virtual void OnPACScriptError(int line_number, const string16& error); |
| 210 virtual void OnAuthRequired(net::URLRequest* request, | 210 virtual void OnAuthRequired(net::URLRequest* request, |
| 211 const net::AuthChallengeInfo& auth_info); | 211 const net::AuthChallengeInfo& auth_info); |
| 212 | 212 |
| 213 void InitRequestStatesIfNew(int request_id); | 213 void InitRequestStatesIfNew(int request_id); |
| 214 | 214 |
| 215 int last_os_error_; | 215 int last_error_; |
| 216 int error_count_; | 216 int error_count_; |
| 217 int created_requests_; | 217 int created_requests_; |
| 218 int destroyed_requests_; | 218 int destroyed_requests_; |
| 219 int completed_requests_; | 219 int completed_requests_; |
| 220 | 220 |
| 221 // net::NetworkDelegate callbacks happen in a particular order (e.g. | 221 // net::NetworkDelegate callbacks happen in a particular order (e.g. |
| 222 // OnBeforeURLRequest is always called before OnBeforeSendHeaders). | 222 // OnBeforeURLRequest is always called before OnBeforeSendHeaders). |
| 223 // This bit-set indicates for each request id (key) what events may be sent | 223 // This bit-set indicates for each request id (key) what events may be sent |
| 224 // next. | 224 // next. |
| 225 std::map<int, int> next_states_; | 225 std::map<int, int> next_states_; |
| 226 | 226 |
| 227 // A log that records for each request id (key) the order in which On... | 227 // A log that records for each request id (key) the order in which On... |
| 228 // functions were called. | 228 // functions were called. |
| 229 std::map<int, std::string> event_order_; | 229 std::map<int, std::string> event_order_; |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 232 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |