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

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

Issue 197283012: Retry requests on reused sockets that receive ERR_EMPTY_RESPONSE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 #include "net/base/test_completion_callback.h" 13 #include "net/base/test_completion_callback.h"
14 #include "net/cert/mock_cert_verifier.h" 14 #include "net/cert/mock_cert_verifier.h"
15 #include "net/dns/mock_host_resolver.h" 15 #include "net/dns/mock_host_resolver.h"
16 #include "net/http/http_auth_handler_factory.h" 16 #include "net/http/http_auth_handler_factory.h"
17 #include "net/http/http_network_session.h" 17 #include "net/http/http_network_session.h"
18 #include "net/http/http_network_session_peer.h" 18 #include "net/http/http_network_session_peer.h"
19 #include "net/http/http_network_transaction.h" 19 #include "net/http/http_network_transaction.h"
20 #include "net/http/http_request_info.h" 20 #include "net/http/http_request_info.h"
21 #include "net/http/http_server_properties.h" 21 #include "net/http/http_server_properties.h"
22 #include "net/http/http_server_properties_impl.h" 22 #include "net/http/http_server_properties_impl.h"
23 #include "net/http/http_stream.h" 23 #include "net/http/http_stream.h"
24 #include "net/http/http_stream_factory_test_util.h"
24 #include "net/http/transport_security_state.h" 25 #include "net/http/transport_security_state.h"
25 #include "net/proxy/proxy_info.h" 26 #include "net/proxy/proxy_info.h"
26 #include "net/proxy/proxy_service.h" 27 #include "net/proxy/proxy_service.h"
27 #include "net/socket/client_socket_handle.h" 28 #include "net/socket/client_socket_handle.h"
28 #include "net/socket/mock_client_socket_pool_manager.h" 29 #include "net/socket/mock_client_socket_pool_manager.h"
29 #include "net/socket/next_proto.h" 30 #include "net/socket/next_proto.h"
30 #include "net/socket/socket_test_util.h" 31 #include "net/socket/socket_test_util.h"
31 #include "net/spdy/spdy_session.h" 32 #include "net/spdy/spdy_session.h"
32 #include "net/spdy/spdy_session_pool.h" 33 #include "net/spdy/spdy_session_pool.h"
33 #include "net/spdy/spdy_test_util_common.h" 34 #include "net/spdy/spdy_test_util_common.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 119 }
119 120
120 virtual std::string GetFailureMessage() const OVERRIDE { 121 virtual std::string GetFailureMessage() const OVERRIDE {
121 return std::string(); 122 return std::string();
122 } 123 }
123 124
124 private: 125 private:
125 const StreamType type_; 126 const StreamType type_;
126 }; 127 };
127 128
128 // HttpStreamFactoryImpl subclass that can wait until a preconnect is complete.
129 class MockHttpStreamFactoryImplForPreconnect : public HttpStreamFactoryImpl {
130 public:
131 MockHttpStreamFactoryImplForPreconnect(HttpNetworkSession* session,
132 bool for_websockets)
133 : HttpStreamFactoryImpl(session, for_websockets),
134 preconnect_done_(false),
135 waiting_for_preconnect_(false) {}
136
137
138 void WaitForPreconnects() {
139 while (!preconnect_done_) {
140 waiting_for_preconnect_ = true;
141 base::MessageLoop::current()->Run();
142 waiting_for_preconnect_ = false;
143 }
144 }
145
146 private:
147 // HttpStreamFactoryImpl methods.
148 virtual void OnPreconnectsCompleteInternal() OVERRIDE {
149 preconnect_done_ = true;
150 if (waiting_for_preconnect_)
151 base::MessageLoop::current()->Quit();
152 }
153
154 bool preconnect_done_;
155 bool waiting_for_preconnect_;
156 };
157
158 class StreamRequestWaiter : public HttpStreamRequest::Delegate { 129 class StreamRequestWaiter : public HttpStreamRequest::Delegate {
159 public: 130 public:
160 StreamRequestWaiter() 131 StreamRequestWaiter()
161 : waiting_for_stream_(false), 132 : waiting_for_stream_(false),
162 stream_done_(false) {} 133 stream_done_(false) {}
163 134
164 // HttpStreamRequest::Delegate 135 // HttpStreamRequest::Delegate
165 136
166 virtual void OnStreamReady( 137 virtual void OnStreamReady(
167 const SSLConfig& used_ssl_config, 138 const SSLConfig& used_ssl_config,
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 1306 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
1336 1307
1337 // Make sure there is no orphaned job. it is already canceled. 1308 // Make sure there is no orphaned job. it is already canceled.
1338 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( 1309 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>(
1339 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); 1310 session->http_stream_factory_for_websocket())->num_orphaned_jobs());
1340 } 1311 }
1341 1312
1342 } // namespace 1313 } // namespace
1343 1314
1344 } // namespace net 1315 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698