OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <math.h> // ceil | 5 #include <math.h> // ceil |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
9 #include "net/base/mock_host_resolver.h" | 9 #include "net/base/mock_host_resolver.h" |
10 #include "net/base/ssl_config_service_defaults.h" | 10 #include "net/base/ssl_config_service_defaults.h" |
11 #include "net/base/ssl_info.h" | 11 #include "net/base/ssl_info.h" |
12 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
13 #include "net/base/upload_data.h" | 13 #include "net/base/upload_data.h" |
14 #include "net/flip/flip_network_transaction.h" | 14 #include "net/flip/flip_network_transaction.h" |
15 #include "net/flip/flip_protocol.h" | 15 #include "net/flip/flip_protocol.h" |
16 #include "net/http/http_auth_handler_ntlm.h" | 16 #include "net/http/http_auth_handler_ntlm.h" |
17 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
18 #include "net/http/http_network_transaction.h" | 18 #include "net/http/http_network_transaction.h" |
19 #include "net/http/http_transaction_unittest.h" | 19 #include "net/http/http_transaction_unittest.h" |
20 #include "net/proxy/proxy_config_service_fixed.h" | 20 #include "net/proxy/proxy_config_service_fixed.h" |
21 #include "net/socket/client_socket_factory.h" | 21 #include "net/socket/client_socket_factory.h" |
22 #include "net/socket/socket_test_util.h" | 22 #include "net/socket/socket_test_util.h" |
23 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
24 #include "testing/platform_test.h" | 24 #include "testing/platform_test.h" |
25 | 25 |
26 //----------------------------------------------------------------------------- | 26 //----------------------------------------------------------------------------- |
27 | 27 |
| 28 namespace net { |
| 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 // Create a proxy service which fails on all requests (falls back to direct). | 32 // Create a proxy service which fails on all requests (falls back to direct). |
31 net::ProxyService* CreateNullProxyService() { | 33 ProxyService* CreateNullProxyService() { |
32 return net::ProxyService::CreateNull(); | 34 return ProxyService::CreateNull(); |
33 } | 35 } |
34 | 36 |
35 // Helper to manage the lifetimes of the dependencies for a | 37 // Helper to manage the lifetimes of the dependencies for a |
36 // HttpNetworkTransaction. | 38 // HttpNetworkTransaction. |
37 class SessionDependencies { | 39 class SessionDependencies { |
38 public: | 40 public: |
39 // Default set of dependencies -- "null" proxy service. | 41 // Default set of dependencies -- "null" proxy service. |
40 SessionDependencies() | 42 SessionDependencies() |
41 : host_resolver(new net::MockHostResolver), | 43 : host_resolver(new MockHostResolver), |
42 proxy_service(CreateNullProxyService()), | 44 proxy_service(CreateNullProxyService()), |
43 ssl_config_service(new net::SSLConfigServiceDefaults) {} | 45 ssl_config_service(new SSLConfigServiceDefaults), |
| 46 flip_session_pool(new FlipSessionPool) {} |
44 | 47 |
45 // Custom proxy service dependency. | 48 // Custom proxy service dependency. |
46 explicit SessionDependencies(net::ProxyService* proxy_service) | 49 explicit SessionDependencies(ProxyService* proxy_service) |
47 : host_resolver(new net::MockHostResolver), | 50 : host_resolver(new MockHostResolver), |
48 proxy_service(proxy_service), | 51 proxy_service(proxy_service), |
49 ssl_config_service(new net::SSLConfigServiceDefaults) {} | 52 ssl_config_service(new SSLConfigServiceDefaults), |
| 53 flip_session_pool(new FlipSessionPool) {} |
50 | 54 |
51 scoped_refptr<net::MockHostResolverBase> host_resolver; | 55 scoped_refptr<MockHostResolverBase> host_resolver; |
52 scoped_refptr<net::ProxyService> proxy_service; | 56 scoped_refptr<ProxyService> proxy_service; |
53 scoped_refptr<net::SSLConfigService> ssl_config_service; | 57 scoped_refptr<SSLConfigService> ssl_config_service; |
54 net::MockClientSocketFactory socket_factory; | 58 MockClientSocketFactory socket_factory; |
| 59 scoped_refptr<FlipSessionPool> flip_session_pool; |
55 }; | 60 }; |
56 | 61 |
57 net::ProxyService* CreateFixedProxyService(const std::string& proxy) { | 62 ProxyService* CreateFixedProxyService(const std::string& proxy) { |
58 net::ProxyConfig proxy_config; | 63 ProxyConfig proxy_config; |
59 proxy_config.proxy_rules.ParseFromString(proxy); | 64 proxy_config.proxy_rules.ParseFromString(proxy); |
60 return net::ProxyService::CreateFixed(proxy_config); | 65 return ProxyService::CreateFixed(proxy_config); |
61 } | 66 } |
62 | 67 |
63 | 68 |
64 net::HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 69 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
65 return new net::HttpNetworkSession(session_deps->host_resolver, | 70 return new HttpNetworkSession(session_deps->host_resolver, |
66 session_deps->proxy_service, | 71 session_deps->proxy_service, |
67 &session_deps->socket_factory, | 72 &session_deps->socket_factory, |
68 session_deps->ssl_config_service); | 73 session_deps->ssl_config_service, |
| 74 session_deps->flip_session_pool); |
69 } | 75 } |
70 | 76 |
71 } // namespace | 77 } // namespace |
72 | 78 |
73 namespace net { | |
74 | |
75 class FlipNetworkTransactionTest : public PlatformTest { | 79 class FlipNetworkTransactionTest : public PlatformTest { |
76 public: | 80 public: |
77 virtual void SetUp() { | 81 virtual void SetUp() { |
78 // Disable compression on this test. | 82 // Disable compression on this test. |
79 flip::FlipFramer::set_enable_compression_default(false); | 83 flip::FlipFramer::set_enable_compression_default(false); |
80 } | 84 } |
81 | 85 |
82 virtual void TearDown() { | 86 virtual void TearDown() { |
83 // Empty the current queue. | 87 // Empty the current queue. |
84 MessageLoop::current()->RunAllPending(); | 88 MessageLoop::current()->RunAllPending(); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 HttpRequestInfo request; | 320 HttpRequestInfo request; |
317 request.method = "GET"; | 321 request.method = "GET"; |
318 request.url = GURL("http://www.google.com/"); | 322 request.url = GURL("http://www.google.com/"); |
319 request.load_flags = 0; | 323 request.load_flags = 0; |
320 TransactionHelperResult out = TransactionHelper(request, data_reads, NULL); | 324 TransactionHelperResult out = TransactionHelper(request, data_reads, NULL); |
321 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); | 325 EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); |
322 } | 326 } |
323 | 327 |
324 | 328 |
325 } // namespace net | 329 } // namespace net |
326 | |
OLD | NEW |