| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 ScopedRunnableMethodFactory<TestCookiePolicy> method_factory_; | 124 ScopedRunnableMethodFactory<TestCookiePolicy> method_factory_; |
| 125 int options_; | 125 int options_; |
| 126 net::CompletionCallback* callback_; | 126 net::CompletionCallback* callback_; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 //----------------------------------------------------------------------------- | 129 //----------------------------------------------------------------------------- |
| 130 | 130 |
| 131 class TestURLRequestContext : public URLRequestContext { | 131 class TestURLRequestContext : public URLRequestContext { |
| 132 public: | 132 public: |
| 133 TestURLRequestContext() { | 133 TestURLRequestContext() { |
| 134 host_resolver_ = net::CreateSystemHostResolver(NULL); | 134 host_resolver_ = net::CreateSystemHostResolver(); |
| 135 proxy_service_ = net::ProxyService::CreateNull(); | 135 proxy_service_ = net::ProxyService::CreateNull(); |
| 136 Init(); | 136 Init(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 explicit TestURLRequestContext(const std::string& proxy) { | 139 explicit TestURLRequestContext(const std::string& proxy) { |
| 140 host_resolver_ = net::CreateSystemHostResolver(NULL); | 140 host_resolver_ = net::CreateSystemHostResolver(); |
| 141 net::ProxyConfig proxy_config; | 141 net::ProxyConfig proxy_config; |
| 142 proxy_config.proxy_rules().ParseFromString(proxy); | 142 proxy_config.proxy_rules().ParseFromString(proxy); |
| 143 proxy_service_ = net::ProxyService::CreateFixed(proxy_config); | 143 proxy_service_ = net::ProxyService::CreateFixed(proxy_config); |
| 144 Init(); | 144 Init(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void set_cookie_policy(net::CookiePolicy* policy) { | 147 void set_cookie_policy(net::CookiePolicy* policy) { |
| 148 cookie_policy_ = policy; | 148 cookie_policy_ = policy; |
| 149 } | 149 } |
| 150 | 150 |
| 151 protected: | 151 protected: |
| 152 virtual ~TestURLRequestContext() { | 152 virtual ~TestURLRequestContext() { |
| 153 delete ftp_transaction_factory_; | 153 delete ftp_transaction_factory_; |
| 154 delete http_transaction_factory_; | 154 delete http_transaction_factory_; |
| 155 delete http_auth_handler_factory_; | 155 delete http_auth_handler_factory_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 void Init() { | 159 void Init() { |
| 160 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | 160 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); |
| 161 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 161 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
| 162 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(); | 162 http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(); |
| 163 http_transaction_factory_ = | 163 http_transaction_factory_ = new net::HttpCache( |
| 164 new net::HttpCache( | 164 net::HttpNetworkLayer::CreateFactory(host_resolver_, |
| 165 net::HttpNetworkLayer::CreateFactory(NULL, host_resolver_, | 165 proxy_service_, |
| 166 proxy_service_, | 166 ssl_config_service_, |
| 167 ssl_config_service_, | 167 http_auth_handler_factory_, |
| 168 http_auth_handler_factory_, | 168 network_delegate_, |
| 169 network_delegate_, | 169 NULL), |
| 170 NULL), | 170 net::HttpCache::DefaultBackend::InMemory(0)); |
| 171 net::HttpCache::DefaultBackend::InMemory(0)); | |
| 172 // In-memory cookie store. | 171 // In-memory cookie store. |
| 173 cookie_store_ = new net::CookieMonster(NULL, NULL); | 172 cookie_store_ = new net::CookieMonster(NULL, NULL); |
| 174 accept_language_ = "en-us,fr"; | 173 accept_language_ = "en-us,fr"; |
| 175 accept_charset_ = "iso-8859-1,*,utf-8"; | 174 accept_charset_ = "iso-8859-1,*,utf-8"; |
| 176 } | 175 } |
| 177 }; | 176 }; |
| 178 | 177 |
| 179 //----------------------------------------------------------------------------- | 178 //----------------------------------------------------------------------------- |
| 180 | 179 |
| 181 class TestURLRequest : public URLRequest { | 180 class TestURLRequest : public URLRequest { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 return false; | 751 return false; |
| 753 | 752 |
| 754 return true; | 753 return true; |
| 755 } | 754 } |
| 756 | 755 |
| 757 private: | 756 private: |
| 758 ~FTPTestServer() {} | 757 ~FTPTestServer() {} |
| 759 }; | 758 }; |
| 760 | 759 |
| 761 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ | 760 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ |
| OLD | NEW |