| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Helper to manage the lifetimes of the dependencies for a | 76 // Helper to manage the lifetimes of the dependencies for a |
| 77 // HttpNetworkTransaction. | 77 // HttpNetworkTransaction. |
| 78 class SessionDependencies { | 78 class SessionDependencies { |
| 79 public: | 79 public: |
| 80 // Default set of dependencies -- "null" proxy service. | 80 // Default set of dependencies -- "null" proxy service. |
| 81 SessionDependencies() | 81 SessionDependencies() |
| 82 : host_resolver(new MockHostResolver), | 82 : host_resolver(new MockHostResolver), |
| 83 proxy_service(ProxyService::CreateNull()), | 83 proxy_service(ProxyService::CreateNull()), |
| 84 ssl_config_service(new SSLConfigServiceDefaults), | 84 ssl_config_service(new SSLConfigServiceDefaults), |
| 85 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} | 85 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 86 spdy_session_pool(new SpdySessionPool) {} |
| 86 | 87 |
| 87 // Custom proxy service dependency. | 88 // Custom proxy service dependency. |
| 88 explicit SessionDependencies(ProxyService* proxy_service) | 89 explicit SessionDependencies(ProxyService* proxy_service) |
| 89 : host_resolver(new MockHostResolver), | 90 : host_resolver(new MockHostResolver), |
| 90 proxy_service(proxy_service), | 91 proxy_service(proxy_service), |
| 91 ssl_config_service(new SSLConfigServiceDefaults), | 92 ssl_config_service(new SSLConfigServiceDefaults), |
| 92 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()) {} | 93 http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault()), |
| 94 spdy_session_pool(new SpdySessionPool) {} |
| 93 | 95 |
| 94 scoped_refptr<MockHostResolverBase> host_resolver; | 96 scoped_refptr<MockHostResolverBase> host_resolver; |
| 95 scoped_refptr<ProxyService> proxy_service; | 97 scoped_refptr<ProxyService> proxy_service; |
| 96 scoped_refptr<SSLConfigService> ssl_config_service; | 98 scoped_refptr<SSLConfigService> ssl_config_service; |
| 97 MockClientSocketFactory socket_factory; | 99 MockClientSocketFactory socket_factory; |
| 98 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | 100 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; |
| 101 scoped_refptr<SpdySessionPool> spdy_session_pool; |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 ProxyService* CreateFixedProxyService(const std::string& proxy) { | 104 ProxyService* CreateFixedProxyService(const std::string& proxy) { |
| 102 net::ProxyConfig proxy_config; | 105 net::ProxyConfig proxy_config; |
| 103 proxy_config.proxy_rules().ParseFromString(proxy); | 106 proxy_config.proxy_rules().ParseFromString(proxy); |
| 104 return ProxyService::CreateFixed(proxy_config); | 107 return ProxyService::CreateFixed(proxy_config); |
| 105 } | 108 } |
| 106 | 109 |
| 107 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | 110 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { |
| 108 return new HttpNetworkSession(NULL, | 111 return new HttpNetworkSession(NULL, |
| 109 session_deps->host_resolver, | 112 session_deps->host_resolver, |
| 110 session_deps->proxy_service, | 113 session_deps->proxy_service, |
| 111 &session_deps->socket_factory, | 114 &session_deps->socket_factory, |
| 112 session_deps->ssl_config_service, | 115 session_deps->ssl_config_service, |
| 116 session_deps->spdy_session_pool, |
| 113 session_deps->http_auth_handler_factory.get()); | 117 session_deps->http_auth_handler_factory.get()); |
| 114 } | 118 } |
| 115 | 119 |
| 116 class HttpNetworkTransactionTest : public PlatformTest { | 120 class HttpNetworkTransactionTest : public PlatformTest { |
| 117 public: | 121 public: |
| 118 virtual void SetUp() { | 122 virtual void SetUp() { |
| 119 spdy::SpdyFramer::set_enable_compression_default(false); | 123 spdy::SpdyFramer::set_enable_compression_default(false); |
| 120 } | 124 } |
| 121 | 125 |
| 122 virtual void TearDown() { | 126 virtual void TearDown() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 232 |
| 229 std::string MockGetHostName() { | 233 std::string MockGetHostName() { |
| 230 return "WTC-WIN7"; | 234 return "WTC-WIN7"; |
| 231 } | 235 } |
| 232 | 236 |
| 233 template<typename EmulatedClientSocketPool> | 237 template<typename EmulatedClientSocketPool> |
| 234 class CaptureGroupNameSocketPool : public EmulatedClientSocketPool { | 238 class CaptureGroupNameSocketPool : public EmulatedClientSocketPool { |
| 235 public: | 239 public: |
| 236 CaptureGroupNameSocketPool(HttpNetworkSession* session) | 240 CaptureGroupNameSocketPool(HttpNetworkSession* session) |
| 237 : EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool", | 241 : EmulatedClientSocketPool(0, 0, "CaptureGroupNameTestPool", |
| 238 session->host_resolver(), NULL) {} | 242 session->host_resolver(), NULL, |
| 243 NULL) {} |
| 239 const std::string last_group_name_received() const { | 244 const std::string last_group_name_received() const { |
| 240 return last_group_name_; | 245 return last_group_name_; |
| 241 } | 246 } |
| 242 | 247 |
| 243 virtual int RequestSocket(const std::string& group_name, | 248 virtual int RequestSocket(const std::string& group_name, |
| 244 const void* socket_params, | 249 const void* socket_params, |
| 245 RequestPriority priority, | 250 RequestPriority priority, |
| 246 ClientSocketHandle* handle, | 251 ClientSocketHandle* handle, |
| 247 CompletionCallback* callback, | 252 CompletionCallback* callback, |
| 248 const BoundNetLog& net_log) { | 253 const BoundNetLog& net_log) { |
| (...skipping 5420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5669 ASSERT_TRUE(response != NULL); | 5674 ASSERT_TRUE(response != NULL); |
| 5670 ASSERT_TRUE(response->headers != NULL); | 5675 ASSERT_TRUE(response->headers != NULL); |
| 5671 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 5676 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 5672 | 5677 |
| 5673 std::string response_data; | 5678 std::string response_data; |
| 5674 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 5679 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 5675 EXPECT_EQ("ok.", response_data); | 5680 EXPECT_EQ("ok.", response_data); |
| 5676 } | 5681 } |
| 5677 | 5682 |
| 5678 } // namespace net | 5683 } // namespace net |
| OLD | NEW |