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

Side by Side Diff: net/spdy/spdy_test_util.h

Issue 3033012: Fixed memory leak in SpdyHttpStreamTest. Removed suppressions. (Closed)
Patch Set: merge with trunk Created 10 years, 5 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/spdy/spdy_stream_unittest.cc ('k') | tools/valgrind/memcheck/suppressions.txt » ('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 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_ 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_H_
6 #define NET_SPDY_SPDY_TEST_UTIL_H_ 6 #define NET_SPDY_SPDY_TEST_UTIL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "net/base/mock_host_resolver.h"
9 #include "net/base/request_priority.h" 10 #include "net/base/request_priority.h"
11 #include "net/base/ssl_config_service_defaults.h"
12 #include "net/http/http_auth_handler_factory.h"
13 #include "net/http/http_network_session.h"
14 #include "net/proxy/proxy_service.h"
10 #include "net/socket/socket_test_util.h" 15 #include "net/socket/socket_test_util.h"
11 #include "net/spdy/spdy_framer.h" 16 #include "net/spdy/spdy_framer.h"
17 #include "net/spdy/spdy_session_pool.h"
12 18
13 namespace net { 19 namespace net {
14 20
15 // NOTE: In GCC, on a Mac, this can't be in an anonymous namespace! 21 // NOTE: In GCC, on a Mac, this can't be in an anonymous namespace!
16 // This struct holds information used to construct spdy control and data frames. 22 // This struct holds information used to construct spdy control and data frames.
17 struct SpdyHeaderInfo { 23 struct SpdyHeaderInfo {
18 spdy::SpdyControlType kind; 24 spdy::SpdyControlType kind;
19 spdy::SpdyStreamId id; 25 spdy::SpdyStreamId id;
20 spdy::SpdyStreamId assoc_id; 26 spdy::SpdyStreamId assoc_id;
21 spdy::SpdyPriority priority; 27 spdy::SpdyPriority priority;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 MockRead CreateMockRead(const spdy::SpdyFrame& resp); 194 MockRead CreateMockRead(const spdy::SpdyFrame& resp);
189 195
190 // Create a MockRead from the given SpdyFrame and sequence number. 196 // Create a MockRead from the given SpdyFrame and sequence number.
191 MockRead CreateMockRead(const spdy::SpdyFrame& resp, int seq); 197 MockRead CreateMockRead(const spdy::SpdyFrame& resp, int seq);
192 198
193 // Combines the given SpdyFrames into the given char array and returns 199 // Combines the given SpdyFrames into the given char array and returns
194 // the total length. 200 // the total length.
195 int CombineFrames(const spdy::SpdyFrame** frames, int num_frames, 201 int CombineFrames(const spdy::SpdyFrame** frames, int num_frames,
196 char* buff, int buff_len); 202 char* buff, int buff_len);
197 203
204 // Helper to manage the lifetimes of the dependencies for a
205 // HttpNetworkTransaction.
206 class SpdySessionDependencies {
207 public:
208 // Default set of dependencies -- "null" proxy service.
209 SpdySessionDependencies()
210 : host_resolver(new MockHostResolver),
211 proxy_service(ProxyService::CreateNull()),
212 ssl_config_service(new SSLConfigServiceDefaults),
213 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
214 spdy_session_pool(new SpdySessionPool()) {
215 // Note: The CancelledTransaction test does cleanup by running all
216 // tasks in the message loop (RunAllPending). Unfortunately, that
217 // doesn't clean up tasks on the host resolver thread; and
218 // TCPConnectJob is currently not cancellable. Using synchronous
219 // lookups allows the test to shutdown cleanly. Until we have
220 // cancellable TCPConnectJobs, use synchronous lookups.
221 host_resolver->set_synchronous_mode(true);
222 }
223
224 // Custom proxy service dependency.
225 explicit SpdySessionDependencies(ProxyService* proxy_service)
226 : host_resolver(new MockHostResolver),
227 proxy_service(proxy_service),
228 ssl_config_service(new SSLConfigServiceDefaults),
229 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
230 spdy_session_pool(new SpdySessionPool()) {}
231
232 scoped_refptr<MockHostResolverBase> host_resolver;
233 scoped_refptr<ProxyService> proxy_service;
234 scoped_refptr<SSLConfigService> ssl_config_service;
235 MockClientSocketFactory socket_factory;
236 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
237 scoped_refptr<SpdySessionPool> spdy_session_pool;
238
239 static HttpNetworkSession* SpdyCreateSession(
240 SpdySessionDependencies* session_deps) {
241 return new HttpNetworkSession(session_deps->host_resolver,
242 session_deps->proxy_service,
243 &session_deps->socket_factory,
244 session_deps->ssl_config_service,
245 session_deps->spdy_session_pool,
246 session_deps->http_auth_handler_factory.get(),
247 NULL,
248 NULL);
249 }
250 };
251
252
198 } // namespace net 253 } // namespace net
199 254
200 #endif // NET_SPDY_SPDY_TEST_UTIL_H_ 255 #endif // NET_SPDY_SPDY_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream_unittest.cc ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698