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_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
6 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
7 #include "net/base/mock_host_resolver.h" | 7 #include "net/base/mock_host_resolver.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/base/ssl_config_service.h" | 9 #include "net/base/ssl_config_service.h" |
10 #include "net/base/ssl_config_service_defaults.h" | 10 #include "net/base/ssl_config_service_defaults.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Helper to manage the lifetimes of the dependencies for a | 46 // Helper to manage the lifetimes of the dependencies for a |
47 // SpdyNetworkTransaction. | 47 // SpdyNetworkTransaction. |
48 class SessionDependencies { | 48 class SessionDependencies { |
49 public: | 49 public: |
50 // Default set of dependencies -- "null" proxy service. | 50 // Default set of dependencies -- "null" proxy service. |
51 SessionDependencies() | 51 SessionDependencies() |
52 : host_resolver(new MockHostResolver), | 52 : host_resolver(new MockHostResolver), |
53 proxy_service(CreateNullProxyService()), | 53 proxy_service(CreateNullProxyService()), |
54 ssl_config_service(new SSLConfigServiceDefaults), | 54 ssl_config_service(new SSLConfigServiceDefaults), |
55 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} | 55 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 56 spdy_session_pool(new SpdySessionPool) {} |
56 | 57 |
57 // Custom proxy service dependency. | 58 // Custom proxy service dependency. |
58 explicit SessionDependencies(ProxyService* proxy_service) | 59 explicit SessionDependencies(ProxyService* proxy_service) |
59 : host_resolver(new MockHostResolver), | 60 : host_resolver(new MockHostResolver), |
60 proxy_service(proxy_service), | 61 proxy_service(proxy_service), |
61 ssl_config_service(new SSLConfigServiceDefaults), | 62 ssl_config_service(new SSLConfigServiceDefaults), |
62 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} | 63 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 64 spdy_session_pool(new SpdySessionPool) {} |
63 | 65 |
64 scoped_refptr<MockHostResolverBase> host_resolver; | 66 scoped_refptr<MockHostResolverBase> host_resolver; |
65 scoped_refptr<ProxyService> proxy_service; | 67 scoped_refptr<ProxyService> proxy_service; |
66 scoped_refptr<SSLConfigService> ssl_config_service; | 68 scoped_refptr<SSLConfigService> ssl_config_service; |
67 MockClientSocketFactory socket_factory; | 69 MockClientSocketFactory socket_factory; |
68 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | 70 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; |
| 71 scoped_refptr<SpdySessionPool> spdy_session_pool; |
69 }; | 72 }; |
70 | 73 |
71 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 74 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
72 return new HttpNetworkSession(NULL, | 75 return new HttpNetworkSession(NULL, |
73 session_deps->host_resolver, | 76 session_deps->host_resolver, |
74 session_deps->proxy_service, | 77 session_deps->proxy_service, |
75 &session_deps->socket_factory, | 78 &session_deps->socket_factory, |
76 session_deps->ssl_config_service, | 79 session_deps->ssl_config_service, |
| 80 session_deps->spdy_session_pool, |
77 session_deps->http_auth_handler_factory.get()); | 81 session_deps->http_auth_handler_factory.get()); |
78 } | 82 } |
79 | 83 |
80 class SpdyStreamTest : public testing::Test { | 84 class SpdyStreamTest : public testing::Test { |
81 protected: | 85 protected: |
82 SpdyStreamTest() | 86 SpdyStreamTest() |
83 : session_(CreateSession(&session_deps_)), | 87 : session_(CreateSession(&session_deps_)), |
84 pool_peer_(session_->spdy_session_pool()) {} | 88 pool_peer_(session_->spdy_session_pool()) {} |
85 | 89 |
86 scoped_refptr<SpdySession> CreateSpdySession() { | 90 scoped_refptr<SpdySession> CreateSpdySession() { |
(...skipping 29 matching lines...) Expand all Loading... |
116 // socket close/error, but we aren't communicating over a socket here. | 120 // socket close/error, but we aren't communicating over a socket here. |
117 pool_peer_.RemoveSpdySession(session); | 121 pool_peer_.RemoveSpdySession(session); |
118 } | 122 } |
119 | 123 |
120 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 124 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
121 // methods. | 125 // methods. |
122 | 126 |
123 } // namespace | 127 } // namespace |
124 | 128 |
125 } // namespace net | 129 } // namespace net |
OLD | NEW |