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(make_scoped_ptr(new MockCertVerifier).Pass()); |
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 make_scoped_ptr(new HttpCache(network_session.get(), |
82 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl(); | 83 HttpCache::DefaultBackend::InMemory(0))) |
| 84 .Pass()); |
| 85 scoped_ptr<URLRequestJobFactoryImpl> job_factory = |
| 86 make_scoped_ptr(new URLRequestJobFactoryImpl()); |
83 #if !defined(DISABLE_FILE_SUPPORT) | 87 #if !defined(DISABLE_FILE_SUPPORT) |
84 job_factory->SetProtocolHandler("file", | 88 job_factory->SetProtocolHandler("file", |
85 make_scoped_ptr(new FileProtocolHandler( | 89 make_scoped_ptr(new FileProtocolHandler( |
86 base::ThreadTaskRunnerHandle::Get()))); | 90 base::ThreadTaskRunnerHandle::Get()))); |
87 #endif | 91 #endif |
88 storage_.set_job_factory(job_factory); | 92 storage_.set_job_factory(job_factory.Pass()); |
89 } | 93 } |
90 | 94 |
91 ~RequestContext() override { AssertNoURLRequests(); } | 95 ~RequestContext() override { AssertNoURLRequests(); } |
92 | 96 |
93 private: | 97 private: |
94 URLRequestContextStorage storage_; | 98 URLRequestContextStorage storage_; |
95 }; | 99 }; |
96 | 100 |
97 #if !defined(DISABLE_FILE_SUPPORT) | 101 #if !defined(DISABLE_FILE_SUPPORT) |
98 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. | 102 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 base::string16 text; | 478 base::string16 text; |
475 TestCompletionCallback callback; | 479 TestCompletionCallback callback; |
476 int result = pac_fetcher.Fetch(url, &text, callback.callback()); | 480 int result = pac_fetcher.Fetch(url, &text, callback.callback()); |
477 EXPECT_EQ(ERR_FAILED, result); | 481 EXPECT_EQ(ERR_FAILED, result); |
478 } | 482 } |
479 } | 483 } |
480 | 484 |
481 } // namespace | 485 } // namespace |
482 | 486 |
483 } // namespace net | 487 } // namespace net |
OLD | NEW |