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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/message_loop_proxy.h" |
16 #include "base/path_service.h" | 18 #include "base/path_service.h" |
17 #include "base/process_util.h" | 19 #include "base/process_util.h" |
18 #include "base/string_util.h" | 20 #include "base/string_util.h" |
19 #include "base/string16.h" | 21 #include "base/string16.h" |
20 #include "base/time.h" | 22 #include "base/time.h" |
21 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
22 #include "googleurl/src/url_util.h" | 24 #include "googleurl/src/url_util.h" |
23 #include "net/base/cert_verifier.h" | 25 #include "net/base/cert_verifier.h" |
24 #include "net/base/cookie_monster.h" | 26 #include "net/base/cookie_monster.h" |
25 #include "net/base/host_resolver.h" | 27 #include "net/base/host_resolver.h" |
26 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
27 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
28 #include "net/base/network_delegate.h" | 30 #include "net/base/network_delegate.h" |
29 #include "net/base/ssl_config_service_defaults.h" | 31 #include "net/base/ssl_config_service_defaults.h" |
30 #include "net/disk_cache/disk_cache.h" | 32 #include "net/disk_cache/disk_cache.h" |
31 #include "net/ftp/ftp_network_layer.h" | 33 #include "net/ftp/ftp_network_layer.h" |
32 #include "net/http/http_auth_handler_factory.h" | 34 #include "net/http/http_auth_handler_factory.h" |
33 #include "net/http/http_cache.h" | 35 #include "net/http/http_cache.h" |
34 #include "net/http/http_network_layer.h" | 36 #include "net/http/http_network_layer.h" |
35 #include "net/proxy/proxy_service.h" | 37 #include "net/proxy/proxy_service.h" |
36 #include "net/url_request/url_request.h" | 38 #include "net/url_request/url_request.h" |
37 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 40 #include "net/url_request/url_request_context_getter.h" |
38 #include "net/url_request/url_request_context_storage.h" | 41 #include "net/url_request/url_request_context_storage.h" |
39 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
40 | 43 |
41 using base::TimeDelta; | 44 using base::TimeDelta; |
42 | 45 |
43 //----------------------------------------------------------------------------- | 46 //----------------------------------------------------------------------------- |
44 | 47 |
45 class TestURLRequestContext : public net::URLRequestContext { | 48 class TestURLRequestContext : public net::URLRequestContext { |
46 public: | 49 public: |
47 TestURLRequestContext(); | 50 TestURLRequestContext(); |
(...skipping 18 matching lines...) Expand all Loading... |
66 protected: | 69 protected: |
67 virtual ~TestURLRequestContext(); | 70 virtual ~TestURLRequestContext(); |
68 | 71 |
69 private: | 72 private: |
70 bool initialized_; | 73 bool initialized_; |
71 net::URLRequestContextStorage context_storage_; | 74 net::URLRequestContextStorage context_storage_; |
72 }; | 75 }; |
73 | 76 |
74 //----------------------------------------------------------------------------- | 77 //----------------------------------------------------------------------------- |
75 | 78 |
| 79 // Used to return a dummy context, which lives on the message loop |
| 80 // given in the constructor. |
| 81 class TestURLRequestContextGetter : public net::URLRequestContextGetter { |
| 82 public: |
| 83 // |io_message_loop_proxy| must not be NULL. |
| 84 explicit TestURLRequestContextGetter( |
| 85 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); |
| 86 |
| 87 // net::URLRequestContextGetter implementation. |
| 88 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE; |
| 89 virtual scoped_refptr<base::MessageLoopProxy> |
| 90 GetIOMessageLoopProxy() const OVERRIDE; |
| 91 |
| 92 protected: |
| 93 virtual ~TestURLRequestContextGetter(); |
| 94 |
| 95 private: |
| 96 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 97 scoped_refptr<TestURLRequestContext> context_; |
| 98 }; |
| 99 |
| 100 //----------------------------------------------------------------------------- |
| 101 |
76 class TestURLRequest : public net::URLRequest { | 102 class TestURLRequest : public net::URLRequest { |
77 public: | 103 public: |
78 TestURLRequest(const GURL& url, Delegate* delegate); | 104 TestURLRequest(const GURL& url, Delegate* delegate); |
79 virtual ~TestURLRequest(); | 105 virtual ~TestURLRequest(); |
80 }; | 106 }; |
81 | 107 |
82 //----------------------------------------------------------------------------- | 108 //----------------------------------------------------------------------------- |
83 | 109 |
84 class TestDelegate : public net::URLRequest::Delegate { | 110 class TestDelegate : public net::URLRequest::Delegate { |
85 public: | 111 public: |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 288 |
263 private: | 289 private: |
264 static std::string value_; | 290 static std::string value_; |
265 const std::string old_value_; | 291 const std::string old_value_; |
266 const std::string new_value_; | 292 const std::string new_value_; |
267 | 293 |
268 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); | 294 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); |
269 }; | 295 }; |
270 | 296 |
271 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 297 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
OLD | NEW |