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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_test_util.h
diff --git a/net/spdy/spdy_test_util.h b/net/spdy/spdy_test_util.h
index 7549b151f78cabcf959dcc853bfc3b64e26ff125..6e7a8d0fb385185f324a472ad9988c2095eb4ce9 100644
--- a/net/spdy/spdy_test_util.h
+++ b/net/spdy/spdy_test_util.h
@@ -6,9 +6,15 @@
#define NET_SPDY_SPDY_TEST_UTIL_H_
#include "base/basictypes.h"
+#include "net/base/mock_host_resolver.h"
#include "net/base/request_priority.h"
+#include "net/base/ssl_config_service_defaults.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_network_session.h"
+#include "net/proxy/proxy_service.h"
#include "net/socket/socket_test_util.h"
#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_session_pool.h"
namespace net {
@@ -195,6 +201,55 @@ MockRead CreateMockRead(const spdy::SpdyFrame& resp, int seq);
int CombineFrames(const spdy::SpdyFrame** frames, int num_frames,
char* buff, int buff_len);
+// Helper to manage the lifetimes of the dependencies for a
+// HttpNetworkTransaction.
+class SpdySessionDependencies {
+ public:
+ // Default set of dependencies -- "null" proxy service.
+ SpdySessionDependencies()
+ : host_resolver(new MockHostResolver),
+ proxy_service(ProxyService::CreateNull()),
+ ssl_config_service(new SSLConfigServiceDefaults),
+ http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
+ spdy_session_pool(new SpdySessionPool()) {
+ // Note: The CancelledTransaction test does cleanup by running all
+ // tasks in the message loop (RunAllPending). Unfortunately, that
+ // doesn't clean up tasks on the host resolver thread; and
+ // TCPConnectJob is currently not cancellable. Using synchronous
+ // lookups allows the test to shutdown cleanly. Until we have
+ // cancellable TCPConnectJobs, use synchronous lookups.
+ host_resolver->set_synchronous_mode(true);
+ }
+
+ // Custom proxy service dependency.
+ explicit SpdySessionDependencies(ProxyService* proxy_service)
+ : host_resolver(new MockHostResolver),
+ proxy_service(proxy_service),
+ ssl_config_service(new SSLConfigServiceDefaults),
+ http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
+ spdy_session_pool(new SpdySessionPool()) {}
+
+ scoped_refptr<MockHostResolverBase> host_resolver;
+ scoped_refptr<ProxyService> proxy_service;
+ scoped_refptr<SSLConfigService> ssl_config_service;
+ MockClientSocketFactory socket_factory;
+ scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
+ scoped_refptr<SpdySessionPool> spdy_session_pool;
+
+ static HttpNetworkSession* SpdyCreateSession(
+ SpdySessionDependencies* session_deps) {
+ return new HttpNetworkSession(session_deps->host_resolver,
+ session_deps->proxy_service,
+ &session_deps->socket_factory,
+ session_deps->ssl_config_service,
+ session_deps->spdy_session_pool,
+ session_deps->http_auth_handler_factory.get(),
+ NULL,
+ NULL);
+}
+};
+
+
} // namespace net
#endif // NET_SPDY_SPDY_TEST_UTIL_H_
« 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