Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 1615005: Flush socket pools and SPDY session pool properly on explicit requests and network changes. (Closed)
Patch Set: Fix minor leak. Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/tcp_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
59 // Note: The CancelledTransaction test does cleanup by running all tasks 58 // Note: The CancelledTransaction test does cleanup by running all tasks
60 // in the message loop (RunAllPending). Unfortunately, that doesn't clean 59 // in the message loop (RunAllPending). Unfortunately, that doesn't clean
61 // up tasks on the host resolver thread; and TCPConnectJob is currently 60 // up tasks on the host resolver thread; and TCPConnectJob is currently
62 // not cancellable. Using synchronous lookups allows the test to shutdown 61 // not cancellable. Using synchronous lookups allows the test to shutdown
63 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous 62 // cleanly. Until we have cancellable TCPConnectJobs, use synchronous
64 // lookups. 63 // lookups.
65 host_resolver->set_synchronous_mode(true); 64 host_resolver->set_synchronous_mode(true);
66 } 65 }
67 66
68 // Custom proxy service dependency. 67 // Custom proxy service dependency.
69 explicit SessionDependencies(ProxyService* proxy_service) 68 explicit SessionDependencies(ProxyService* proxy_service)
70 : host_resolver(new MockHostResolver), 69 : host_resolver(new MockHostResolver),
71 proxy_service(proxy_service), 70 proxy_service(proxy_service),
72 ssl_config_service(new SSLConfigServiceDefaults), 71 ssl_config_service(new SSLConfigServiceDefaults),
73 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), 72 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {}
74 spdy_session_pool(new SpdySessionPool) {}
75 73
76 scoped_refptr<MockHostResolverBase> host_resolver; 74 scoped_refptr<MockHostResolverBase> host_resolver;
77 scoped_refptr<ProxyService> proxy_service; 75 scoped_refptr<ProxyService> proxy_service;
78 scoped_refptr<SSLConfigService> ssl_config_service; 76 scoped_refptr<SSLConfigService> ssl_config_service;
79 MockClientSocketFactory socket_factory; 77 MockClientSocketFactory socket_factory;
80 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 78 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
81 scoped_refptr<SpdySessionPool> spdy_session_pool;
82 }; 79 };
83 80
84 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { 81 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
85 return new HttpNetworkSession(NULL, 82 return new HttpNetworkSession(NULL,
86 session_deps->host_resolver, 83 session_deps->host_resolver,
87 session_deps->proxy_service, 84 session_deps->proxy_service,
88 &session_deps->socket_factory, 85 &session_deps->socket_factory,
89 session_deps->ssl_config_service, 86 session_deps->ssl_config_service,
90 session_deps->spdy_session_pool,
91 session_deps->http_auth_handler_factory.get()); 87 session_deps->http_auth_handler_factory.get());
92 } 88 }
93 89
94 // Chop a frame into an array of MockWrites. 90 // Chop a frame into an array of MockWrites.
95 // |data| is the frame to chop. 91 // |data| is the frame to chop.
96 // |length| is the length of the frame to chop. 92 // |length| is the length of the frame to chop.
97 // |num_chunks| is the number of chunks to create. 93 // |num_chunks| is the number of chunks to create.
98 MockWrite* ChopFrame(const char* data, int length, int num_chunks) { 94 MockWrite* ChopFrame(const char* data, int length, int num_chunks) {
99 MockWrite* chunks = new MockWrite[num_chunks]; 95 MockWrite* chunks = new MockWrite[num_chunks];
100 int chunk_size = length / num_chunks; 96 int chunk_size = length / num_chunks;
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // We shouldn't get here in this test. 2448 // We shouldn't get here in this test.
2453 FAIL() << "Unexpected read: " << rv; 2449 FAIL() << "Unexpected read: " << rv;
2454 } while (rv > 0); 2450 } while (rv > 0);
2455 2451
2456 // Flush the MessageLoop; this will cause the buffered IO task 2452 // Flush the MessageLoop; this will cause the buffered IO task
2457 // to run for the final time. 2453 // to run for the final time.
2458 MessageLoop::current()->RunAllPending(); 2454 MessageLoop::current()->RunAllPending();
2459 } 2455 }
2460 2456
2461 } // namespace net 2457 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698