| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cert_net/cert_net_fetcher_impl.h" | 5 #include "net/cert_net/cert_net_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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 const base::FilePath::CharType kDocRoot[] = | 28 const base::FilePath::CharType kDocRoot[] = |
| 29 FILE_PATH_LITERAL("net/data/cert_net_fetcher_impl_unittest"); | 29 FILE_PATH_LITERAL("net/data/cert_net_fetcher_impl_unittest"); |
| 30 | 30 |
| 31 // A non-mock URLRequestContext which can access http:// urls. | 31 // A non-mock URLRequestContext which can access http:// urls. |
| 32 class RequestContext : public URLRequestContext { | 32 class RequestContext : public URLRequestContext { |
| 33 public: | 33 public: |
| 34 RequestContext() : storage_(this) { | 34 RequestContext() : storage_(this) { |
| 35 ProxyConfig no_proxy; | 35 ProxyConfig no_proxy; |
| 36 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); | 36 storage_.set_host_resolver(scoped_ptr<HostResolver>(new MockHostResolver)); |
| 37 storage_.set_cert_verifier(new MockCertVerifier); | 37 storage_.set_cert_verifier(make_scoped_ptr(new MockCertVerifier).Pass()); |
| 38 storage_.set_transport_security_state(new TransportSecurityState); | 38 storage_.set_transport_security_state( |
| 39 make_scoped_ptr(new TransportSecurityState)); |
| 39 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy)); | 40 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy)); |
| 40 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 41 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
| 41 storage_.set_http_server_properties( | 42 storage_.set_http_server_properties( |
| 42 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 43 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
| 43 | 44 |
| 44 HttpNetworkSession::Params params; | 45 HttpNetworkSession::Params params; |
| 45 params.host_resolver = host_resolver(); | 46 params.host_resolver = host_resolver(); |
| 46 params.cert_verifier = cert_verifier(); | 47 params.cert_verifier = cert_verifier(); |
| 47 params.transport_security_state = transport_security_state(); | 48 params.transport_security_state = transport_security_state(); |
| 48 params.proxy_service = proxy_service(); | 49 params.proxy_service = proxy_service(); |
| 49 params.ssl_config_service = ssl_config_service(); | 50 params.ssl_config_service = ssl_config_service(); |
| 50 params.http_server_properties = http_server_properties(); | 51 params.http_server_properties = http_server_properties(); |
| 51 scoped_refptr<HttpNetworkSession> network_session( | 52 scoped_refptr<HttpNetworkSession> network_session( |
| 52 new HttpNetworkSession(params)); | 53 new HttpNetworkSession(params)); |
| 53 storage_.set_http_transaction_factory(new HttpCache( | 54 storage_.set_http_transaction_factory( |
| 54 network_session.get(), HttpCache::DefaultBackend::InMemory(0))); | 55 make_scoped_ptr(new HttpCache(network_session.get(), |
| 55 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl(); | 56 HttpCache::DefaultBackend::InMemory(0))) |
| 56 storage_.set_job_factory(job_factory); | 57 .Pass()); |
| 58 storage_.set_job_factory( |
| 59 make_scoped_ptr(new URLRequestJobFactoryImpl()).Pass()); |
| 57 } | 60 } |
| 58 | 61 |
| 59 ~RequestContext() override { AssertNoURLRequests(); } | 62 ~RequestContext() override { AssertNoURLRequests(); } |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 URLRequestContextStorage storage_; | 65 URLRequestContextStorage storage_; |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 class FetchResult { | 68 class FetchResult { |
| 66 public: | 69 public: |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 EXPECT_EQ(1, network_delegate_.created_requests()); | 752 EXPECT_EQ(1, network_delegate_.created_requests()); |
| 750 | 753 |
| 751 scoped_ptr<FetchResult> result = callback1.WaitForResult(); | 754 scoped_ptr<FetchResult> result = callback1.WaitForResult(); |
| 752 result->VerifySuccess("-cert.crt-\n"); | 755 result->VerifySuccess("-cert.crt-\n"); |
| 753 | 756 |
| 754 // request2 was cancelled. | 757 // request2 was cancelled. |
| 755 EXPECT_FALSE(callback2.HasResult()); | 758 EXPECT_FALSE(callback2.HasResult()); |
| 756 } | 759 } |
| 757 | 760 |
| 758 } // namespace net | 761 } // namespace net |
| OLD | NEW |