| 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) {} | |
| 57 | 56 |
| 58 // Custom proxy service dependency. | 57 // Custom proxy service dependency. |
| 59 explicit SessionDependencies(ProxyService* proxy_service) | 58 explicit SessionDependencies(ProxyService* proxy_service) |
| 60 : host_resolver(new MockHostResolver), | 59 : host_resolver(new MockHostResolver), |
| 61 proxy_service(proxy_service), | 60 proxy_service(proxy_service), |
| 62 ssl_config_service(new SSLConfigServiceDefaults), | 61 ssl_config_service(new SSLConfigServiceDefaults), |
| 63 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), | 62 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} |
| 64 spdy_session_pool(new SpdySessionPool) {} | |
| 65 | 63 |
| 66 scoped_refptr<MockHostResolverBase> host_resolver; | 64 scoped_refptr<MockHostResolverBase> host_resolver; |
| 67 scoped_refptr<ProxyService> proxy_service; | 65 scoped_refptr<ProxyService> proxy_service; |
| 68 scoped_refptr<SSLConfigService> ssl_config_service; | 66 scoped_refptr<SSLConfigService> ssl_config_service; |
| 69 MockClientSocketFactory socket_factory; | 67 MockClientSocketFactory socket_factory; |
| 70 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | 68 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; |
| 71 scoped_refptr<SpdySessionPool> spdy_session_pool; | |
| 72 }; | 69 }; |
| 73 | 70 |
| 74 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 71 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
| 75 return new HttpNetworkSession(NULL, | 72 return new HttpNetworkSession(NULL, |
| 76 session_deps->host_resolver, | 73 session_deps->host_resolver, |
| 77 session_deps->proxy_service, | 74 session_deps->proxy_service, |
| 78 &session_deps->socket_factory, | 75 &session_deps->socket_factory, |
| 79 session_deps->ssl_config_service, | 76 session_deps->ssl_config_service, |
| 80 session_deps->spdy_session_pool, | |
| 81 session_deps->http_auth_handler_factory.get()); | 77 session_deps->http_auth_handler_factory.get()); |
| 82 } | 78 } |
| 83 | 79 |
| 84 class SpdyStreamTest : public testing::Test { | 80 class SpdyStreamTest : public testing::Test { |
| 85 protected: | 81 protected: |
| 86 SpdyStreamTest() | 82 SpdyStreamTest() |
| 87 : session_(CreateSession(&session_deps_)), | 83 : session_(CreateSession(&session_deps_)), |
| 88 pool_peer_(session_->spdy_session_pool()) {} | 84 pool_peer_(session_->spdy_session_pool()) {} |
| 89 | 85 |
| 90 scoped_refptr<SpdySession> CreateSpdySession() { | 86 scoped_refptr<SpdySession> CreateSpdySession() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 // socket close/error, but we aren't communicating over a socket here. | 116 // socket close/error, but we aren't communicating over a socket here. |
| 121 pool_peer_.RemoveSpdySession(session); | 117 pool_peer_.RemoveSpdySession(session); |
| 122 } | 118 } |
| 123 | 119 |
| 124 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 120 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 125 // methods. | 121 // methods. |
| 126 | 122 |
| 127 } // namespace | 123 } // namespace |
| 128 | 124 |
| 129 } // namespace net | 125 } // namespace net |
| OLD | NEW |