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 10 matching lines...) Expand all Loading... |
21 #include "net/base/cookie_monster.h" | 21 #include "net/base/cookie_monster.h" |
22 #include "net/base/cookie_policy.h" | 22 #include "net/base/cookie_policy.h" |
23 #include "net/base/host_resolver.h" | 23 #include "net/base/host_resolver.h" |
24 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
26 #include "net/base/ssl_config_service_defaults.h" | 26 #include "net/base/ssl_config_service_defaults.h" |
27 #include "net/disk_cache/disk_cache.h" | 27 #include "net/disk_cache/disk_cache.h" |
28 #include "net/ftp/ftp_network_layer.h" | 28 #include "net/ftp/ftp_network_layer.h" |
29 #include "net/http/http_auth_handler_factory.h" | 29 #include "net/http/http_auth_handler_factory.h" |
30 #include "net/http/http_cache.h" | 30 #include "net/http/http_cache.h" |
| 31 #include "net/http/http_network_delegate.h" |
31 #include "net/http/http_network_layer.h" | 32 #include "net/http/http_network_layer.h" |
32 #include "net/test/test_server.h" | 33 #include "net/test/test_server.h" |
33 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
35 #include "net/proxy/proxy_service.h" | 36 #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 #include "googleurl/src/url_util.h" |
38 | 39 |
39 using base::TimeDelta; | 40 using base::TimeDelta; |
40 | 41 |
(...skipping 27 matching lines...) Expand all Loading... |
68 int options_; | 69 int options_; |
69 net::CompletionCallback* callback_; | 70 net::CompletionCallback* callback_; |
70 }; | 71 }; |
71 | 72 |
72 //----------------------------------------------------------------------------- | 73 //----------------------------------------------------------------------------- |
73 | 74 |
74 class TestURLRequestContext : public net::URLRequestContext { | 75 class TestURLRequestContext : public net::URLRequestContext { |
75 public: | 76 public: |
76 TestURLRequestContext(); | 77 TestURLRequestContext(); |
77 explicit TestURLRequestContext(const std::string& proxy); | 78 explicit TestURLRequestContext(const std::string& proxy); |
| 79 TestURLRequestContext(const std::string& proxy, |
| 80 net::HostResolver* host_resolver); |
78 | 81 |
79 protected: | 82 protected: |
80 virtual ~TestURLRequestContext(); | 83 virtual ~TestURLRequestContext(); |
81 | 84 |
82 private: | 85 private: |
83 void Init(); | 86 void Init(); |
84 }; | 87 }; |
85 | 88 |
86 //----------------------------------------------------------------------------- | 89 //----------------------------------------------------------------------------- |
87 | 90 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 int set_cookie_count_; | 179 int set_cookie_count_; |
177 bool received_data_before_response_; | 180 bool received_data_before_response_; |
178 bool request_failed_; | 181 bool request_failed_; |
179 bool have_certificate_errors_; | 182 bool have_certificate_errors_; |
180 std::string data_received_; | 183 std::string data_received_; |
181 | 184 |
182 // our read buffer | 185 // our read buffer |
183 scoped_refptr<net::IOBuffer> buf_; | 186 scoped_refptr<net::IOBuffer> buf_; |
184 }; | 187 }; |
185 | 188 |
| 189 //----------------------------------------------------------------------------- |
| 190 |
| 191 class TestHttpNetworkDelegate : public net::HttpNetworkDelegate { |
| 192 public: |
| 193 TestHttpNetworkDelegate(); |
| 194 virtual ~TestHttpNetworkDelegate(); |
| 195 |
| 196 // net::HttpNetworkDelegate: |
| 197 virtual void OnBeforeURLRequest(net::URLRequest* request); |
| 198 virtual void OnSendHttpRequest(net::HttpRequestHeaders* headers); |
| 199 virtual void OnResponseStarted(net::URLRequest* request); |
| 200 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read); |
| 201 |
| 202 int last_os_error() const { return last_os_error_; } |
| 203 int error_count() const { return error_count_; } |
| 204 |
| 205 private: |
| 206 int last_os_error_; |
| 207 int error_count_; |
| 208 }; |
| 209 |
186 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 210 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
OLD | NEW |