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/spdy/spdy_network_transaction.h" | 5 #include "net/spdy/spdy_network_transaction.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Helper to manage the lifetimes of the dependencies for a | 48 // Helper to manage the lifetimes of the dependencies for a |
49 // SpdyNetworkTransaction. | 49 // SpdyNetworkTransaction. |
50 class SessionDependencies { | 50 class SessionDependencies { |
51 public: | 51 public: |
52 // Default set of dependencies -- "null" proxy service. | 52 // Default set of dependencies -- "null" proxy service. |
53 SessionDependencies() | 53 SessionDependencies() |
54 : host_resolver(new MockHostResolver), | 54 : host_resolver(new MockHostResolver), |
55 proxy_service(ProxyService::CreateNull()), | 55 proxy_service(ProxyService::CreateNull()), |
56 ssl_config_service(new SSLConfigServiceDefaults), | 56 ssl_config_service(new SSLConfigServiceDefaults), |
57 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) { | 57 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 58 spdy_session_pool(new SpdySessionPool) { |
58 // Note: The CancelledTransaction test does cleanup by running all tasks | 59 // Note: The CancelledTransaction test does cleanup by running all tasks |
59 // in the message loop (RunAllPending). Unfortunately, that doesn't clean | 60 // in the message loop (RunAllPending). Unfortunately, that doesn't clean |
60 // up tasks on the host resolver thread; and TCPConnectJob is currently | 61 // up tasks on the host resolver thread; and TCPConnectJob is currently |
61 // not cancellable. Using synchronous lookups allows the test to shutdown | 62 // not cancellable. Using synchronous lookups allows the test to shutdown |
62 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous | 63 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous |
63 // lookups. | 64 // lookups. |
64 host_resolver->set_synchronous_mode(true); | 65 host_resolver->set_synchronous_mode(true); |
65 } | 66 } |
66 | 67 |
67 // Custom proxy service dependency. | 68 // Custom proxy service dependency. |
68 explicit SessionDependencies(ProxyService* proxy_service) | 69 explicit SessionDependencies(ProxyService* proxy_service) |
69 : host_resolver(new MockHostResolver), | 70 : host_resolver(new MockHostResolver), |
70 proxy_service(proxy_service), | 71 proxy_service(proxy_service), |
71 ssl_config_service(new SSLConfigServiceDefaults), | 72 ssl_config_service(new SSLConfigServiceDefaults), |
72 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} | 73 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 74 spdy_session_pool(new SpdySessionPool) {} |
73 | 75 |
74 scoped_refptr<MockHostResolverBase> host_resolver; | 76 scoped_refptr<MockHostResolverBase> host_resolver; |
75 scoped_refptr<ProxyService> proxy_service; | 77 scoped_refptr<ProxyService> proxy_service; |
76 scoped_refptr<SSLConfigService> ssl_config_service; | 78 scoped_refptr<SSLConfigService> ssl_config_service; |
77 MockClientSocketFactory socket_factory; | 79 MockClientSocketFactory socket_factory; |
78 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | 80 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; |
| 81 scoped_refptr<SpdySessionPool> spdy_session_pool; |
79 }; | 82 }; |
80 | 83 |
81 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 84 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
82 return new HttpNetworkSession(NULL, | 85 return new HttpNetworkSession(NULL, |
83 session_deps->host_resolver, | 86 session_deps->host_resolver, |
84 session_deps->proxy_service, | 87 session_deps->proxy_service, |
85 &session_deps->socket_factory, | 88 &session_deps->socket_factory, |
86 session_deps->ssl_config_service, | 89 session_deps->ssl_config_service, |
| 90 session_deps->spdy_session_pool, |
87 session_deps->http_auth_handler_factory.get()); | 91 session_deps->http_auth_handler_factory.get()); |
88 } | 92 } |
89 | 93 |
90 // Chop a frame into an array of MockWrites. | 94 // Chop a frame into an array of MockWrites. |
91 // |data| is the frame to chop. | 95 // |data| is the frame to chop. |
92 // |length| is the length of the frame to chop. | 96 // |length| is the length of the frame to chop. |
93 // |num_chunks| is the number of chunks to create. | 97 // |num_chunks| is the number of chunks to create. |
94 MockWrite* ChopFrame(const char* data, int length, int num_chunks) { | 98 MockWrite* ChopFrame(const char* data, int length, int num_chunks) { |
95 MockWrite* chunks = new MockWrite[num_chunks]; | 99 MockWrite* chunks = new MockWrite[num_chunks]; |
96 int chunk_size = length / num_chunks; | 100 int chunk_size = length / num_chunks; |
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 // Verify the second persisted setting. | 2709 // Verify the second persisted setting. |
2706 setting = saved_settings.front(); | 2710 setting = saved_settings.front(); |
2707 saved_settings.pop_front(); | 2711 saved_settings.pop_front(); |
2708 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); | 2712 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, setting.first.flags()); |
2709 EXPECT_EQ(kSampleId2, setting.first.id()); | 2713 EXPECT_EQ(kSampleId2, setting.first.id()); |
2710 EXPECT_EQ(kSampleValue2, setting.second); | 2714 EXPECT_EQ(kSampleValue2, setting.second); |
2711 } | 2715 } |
2712 } | 2716 } |
2713 | 2717 |
2714 } // namespace net | 2718 } // namespace net |
OLD | NEW |