| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(NULL)) { | 58 spdy_session_pool(new SpdySessionPool()) { |
| 59 // Note: The CancelledTransaction test does cleanup by running all tasks | 59 // Note: The CancelledTransaction test does cleanup by running all tasks |
| 60 // in the message loop (RunAllPending). Unfortunately, that doesn't clean | 60 // in the message loop (RunAllPending). Unfortunately, that doesn't clean |
| 61 // up tasks on the host resolver thread; and TCPConnectJob is currently | 61 // up tasks on the host resolver thread; and TCPConnectJob is currently |
| 62 // not cancellable. Using synchronous lookups allows the test to shutdown | 62 // not cancellable. Using synchronous lookups allows the test to shutdown |
| 63 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous | 63 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous |
| 64 // lookups. | 64 // lookups. |
| 65 host_resolver->set_synchronous_mode(true); | 65 host_resolver->set_synchronous_mode(true); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Custom proxy service dependency. | 68 // Custom proxy service dependency. |
| 69 explicit SessionDependencies(ProxyService* proxy_service) | 69 explicit SessionDependencies(ProxyService* proxy_service) |
| 70 : host_resolver(new MockHostResolver), | 70 : host_resolver(new MockHostResolver), |
| 71 proxy_service(proxy_service), | 71 proxy_service(proxy_service), |
| 72 ssl_config_service(new SSLConfigServiceDefaults), | 72 ssl_config_service(new SSLConfigServiceDefaults), |
| 73 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), | 73 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 74 spdy_session_pool(new SpdySessionPool(NULL)) {} | 74 spdy_session_pool(new SpdySessionPool()) {} |
| 75 | 75 |
| 76 scoped_refptr<MockHostResolverBase> host_resolver; | 76 scoped_refptr<MockHostResolverBase> host_resolver; |
| 77 scoped_refptr<ProxyService> proxy_service; | 77 scoped_refptr<ProxyService> proxy_service; |
| 78 scoped_refptr<SSLConfigService> ssl_config_service; | 78 scoped_refptr<SSLConfigService> ssl_config_service; |
| 79 MockClientSocketFactory socket_factory; | 79 MockClientSocketFactory socket_factory; |
| 80 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | 80 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; |
| 81 scoped_refptr<SpdySessionPool> spdy_session_pool; | 81 scoped_refptr<SpdySessionPool> spdy_session_pool; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 84 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
| 85 return new HttpNetworkSession(NULL, | 85 return new HttpNetworkSession(session_deps->host_resolver, |
| 86 session_deps->host_resolver, | |
| 87 session_deps->proxy_service, | 86 session_deps->proxy_service, |
| 88 &session_deps->socket_factory, | 87 &session_deps->socket_factory, |
| 89 session_deps->ssl_config_service, | 88 session_deps->ssl_config_service, |
| 90 session_deps->spdy_session_pool, | 89 session_deps->spdy_session_pool, |
| 91 session_deps->http_auth_handler_factory.get(), | 90 session_deps->http_auth_handler_factory.get(), |
| 92 NULL, | 91 NULL, |
| 93 NULL); | 92 NULL); |
| 94 } | 93 } |
| 95 | 94 |
| 96 // Chop a frame into an array of MockWrites. | 95 // Chop a frame into an array of MockWrites. |
| (...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 EXPECT_TRUE(response->was_fetched_via_spdy); | 2508 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 2510 out.rv = ReadTransaction(trans.get(), &out.response_data); | 2509 out.rv = ReadTransaction(trans.get(), &out.response_data); |
| 2511 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); | 2510 EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); |
| 2512 | 2511 |
| 2513 // Verify that we consumed all test data. | 2512 // Verify that we consumed all test data. |
| 2514 EXPECT_TRUE(data->at_read_eof()); | 2513 EXPECT_TRUE(data->at_read_eof()); |
| 2515 EXPECT_TRUE(data->at_write_eof()); | 2514 EXPECT_TRUE(data->at_write_eof()); |
| 2516 } | 2515 } |
| 2517 | 2516 |
| 2518 } // namespace net | 2517 } // namespace net |
| OLD | NEW |