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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 1604045: Fix crash on IP address change. (Closed)
Patch Set: Merge conflict 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/http/http_network_session_unittest.cc ('k') | net/net.gyp » ('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 <math.h> // ceil 5 #include <math.h> // ceil
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 25 matching lines...) Expand all
36 36
37 // Helper to manage the lifetimes of the dependencies for a 37 // Helper to manage the lifetimes of the dependencies for a
38 // HttpNetworkTransaction. 38 // HttpNetworkTransaction.
39 class SessionDependencies { 39 class SessionDependencies {
40 public: 40 public:
41 // Default set of dependencies -- "null" proxy service. 41 // Default set of dependencies -- "null" proxy service.
42 SessionDependencies() 42 SessionDependencies()
43 : host_resolver(new MockHostResolver), 43 : host_resolver(new MockHostResolver),
44 proxy_service(ProxyService::CreateNull()), 44 proxy_service(ProxyService::CreateNull()),
45 ssl_config_service(new SSLConfigServiceDefaults), 45 ssl_config_service(new SSLConfigServiceDefaults),
46 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} 46 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
47 spdy_session_pool(new SpdySessionPool) {}
47 48
48 // Custom proxy service dependency. 49 // Custom proxy service dependency.
49 explicit SessionDependencies(ProxyService* proxy_service) 50 explicit SessionDependencies(ProxyService* proxy_service)
50 : host_resolver(new MockHostResolver), 51 : host_resolver(new MockHostResolver),
51 proxy_service(proxy_service), 52 proxy_service(proxy_service),
52 ssl_config_service(new SSLConfigServiceDefaults), 53 ssl_config_service(new SSLConfigServiceDefaults),
53 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} 54 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()),
55 spdy_session_pool(new SpdySessionPool) {}
54 56
55 scoped_refptr<MockHostResolverBase> host_resolver; 57 scoped_refptr<MockHostResolverBase> host_resolver;
56 scoped_refptr<ProxyService> proxy_service; 58 scoped_refptr<ProxyService> proxy_service;
57 scoped_refptr<SSLConfigService> ssl_config_service; 59 scoped_refptr<SSLConfigService> ssl_config_service;
58 MockClientSocketFactory socket_factory; 60 MockClientSocketFactory socket_factory;
59 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; 61 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory;
62 scoped_refptr<SpdySessionPool> spdy_session_pool;
60 }; 63 };
61 64
62 ProxyService* CreateFixedProxyService(const std::string& proxy) { 65 ProxyService* CreateFixedProxyService(const std::string& proxy) {
63 net::ProxyConfig proxy_config; 66 net::ProxyConfig proxy_config;
64 proxy_config.proxy_rules().ParseFromString(proxy); 67 proxy_config.proxy_rules().ParseFromString(proxy);
65 return ProxyService::CreateFixed(proxy_config); 68 return ProxyService::CreateFixed(proxy_config);
66 } 69 }
67 70
68 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { 71 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
69 return new HttpNetworkSession(NULL, 72 return new HttpNetworkSession(NULL,
70 session_deps->host_resolver, 73 session_deps->host_resolver,
71 session_deps->proxy_service, 74 session_deps->proxy_service,
72 &session_deps->socket_factory, 75 &session_deps->socket_factory,
73 session_deps->ssl_config_service, 76 session_deps->ssl_config_service,
77 session_deps->spdy_session_pool,
74 session_deps->http_auth_handler_factory.get()); 78 session_deps->http_auth_handler_factory.get());
75 } 79 }
76 80
77 class HttpNetworkTransactionTest : public PlatformTest { 81 class HttpNetworkTransactionTest : public PlatformTest {
78 public: 82 public:
79 virtual void TearDown() { 83 virtual void TearDown() {
80 // Empty the current queue. 84 // Empty the current queue.
81 MessageLoop::current()->RunAllPending(); 85 MessageLoop::current()->RunAllPending();
82 PlatformTest::TearDown(); 86 PlatformTest::TearDown();
83 } 87 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 std::string MockGetHostName() { 181 std::string MockGetHostName() {
178 return "WTC-WIN7"; 182 return "WTC-WIN7";
179 } 183 }
180 184
181 template<typename EmulatedClientSocketPool, typename SocketSourceType> 185 template<typename EmulatedClientSocketPool, typename SocketSourceType>
182 class CaptureGroupNameSocketPool : public EmulatedClientSocketPool { 186 class CaptureGroupNameSocketPool : public EmulatedClientSocketPool {
183 public: 187 public:
184 CaptureGroupNameSocketPool(HttpNetworkSession* session, 188 CaptureGroupNameSocketPool(HttpNetworkSession* session,
185 SocketSourceType* socket_source) 189 SocketSourceType* socket_source)
186 : EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool", 190 : EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool",
187 session->host_resolver(), socket_source) {} 191 session->host_resolver(), socket_source,
192 NULL) {}
188 const std::string last_group_name_received() const { 193 const std::string last_group_name_received() const {
189 return last_group_name_; 194 return last_group_name_;
190 } 195 }
191 196
192 virtual int RequestSocket(const std::string& group_name, 197 virtual int RequestSocket(const std::string& group_name,
193 const void* socket_params, 198 const void* socket_params,
194 RequestPriority priority, 199 RequestPriority priority,
195 ClientSocketHandle* handle, 200 ClientSocketHandle* handle,
196 CompletionCallback* callback, 201 CompletionCallback* callback,
197 const BoundNetLog& net_log) { 202 const BoundNetLog& net_log) {
(...skipping 4677 matching lines...) Expand 10 before | Expand all | Expand 10 after
4875 EXPECT_FALSE(response->auth_challenge.get() == NULL); 4880 EXPECT_FALSE(response->auth_challenge.get() == NULL);
4876 4881
4877 EXPECT_EQ(L"myserver:80", response->auth_challenge->host_and_port); 4882 EXPECT_EQ(L"myserver:80", response->auth_challenge->host_and_port);
4878 EXPECT_EQ(L"", response->auth_challenge->realm); 4883 EXPECT_EQ(L"", response->auth_challenge->realm);
4879 EXPECT_EQ(L"mock", response->auth_challenge->scheme); 4884 EXPECT_EQ(L"mock", response->auth_challenge->scheme);
4880 auth_handler->ResetResolveExpectation(); 4885 auth_handler->ResetResolveExpectation();
4881 } 4886 }
4882 } 4887 }
4883 4888
4884 } // namespace net 4889 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session_unittest.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698