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

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

Issue 8586015: Slow start pipelining. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for landing Created 9 years 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
« no previous file with comments | « net/http/http_pipelined_host_unittest.cc ('k') | net/http/http_stream_factory_impl.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void ExpectResponse(const std::string& expected, 90 void ExpectResponse(const std::string& expected,
91 HttpNetworkTransaction& transaction) { 91 HttpNetworkTransaction& transaction) {
92 scoped_refptr<IOBuffer> buffer(new IOBuffer(expected.size())); 92 scoped_refptr<IOBuffer> buffer(new IOBuffer(expected.size()));
93 EXPECT_EQ(static_cast<int>(expected.size()), 93 EXPECT_EQ(static_cast<int>(expected.size()),
94 transaction.Read(buffer.get(), expected.size(), &callback_)); 94 transaction.Read(buffer.get(), expected.size(), &callback_));
95 std::string actual(buffer->data(), expected.size()); 95 std::string actual(buffer->data(), expected.size());
96 EXPECT_THAT(actual, StrEq(expected)); 96 EXPECT_THAT(actual, StrEq(expected));
97 EXPECT_EQ(OK, transaction.Read(buffer.get(), expected.size(), &callback_)); 97 EXPECT_EQ(OK, transaction.Read(buffer.get(), expected.size(), &callback_));
98 } 98 }
99 99
100 void CompleteTwoRequests() { 100 void CompleteTwoRequests(int data_index, int stop_at_step) {
101 scoped_ptr<HttpNetworkTransaction> one_transaction( 101 scoped_ptr<HttpNetworkTransaction> one_transaction(
102 new HttpNetworkTransaction(session_.get())); 102 new HttpNetworkTransaction(session_.get()));
103 TestOldCompletionCallback one_callback; 103 TestOldCompletionCallback one_callback;
104 EXPECT_EQ(ERR_IO_PENDING, 104 EXPECT_EQ(ERR_IO_PENDING,
105 one_transaction->Start(GetRequestInfo("one.html"), &one_callback, 105 one_transaction->Start(GetRequestInfo("one.html"), &one_callback,
106 BoundNetLog())); 106 BoundNetLog()));
107 EXPECT_EQ(OK, one_callback.WaitForResult()); 107 EXPECT_EQ(OK, one_callback.WaitForResult());
108 108
109 HttpNetworkTransaction two_transaction(session_.get()); 109 HttpNetworkTransaction two_transaction(session_.get());
110 TestOldCompletionCallback two_callback; 110 TestOldCompletionCallback two_callback;
111 EXPECT_EQ(ERR_IO_PENDING, 111 EXPECT_EQ(ERR_IO_PENDING,
112 two_transaction.Start(GetRequestInfo("two.html"), &two_callback, 112 two_transaction.Start(GetRequestInfo("two.html"), &two_callback,
113 BoundNetLog())); 113 BoundNetLog()));
114 114
115 TestOldCompletionCallback one_read_callback; 115 TestOldCompletionCallback one_read_callback;
116 scoped_refptr<IOBuffer> buffer(new IOBuffer(8)); 116 scoped_refptr<IOBuffer> buffer(new IOBuffer(8));
117 EXPECT_EQ(ERR_IO_PENDING, 117 EXPECT_EQ(ERR_IO_PENDING,
118 one_transaction->Read(buffer.get(), 8, &one_read_callback)); 118 one_transaction->Read(buffer.get(), 8, &one_read_callback));
119 119
120 data_vector_[0]->RunFor(2); 120 data_vector_[data_index]->SetStop(stop_at_step);
121 data_vector_[data_index]->Run();
121 EXPECT_EQ(8, one_read_callback.WaitForResult()); 122 EXPECT_EQ(8, one_read_callback.WaitForResult());
122 data_vector_[0]->SetStop(10); 123 data_vector_[data_index]->SetStop(10);
123 std::string actual(buffer->data(), 8); 124 std::string actual(buffer->data(), 8);
124 EXPECT_THAT(actual, StrEq("one.html")); 125 EXPECT_THAT(actual, StrEq("one.html"));
125 EXPECT_EQ(OK, one_transaction->Read(buffer.get(), 8, &one_read_callback)); 126 EXPECT_EQ(OK, one_transaction->Read(buffer.get(), 8, &one_read_callback));
126 127
127 EXPECT_EQ(OK, two_callback.WaitForResult()); 128 EXPECT_EQ(OK, two_callback.WaitForResult());
128 ExpectResponse("two.html", two_transaction); 129 ExpectResponse("two.html", two_transaction);
129 } 130 }
130 131
132 void CompleteFourRequests() {
133 scoped_ptr<HttpNetworkTransaction> one_transaction(
134 new HttpNetworkTransaction(session_.get()));
135 TestOldCompletionCallback one_callback;
136 EXPECT_EQ(ERR_IO_PENDING,
137 one_transaction->Start(GetRequestInfo("one.html"), &one_callback,
138 BoundNetLog()));
139 EXPECT_EQ(OK, one_callback.WaitForResult());
140
141 HttpNetworkTransaction two_transaction(session_.get());
142 TestOldCompletionCallback two_callback;
143 EXPECT_EQ(ERR_IO_PENDING,
144 two_transaction.Start(GetRequestInfo("two.html"), &two_callback,
145 BoundNetLog()));
146
147 HttpNetworkTransaction three_transaction(session_.get());
148 TestOldCompletionCallback three_callback;
149 EXPECT_EQ(ERR_IO_PENDING,
150 three_transaction.Start(GetRequestInfo("three.html"),
151 &three_callback, BoundNetLog()));
152
153 HttpNetworkTransaction four_transaction(session_.get());
154 TestOldCompletionCallback four_callback;
155 EXPECT_EQ(ERR_IO_PENDING,
156 four_transaction.Start(GetRequestInfo("four.html"),
157 &four_callback, BoundNetLog()));
158
159 ExpectResponse("one.html", *one_transaction.get());
160 EXPECT_EQ(OK, two_callback.WaitForResult());
161 ExpectResponse("two.html", two_transaction);
162 EXPECT_EQ(OK, three_callback.WaitForResult());
163 ExpectResponse("three.html", three_transaction);
164
165 one_transaction.reset();
166 EXPECT_EQ(OK, four_callback.WaitForResult());
167 ExpectResponse("four.html", four_transaction);
168 }
169
131 DeterministicMockClientSocketFactory factory_; 170 DeterministicMockClientSocketFactory factory_;
132 ClientSocketPoolHistograms histograms_; 171 ClientSocketPoolHistograms histograms_;
133 MockTransportClientSocketPool pool_; 172 MockTransportClientSocketPool pool_;
134 std::vector<scoped_refptr<DeterministicSocketData> > data_vector_; 173 std::vector<scoped_refptr<DeterministicSocketData> > data_vector_;
135 TestOldCompletionCallback callback_; 174 TestOldCompletionCallback callback_;
136 ScopedVector<HttpRequestInfo> request_info_vector_; 175 ScopedVector<HttpRequestInfo> request_info_vector_;
137 bool default_pipelining_enabled_; 176 bool default_pipelining_enabled_;
138 177
139 scoped_ptr<ProxyService> proxy_service_; 178 scoped_ptr<ProxyService> proxy_service_;
140 MockHostResolver mock_resolver_; 179 MockHostResolver mock_resolver_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 MockRead reads[] = { 220 MockRead reads[] = {
182 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), 221 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
183 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), 222 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
184 MockRead(true, 4, "one.html"), 223 MockRead(true, 4, "one.html"),
185 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), 224 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"),
186 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), 225 MockRead(false, 6, "Content-Length: 8\r\n\r\n"),
187 MockRead(false, 7, "two.html"), 226 MockRead(false, 7, "two.html"),
188 }; 227 };
189 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); 228 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
190 229
191 CompleteTwoRequests(); 230 CompleteTwoRequests(0, 5);
192 } 231 }
193 232
194 TEST_F(HttpPipelinedNetworkTransactionTest, ReusesOnSpaceAvailable) { 233 TEST_F(HttpPipelinedNetworkTransactionTest, ReusesOnSpaceAvailable) {
195 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(); 234 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group();
196 ClientSocketPoolManager::set_max_sockets_per_group(1); 235 ClientSocketPoolManager::set_max_sockets_per_group(1);
197 Initialize(); 236 Initialize();
198 237
199 MockWrite writes[] = { 238 MockWrite writes[] = {
200 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" 239 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
201 "Host: localhost\r\n" 240 "Host: localhost\r\n"
(...skipping 17 matching lines...) Expand all
219 MockRead(false, 8, "two.html"), 258 MockRead(false, 8, "two.html"),
220 MockRead(false, 9, "HTTP/1.1 200 OK\r\n"), 259 MockRead(false, 9, "HTTP/1.1 200 OK\r\n"),
221 MockRead(false, 10, "Content-Length: 10\r\n\r\n"), 260 MockRead(false, 10, "Content-Length: 10\r\n\r\n"),
222 MockRead(false, 11, "three.html"), 261 MockRead(false, 11, "three.html"),
223 MockRead(false, 13, "HTTP/1.1 200 OK\r\n"), 262 MockRead(false, 13, "HTTP/1.1 200 OK\r\n"),
224 MockRead(false, 14, "Content-Length: 9\r\n\r\n"), 263 MockRead(false, 14, "Content-Length: 9\r\n\r\n"),
225 MockRead(false, 15, "four.html"), 264 MockRead(false, 15, "four.html"),
226 }; 265 };
227 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); 266 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
228 267
229 scoped_ptr<HttpNetworkTransaction> one_transaction( 268 CompleteFourRequests();
230 new HttpNetworkTransaction(session_.get()));
231 TestOldCompletionCallback one_callback;
232 EXPECT_EQ(ERR_IO_PENDING,
233 one_transaction->Start(GetRequestInfo("one.html"), &one_callback,
234 BoundNetLog()));
235 EXPECT_EQ(OK, one_callback.WaitForResult());
236
237 HttpNetworkTransaction two_transaction(session_.get());
238 TestOldCompletionCallback two_callback;
239 EXPECT_EQ(ERR_IO_PENDING,
240 two_transaction.Start(GetRequestInfo("two.html"), &two_callback,
241 BoundNetLog()));
242
243 HttpNetworkTransaction three_transaction(session_.get());
244 TestOldCompletionCallback three_callback;
245 EXPECT_EQ(ERR_IO_PENDING,
246 three_transaction.Start(GetRequestInfo("three.html"),
247 &three_callback, BoundNetLog()));
248
249 HttpNetworkTransaction four_transaction(session_.get());
250 TestOldCompletionCallback four_callback;
251 EXPECT_EQ(ERR_IO_PENDING,
252 four_transaction.Start(GetRequestInfo("four.html"), &four_callback,
253 BoundNetLog()));
254
255 ExpectResponse("one.html", *one_transaction.get());
256 EXPECT_EQ(OK, two_callback.WaitForResult());
257 ExpectResponse("two.html", two_transaction);
258 EXPECT_EQ(OK, three_callback.WaitForResult());
259 ExpectResponse("three.html", three_transaction);
260
261 one_transaction.reset();
262 EXPECT_EQ(OK, four_callback.WaitForResult());
263 ExpectResponse("four.html", four_transaction);
264 269
265 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets); 270 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets);
266 } 271 }
267 272
268 TEST_F(HttpPipelinedNetworkTransactionTest, UnknownSizeEvictsToNewPipeline) { 273 TEST_F(HttpPipelinedNetworkTransactionTest, UnknownSizeEvictsToNewPipeline) {
269 Initialize(); 274 Initialize();
270 275
271 MockWrite writes[] = { 276 MockWrite writes[] = {
272 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" 277 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
273 "Host: localhost\r\n" 278 "Host: localhost\r\n"
274 "Connection: keep-alive\r\n\r\n"), 279 "Connection: keep-alive\r\n\r\n"),
275 MockWrite(false, 2, "GET /two.html HTTP/1.1\r\n"
276 "Host: localhost\r\n"
277 "Connection: keep-alive\r\n\r\n"),
278 }; 280 };
279 MockRead reads[] = { 281 MockRead reads[] = {
280 MockRead(false, 1, "HTTP/1.1 200 OK\r\n\r\n"), 282 MockRead(false, 1, "HTTP/1.1 200 OK\r\n\r\n"),
281 MockRead(true, 3, "one.html"), 283 MockRead(true, 2, "one.html"),
282 MockRead(false, OK, 4), 284 MockRead(false, OK, 3),
283 }; 285 };
284 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); 286 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
285 287
286 MockWrite writes2[] = { 288 MockWrite writes2[] = {
287 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" 289 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n"
288 "Host: localhost\r\n" 290 "Host: localhost\r\n"
289 "Connection: keep-alive\r\n\r\n"), 291 "Connection: keep-alive\r\n\r\n"),
290 }; 292 };
291 MockRead reads2[] = { 293 MockRead reads2[] = {
292 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), 294 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
293 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), 295 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
294 MockRead(false, 3, "two.html"), 296 MockRead(false, 3, "two.html"),
295 }; 297 };
296 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); 298 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2));
297 299
298 CompleteTwoRequests(); 300 CompleteTwoRequests(0, 3);
299 } 301 }
300 302
301 TEST_F(HttpPipelinedNetworkTransactionTest, ConnectionCloseEvictToNewPipeline) { 303 TEST_F(HttpPipelinedNetworkTransactionTest, ConnectionCloseEvictToNewPipeline) {
302 Initialize(); 304 Initialize();
303 305
304 MockWrite writes[] = { 306 MockWrite writes[] = {
305 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" 307 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
306 "Host: localhost\r\n" 308 "Host: localhost\r\n"
307 "Connection: keep-alive\r\n\r\n"), 309 "Connection: keep-alive\r\n\r\n"),
308 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" 310 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n"
(...skipping 13 matching lines...) Expand all
322 "Host: localhost\r\n" 324 "Host: localhost\r\n"
323 "Connection: keep-alive\r\n\r\n"), 325 "Connection: keep-alive\r\n\r\n"),
324 }; 326 };
325 MockRead reads2[] = { 327 MockRead reads2[] = {
326 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), 328 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
327 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), 329 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
328 MockRead(false, 3, "two.html"), 330 MockRead(false, 3, "two.html"),
329 }; 331 };
330 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); 332 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2));
331 333
332 CompleteTwoRequests(); 334 CompleteTwoRequests(0, 5);
333 } 335 }
334 336
335 TEST_F(HttpPipelinedNetworkTransactionTest, ErrorEvictsToNewPipeline) { 337 TEST_F(HttpPipelinedNetworkTransactionTest, ErrorEvictsToNewPipeline) {
336 Initialize(); 338 Initialize();
337 339
338 MockWrite writes[] = { 340 MockWrite writes[] = {
339 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" 341 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
340 "Host: localhost\r\n" 342 "Host: localhost\r\n"
341 "Connection: keep-alive\r\n\r\n"), 343 "Connection: keep-alive\r\n\r\n"),
342 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" 344 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 ERR_IO_PENDING, 503 ERR_IO_PENDING,
502 transaction.Start(GetRequestInfo("one.html"), &callback_, BoundNetLog())); 504 transaction.Start(GetRequestInfo("one.html"), &callback_, BoundNetLog()));
503 EXPECT_EQ(OK, callback_.WaitForResult()); 505 EXPECT_EQ(OK, callback_.WaitForResult());
504 506
505 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass")); 507 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass"));
506 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, &callback_)); 508 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, &callback_));
507 509
508 ExpectResponse("one.html", transaction); 510 ExpectResponse("one.html", transaction);
509 } 511 }
510 512
513 TEST_F(HttpPipelinedNetworkTransactionTest, OldVersionDisablesPipelining) {
514 Initialize();
515
516 MockWrite writes[] = {
517 MockWrite(false, 0, "GET /pipelined.html HTTP/1.1\r\n"
518 "Host: localhost\r\n"
519 "Connection: keep-alive\r\n\r\n"),
520 };
521 MockRead reads[] = {
522 MockRead(false, 1, "HTTP/1.0 200 OK\r\n"),
523 MockRead(false, 2, "Content-Length: 14\r\n\r\n"),
524 MockRead(false, 3, "pipelined.html"),
525 };
526 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
527
528 MockWrite writes2[] = {
529 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
530 "Host: localhost\r\n"
531 "Connection: keep-alive\r\n\r\n"),
532 };
533 MockRead reads2[] = {
534 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
535 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
536 MockRead(true, 3, "one.html"),
537 MockRead(false, OK, 4),
538 };
539 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2));
540
541 MockWrite writes3[] = {
542 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n"
543 "Host: localhost\r\n"
544 "Connection: keep-alive\r\n\r\n"),
545 };
546 MockRead reads3[] = {
547 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
548 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
549 MockRead(false, 3, "two.html"),
550 MockRead(false, OK, 4),
551 };
552 AddExpectedConnection(reads3, arraysize(reads3), writes3, arraysize(writes3));
553
554 HttpNetworkTransaction one_transaction(session_.get());
555 TestOldCompletionCallback one_callback;
556 EXPECT_EQ(ERR_IO_PENDING,
557 one_transaction.Start(GetRequestInfo("pipelined.html"),
558 &one_callback, BoundNetLog()));
559 EXPECT_EQ(OK, one_callback.WaitForResult());
560 ExpectResponse("pipelined.html", one_transaction);
561
562 CompleteTwoRequests(1, 4);
563 }
564
565 TEST_F(HttpPipelinedNetworkTransactionTest, PipelinesImmediatelyIfKnownGood) {
566 // The first request gets us an HTTP/1.1. The next 3 test pipelining. When the
567 // 3rd request completes, we know pipelining is safe. After the first 4
568 // complete, the 5th and 6th should then be immediately sent pipelined on a
569 // new HttpPipelinedConnection.
570 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group();
571 ClientSocketPoolManager::set_max_sockets_per_group(1);
572 Initialize();
573
574 MockWrite writes[] = {
575 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n"
576 "Host: localhost\r\n"
577 "Connection: keep-alive\r\n\r\n"),
578 MockWrite(false, 4, "GET /two.html HTTP/1.1\r\n"
579 "Host: localhost\r\n"
580 "Connection: keep-alive\r\n\r\n"),
581 MockWrite(false, 7, "GET /three.html HTTP/1.1\r\n"
582 "Host: localhost\r\n"
583 "Connection: keep-alive\r\n\r\n"),
584 MockWrite(false, 12, "GET /four.html HTTP/1.1\r\n"
585 "Host: localhost\r\n"
586 "Connection: keep-alive\r\n\r\n"),
587 MockWrite(false, 16, "GET /second-pipeline-one.html HTTP/1.1\r\n"
588 "Host: localhost\r\n"
589 "Connection: keep-alive\r\n\r\n"),
590 MockWrite(false, 17, "GET /second-pipeline-two.html HTTP/1.1\r\n"
591 "Host: localhost\r\n"
592 "Connection: keep-alive\r\n\r\n"),
593 };
594 MockRead reads[] = {
595 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
596 MockRead(false, 2, "Content-Length: 8\r\n\r\n"),
597 MockRead(false, 3, "one.html"),
598 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"),
599 MockRead(false, 6, "Content-Length: 8\r\n\r\n"),
600 MockRead(false, 8, "two.html"),
601 MockRead(false, 9, "HTTP/1.1 200 OK\r\n"),
602 MockRead(false, 10, "Content-Length: 10\r\n\r\n"),
603 MockRead(false, 11, "three.html"),
604 MockRead(false, 13, "HTTP/1.1 200 OK\r\n"),
605 MockRead(false, 14, "Content-Length: 9\r\n\r\n"),
606 MockRead(false, 15, "four.html"),
607 MockRead(true, 18, "HTTP/1.1 200 OK\r\n"),
608 MockRead(true, 19, "Content-Length: 24\r\n\r\n"),
609 MockRead(false, 20, "second-pipeline-one.html"),
610 MockRead(false, 21, "HTTP/1.1 200 OK\r\n"),
611 MockRead(false, 22, "Content-Length: 24\r\n\r\n"),
612 MockRead(false, 23, "second-pipeline-two.html"),
613 };
614 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes));
615
616 CompleteFourRequests();
617
618 HttpNetworkTransaction second_one_transaction(session_.get());
619 TestOldCompletionCallback second_one_callback;
620 EXPECT_EQ(ERR_IO_PENDING,
621 second_one_transaction.Start(
622 GetRequestInfo("second-pipeline-one.html"),
623 &second_one_callback, BoundNetLog()));
624 MessageLoop::current()->RunAllPending();
625
626 HttpNetworkTransaction second_two_transaction(session_.get());
627 TestOldCompletionCallback second_two_callback;
628 EXPECT_EQ(ERR_IO_PENDING,
629 second_two_transaction.Start(
630 GetRequestInfo("second-pipeline-two.html"),
631 &second_two_callback, BoundNetLog()));
632
633 data_vector_[0]->RunFor(3);
634 EXPECT_EQ(OK, second_one_callback.WaitForResult());
635 data_vector_[0]->StopAfter(100);
636 ExpectResponse("second-pipeline-one.html", second_one_transaction);
637 EXPECT_EQ(OK, second_two_callback.WaitForResult());
638 ExpectResponse("second-pipeline-two.html", second_two_transaction);
639
640 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets);
641 }
642
511 } // anonymous namespace 643 } // anonymous namespace
512 644
513 } // namespace net 645 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_pipelined_host_unittest.cc ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698