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 #include "net/proxy/proxy_script_fetcher_impl.h" | 5 #include "net/proxy/proxy_script_fetcher_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 base::string16 text; | 54 base::string16 text; |
55 }; | 55 }; |
56 | 56 |
57 // A non-mock URL request which can access http:// and file:// urls, in the case | 57 // A non-mock URL request which can access http:// and file:// urls, in the case |
58 // the tests were built with file support. | 58 // the tests were built with file support. |
59 class RequestContext : public URLRequestContext { | 59 class RequestContext : public URLRequestContext { |
60 public: | 60 public: |
61 RequestContext() : storage_(this) { | 61 RequestContext() : storage_(this) { |
62 ProxyConfig no_proxy; | 62 ProxyConfig no_proxy; |
63 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); | 63 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); |
64 storage_.set_cert_verifier(new MockCertVerifier); | 64 storage_.set_cert_verifier(scoped_ptr<CertVerifier>(new MockCertVerifier)); |
65 storage_.set_transport_security_state(new TransportSecurityState); | 65 storage_.set_transport_security_state( |
| 66 make_scoped_ptr(new TransportSecurityState)); |
66 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy)); | 67 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy)); |
67 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 68 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
68 storage_.set_http_server_properties( | 69 storage_.set_http_server_properties( |
69 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 70 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
70 | 71 |
71 HttpNetworkSession::Params params; | 72 HttpNetworkSession::Params params; |
72 params.host_resolver = host_resolver(); | 73 params.host_resolver = host_resolver(); |
73 params.cert_verifier = cert_verifier(); | 74 params.cert_verifier = cert_verifier(); |
74 params.transport_security_state = transport_security_state(); | 75 params.transport_security_state = transport_security_state(); |
75 params.proxy_service = proxy_service(); | 76 params.proxy_service = proxy_service(); |
76 params.ssl_config_service = ssl_config_service(); | 77 params.ssl_config_service = ssl_config_service(); |
77 params.http_server_properties = http_server_properties(); | 78 params.http_server_properties = http_server_properties(); |
78 scoped_refptr<HttpNetworkSession> network_session( | 79 scoped_refptr<HttpNetworkSession> network_session( |
79 new HttpNetworkSession(params)); | 80 new HttpNetworkSession(params)); |
80 storage_.set_http_transaction_factory(new HttpCache( | 81 storage_.set_http_transaction_factory( |
81 network_session.get(), HttpCache::DefaultBackend::InMemory(0))); | 82 scoped_ptr<HttpTransactionFactory>(new HttpCache( |
82 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl(); | 83 network_session.get(), HttpCache::DefaultBackend::InMemory(0)))); |
| 84 scoped_ptr<URLRequestJobFactoryImpl> job_factory = |
| 85 make_scoped_ptr(new URLRequestJobFactoryImpl()); |
83 #if !defined(DISABLE_FILE_SUPPORT) | 86 #if !defined(DISABLE_FILE_SUPPORT) |
84 job_factory->SetProtocolHandler( | 87 job_factory->SetProtocolHandler( |
85 "file", new FileProtocolHandler(base::ThreadTaskRunnerHandle::Get())); | 88 "file", new FileProtocolHandler(base::ThreadTaskRunnerHandle::Get())); |
86 #endif | 89 #endif |
87 storage_.set_job_factory(job_factory); | 90 storage_.set_job_factory(job_factory.Pass()); |
88 } | 91 } |
89 | 92 |
90 ~RequestContext() override { AssertNoURLRequests(); } | 93 ~RequestContext() override { AssertNoURLRequests(); } |
91 | 94 |
92 private: | 95 private: |
93 URLRequestContextStorage storage_; | 96 URLRequestContextStorage storage_; |
94 }; | 97 }; |
95 | 98 |
96 #if !defined(DISABLE_FILE_SUPPORT) | 99 #if !defined(DISABLE_FILE_SUPPORT) |
97 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. | 100 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 base::string16 text; | 478 base::string16 text; |
476 TestCompletionCallback callback; | 479 TestCompletionCallback callback; |
477 int result = pac_fetcher.Fetch(url, &text, callback.callback()); | 480 int result = pac_fetcher.Fetch(url, &text, callback.callback()); |
478 EXPECT_EQ(ERR_FAILED, result); | 481 EXPECT_EQ(ERR_FAILED, result); |
479 } | 482 } |
480 } | 483 } |
481 | 484 |
482 } // namespace | 485 } // namespace |
483 | 486 |
484 } // namespace net | 487 } // namespace net |
OLD | NEW |