| 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 #include "net/proxy/proxy_script_fetcher.h" | 5 #include "net/proxy/proxy_script_fetcher.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 struct FetchResult { | 25 struct FetchResult { |
| 26 int code; | 26 int code; |
| 27 std::string bytes; | 27 std::string bytes; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // A non-mock URL request which can access http:// and file:// urls. | 30 // A non-mock URL request which can access http:// and file:// urls. |
| 31 class RequestContext : public URLRequestContext { | 31 class RequestContext : public URLRequestContext { |
| 32 public: | 32 public: |
| 33 RequestContext() { | 33 RequestContext() { |
| 34 net::ProxyConfig no_proxy; | 34 net::ProxyConfig no_proxy; |
| 35 host_resolver_ = net::CreateSystemHostResolver(NULL); | 35 host_resolver_ = net::CreateSystemHostResolver(); |
| 36 proxy_service_ = net::ProxyService::CreateFixed(no_proxy); | 36 proxy_service_ = net::ProxyService::CreateFixed(no_proxy); |
| 37 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 37 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
| 38 | 38 |
| 39 http_transaction_factory_ = | 39 http_transaction_factory_ = new net::HttpCache( |
| 40 new net::HttpCache( | 40 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, |
| 41 net::HttpNetworkLayer::CreateFactory( | 41 ssl_config_service_, NULL, NULL, NULL), |
| 42 NULL, host_resolver_, proxy_service_, ssl_config_service_, | 42 net::HttpCache::DefaultBackend::InMemory(0)); |
| 43 NULL, NULL, NULL), | |
| 44 net::HttpCache::DefaultBackend::InMemory(0)); | |
| 45 } | 43 } |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 ~RequestContext() { | 46 ~RequestContext() { |
| 49 delete http_transaction_factory_; | 47 delete http_transaction_factory_; |
| 50 } | 48 } |
| 51 }; | 49 }; |
| 52 | 50 |
| 53 // Required to be in net namespace by FRIEND_TEST. | 51 // Required to be in net namespace by FRIEND_TEST. |
| 54 namespace net { | 52 namespace net { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 std::string bytes; | 319 std::string bytes; |
| 322 TestCompletionCallback callback; | 320 TestCompletionCallback callback; |
| 323 int result = pac_fetcher->Fetch(url, &bytes, &callback); | 321 int result = pac_fetcher->Fetch(url, &bytes, &callback); |
| 324 EXPECT_EQ(ERR_IO_PENDING, result); | 322 EXPECT_EQ(ERR_IO_PENDING, result); |
| 325 EXPECT_EQ(OK, callback.WaitForResult()); | 323 EXPECT_EQ(OK, callback.WaitForResult()); |
| 326 EXPECT_EQ("This was encoded as UTF-16BE.\n", bytes); | 324 EXPECT_EQ("This was encoded as UTF-16BE.\n", bytes); |
| 327 } | 325 } |
| 328 } | 326 } |
| 329 | 327 |
| 330 } // namespace net | 328 } // namespace net |
| OLD | NEW |