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

Side by Side Diff: content/browser/byte_stream_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « content/browser/byte_stream.cc ('k') | content/browser/child_process_launcher.cc » ('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) 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 "content/browser/byte_stream.h" 5 #include "content/browser/byte_stream.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <deque> 9 #include <deque>
10 #include <limits> 10 #include <limits>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 std::deque<size_t> length_queue_; 96 std::deque<size_t> length_queue_;
97 }; 97 };
98 98
99 ByteStreamTest::ByteStreamTest() 99 ByteStreamTest::ByteStreamTest()
100 : producing_seed_key_(0), 100 : producing_seed_key_(0),
101 consuming_seed_key_(0) { } 101 consuming_seed_key_(0) { }
102 102
103 // Confirm that filling and emptying the stream works properly, and that 103 // Confirm that filling and emptying the stream works properly, and that
104 // we get full triggers when we expect. 104 // we get full triggers when we expect.
105 TEST_F(ByteStreamTest, ByteStream_PushBack) { 105 TEST_F(ByteStreamTest, ByteStream_PushBack) {
106 scoped_ptr<ByteStreamWriter> byte_stream_input; 106 std::unique_ptr<ByteStreamWriter> byte_stream_input;
107 scoped_ptr<ByteStreamReader> byte_stream_output; 107 std::unique_ptr<ByteStreamReader> byte_stream_output;
108 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 108 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
109 3 * 1024, &byte_stream_input, &byte_stream_output); 109 3 * 1024, &byte_stream_input, &byte_stream_output);
110 110
111 // Push a series of IO buffers on; test pushback happening and 111 // Push a series of IO buffers on; test pushback happening and
112 // that it's advisory. 112 // that it's advisory.
113 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 113 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
114 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 114 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
115 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 115 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
116 EXPECT_FALSE(Write(byte_stream_input.get(), 1)); 116 EXPECT_FALSE(Write(byte_stream_input.get(), 1));
117 EXPECT_FALSE(Write(byte_stream_input.get(), 1024)); 117 EXPECT_FALSE(Write(byte_stream_input.get(), 1024));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 byte_stream_output->Read(&output_io_buffer, &output_length)); 150 byte_stream_output->Read(&output_io_buffer, &output_length));
151 151
152 message_loop_.RunUntilIdle(); 152 message_loop_.RunUntilIdle();
153 // Reader now knows that all data is read out. 153 // Reader now knows that all data is read out.
154 EXPECT_EQ(1024U, byte_stream_input->GetTotalBufferedBytes()); 154 EXPECT_EQ(1024U, byte_stream_input->GetTotalBufferedBytes());
155 } 155 }
156 156
157 // Confirm that Flush() method makes the writer to send written contents to 157 // Confirm that Flush() method makes the writer to send written contents to
158 // the reader. 158 // the reader.
159 TEST_F(ByteStreamTest, ByteStream_Flush) { 159 TEST_F(ByteStreamTest, ByteStream_Flush) {
160 scoped_ptr<ByteStreamWriter> byte_stream_input; 160 std::unique_ptr<ByteStreamWriter> byte_stream_input;
161 scoped_ptr<ByteStreamReader> byte_stream_output; 161 std::unique_ptr<ByteStreamReader> byte_stream_output;
162 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 162 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
163 1024, &byte_stream_input, &byte_stream_output); 163 1024, &byte_stream_input, &byte_stream_output);
164 164
165 EXPECT_TRUE(Write(byte_stream_input.get(), 1)); 165 EXPECT_TRUE(Write(byte_stream_input.get(), 1));
166 message_loop_.RunUntilIdle(); 166 message_loop_.RunUntilIdle();
167 167
168 scoped_refptr<net::IOBuffer> output_io_buffer; 168 scoped_refptr<net::IOBuffer> output_io_buffer;
169 size_t output_length = 0; 169 size_t output_length = 0;
170 // Check that data is not sent to the reader yet. 170 // Check that data is not sent to the reader yet.
171 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 171 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
(...skipping 17 matching lines...) Expand all
189 message_loop_.RunUntilIdle(); 189 message_loop_.RunUntilIdle();
190 190
191 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE, 191 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE,
192 byte_stream_output->Read(&output_io_buffer, &output_length)); 192 byte_stream_output->Read(&output_io_buffer, &output_length));
193 } 193 }
194 194
195 // Same as above, only use knowledge of the internals to confirm 195 // Same as above, only use knowledge of the internals to confirm
196 // that we're getting pushback even when data's split across the two 196 // that we're getting pushback even when data's split across the two
197 // objects 197 // objects
198 TEST_F(ByteStreamTest, ByteStream_PushBackSplit) { 198 TEST_F(ByteStreamTest, ByteStream_PushBackSplit) {
199 scoped_ptr<ByteStreamWriter> byte_stream_input; 199 std::unique_ptr<ByteStreamWriter> byte_stream_input;
200 scoped_ptr<ByteStreamReader> byte_stream_output; 200 std::unique_ptr<ByteStreamReader> byte_stream_output;
201 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 201 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
202 9 * 1024, &byte_stream_input, &byte_stream_output); 202 9 * 1024, &byte_stream_input, &byte_stream_output);
203 203
204 // Push a series of IO buffers on; test pushback happening and 204 // Push a series of IO buffers on; test pushback happening and
205 // that it's advisory. 205 // that it's advisory.
206 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 206 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
207 message_loop_.RunUntilIdle(); 207 message_loop_.RunUntilIdle();
208 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 208 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
209 message_loop_.RunUntilIdle(); 209 message_loop_.RunUntilIdle();
210 EXPECT_TRUE(Write(byte_stream_input.get(), 1024)); 210 EXPECT_TRUE(Write(byte_stream_input.get(), 1024));
(...skipping 27 matching lines...) Expand all
238 byte_stream_output->Read(&output_io_buffer, &output_length)); 238 byte_stream_output->Read(&output_io_buffer, &output_length));
239 EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length)); 239 EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
240 240
241 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 241 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
242 byte_stream_output->Read(&output_io_buffer, &output_length)); 242 byte_stream_output->Read(&output_io_buffer, &output_length));
243 } 243 }
244 244
245 // Confirm that a Close() notification transmits in-order 245 // Confirm that a Close() notification transmits in-order
246 // with data on the stream. 246 // with data on the stream.
247 TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) { 247 TEST_F(ByteStreamTest, ByteStream_CompleteTransmits) {
248 scoped_ptr<ByteStreamWriter> byte_stream_input; 248 std::unique_ptr<ByteStreamWriter> byte_stream_input;
249 scoped_ptr<ByteStreamReader> byte_stream_output; 249 std::unique_ptr<ByteStreamReader> byte_stream_output;
250 250
251 scoped_refptr<net::IOBuffer> output_io_buffer; 251 scoped_refptr<net::IOBuffer> output_io_buffer;
252 size_t output_length; 252 size_t output_length;
253 253
254 // Empty stream, non-error case. 254 // Empty stream, non-error case.
255 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 255 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
256 3 * 1024, &byte_stream_input, &byte_stream_output); 256 3 * 1024, &byte_stream_input, &byte_stream_output);
257 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 257 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
258 byte_stream_output->Read(&output_io_buffer, &output_length)); 258 byte_stream_output->Read(&output_io_buffer, &output_length));
259 byte_stream_input->Close(0); 259 byte_stream_input->Close(0);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE, 304 ASSERT_EQ(ByteStreamReader::STREAM_COMPLETE,
305 byte_stream_output->Read(&output_io_buffer, &output_length)); 305 byte_stream_output->Read(&output_io_buffer, &output_length));
306 EXPECT_EQ(kFakeErrorCode, byte_stream_output->GetStatus()); 306 EXPECT_EQ(kFakeErrorCode, byte_stream_output->GetStatus());
307 } 307 }
308 308
309 // Confirm that callbacks on the sink side are triggered when they should be. 309 // Confirm that callbacks on the sink side are triggered when they should be.
310 TEST_F(ByteStreamTest, ByteStream_SinkCallback) { 310 TEST_F(ByteStreamTest, ByteStream_SinkCallback) {
311 scoped_refptr<base::TestSimpleTaskRunner> task_runner( 311 scoped_refptr<base::TestSimpleTaskRunner> task_runner(
312 new base::TestSimpleTaskRunner()); 312 new base::TestSimpleTaskRunner());
313 313
314 scoped_ptr<ByteStreamWriter> byte_stream_input; 314 std::unique_ptr<ByteStreamWriter> byte_stream_input;
315 scoped_ptr<ByteStreamReader> byte_stream_output; 315 std::unique_ptr<ByteStreamReader> byte_stream_output;
316 CreateByteStream(message_loop_.task_runner(), task_runner, 10000, 316 CreateByteStream(message_loop_.task_runner(), task_runner, 10000,
317 &byte_stream_input, &byte_stream_output); 317 &byte_stream_input, &byte_stream_output);
318 318
319 scoped_refptr<net::IOBuffer> output_io_buffer; 319 scoped_refptr<net::IOBuffer> output_io_buffer;
320 size_t output_length; 320 size_t output_length;
321 321
322 // Note that the specifics of when the callbacks are called with regard 322 // Note that the specifics of when the callbacks are called with regard
323 // to how much data is pushed onto the stream is not (currently) part 323 // to how much data is pushed onto the stream is not (currently) part
324 // of the interface contract. If it becomes part of the contract, the 324 // of the interface contract. If it becomes part of the contract, the
325 // tests below should get much more precise. 325 // tests below should get much more precise.
(...skipping 29 matching lines...) Expand all
355 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 355 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
356 byte_stream_output->Read(&output_io_buffer, &output_length)); 356 byte_stream_output->Read(&output_io_buffer, &output_length));
357 } 357 }
358 358
359 // Confirm that callbacks on the source side are triggered when they should 359 // Confirm that callbacks on the source side are triggered when they should
360 // be. 360 // be.
361 TEST_F(ByteStreamTest, ByteStream_SourceCallback) { 361 TEST_F(ByteStreamTest, ByteStream_SourceCallback) {
362 scoped_refptr<base::TestSimpleTaskRunner> task_runner( 362 scoped_refptr<base::TestSimpleTaskRunner> task_runner(
363 new base::TestSimpleTaskRunner()); 363 new base::TestSimpleTaskRunner());
364 364
365 scoped_ptr<ByteStreamWriter> byte_stream_input; 365 std::unique_ptr<ByteStreamWriter> byte_stream_input;
366 scoped_ptr<ByteStreamReader> byte_stream_output; 366 std::unique_ptr<ByteStreamReader> byte_stream_output;
367 CreateByteStream(task_runner, message_loop_.task_runner(), 10000, 367 CreateByteStream(task_runner, message_loop_.task_runner(), 10000,
368 &byte_stream_input, &byte_stream_output); 368 &byte_stream_input, &byte_stream_output);
369 369
370 scoped_refptr<net::IOBuffer> output_io_buffer; 370 scoped_refptr<net::IOBuffer> output_io_buffer;
371 size_t output_length; 371 size_t output_length;
372 372
373 // Note that the specifics of when the callbacks are called with regard 373 // Note that the specifics of when the callbacks are called with regard
374 // to how much data is pulled from the stream is not (currently) part 374 // to how much data is pulled from the stream is not (currently) part
375 // of the interface contract. If it becomes part of the contract, the 375 // of the interface contract. If it becomes part of the contract, the
376 // tests below should get much more precise. 376 // tests below should get much more precise.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // callback. 416 // callback.
417 EXPECT_EQ(1, num_callbacks); 417 EXPECT_EQ(1, num_callbacks);
418 } 418 }
419 419
420 // Confirm that racing a change to a sink callback with a post results 420 // Confirm that racing a change to a sink callback with a post results
421 // in the new callback being called. 421 // in the new callback being called.
422 TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) { 422 TEST_F(ByteStreamTest, ByteStream_SinkInterrupt) {
423 scoped_refptr<base::TestSimpleTaskRunner> task_runner( 423 scoped_refptr<base::TestSimpleTaskRunner> task_runner(
424 new base::TestSimpleTaskRunner()); 424 new base::TestSimpleTaskRunner());
425 425
426 scoped_ptr<ByteStreamWriter> byte_stream_input; 426 std::unique_ptr<ByteStreamWriter> byte_stream_input;
427 scoped_ptr<ByteStreamReader> byte_stream_output; 427 std::unique_ptr<ByteStreamReader> byte_stream_output;
428 CreateByteStream(message_loop_.task_runner(), task_runner, 10000, 428 CreateByteStream(message_loop_.task_runner(), task_runner, 10000,
429 &byte_stream_input, &byte_stream_output); 429 &byte_stream_input, &byte_stream_output);
430 430
431 scoped_refptr<net::IOBuffer> output_io_buffer; 431 scoped_refptr<net::IOBuffer> output_io_buffer;
432 size_t output_length; 432 size_t output_length;
433 base::Closure intermediate_callback; 433 base::Closure intermediate_callback;
434 434
435 // Record initial state. 435 // Record initial state.
436 int num_callbacks = 0; 436 int num_callbacks = 0;
437 byte_stream_output->RegisterCallback( 437 byte_stream_output->RegisterCallback(
(...skipping 24 matching lines...) Expand all
462 byte_stream_output->Read(&output_io_buffer, &output_length)); 462 byte_stream_output->Read(&output_io_buffer, &output_length));
463 463
464 } 464 }
465 465
466 // Confirm that racing a change to a source callback with a post results 466 // Confirm that racing a change to a source callback with a post results
467 // in the new callback being called. 467 // in the new callback being called.
468 TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) { 468 TEST_F(ByteStreamTest, ByteStream_SourceInterrupt) {
469 scoped_refptr<base::TestSimpleTaskRunner> task_runner( 469 scoped_refptr<base::TestSimpleTaskRunner> task_runner(
470 new base::TestSimpleTaskRunner()); 470 new base::TestSimpleTaskRunner());
471 471
472 scoped_ptr<ByteStreamWriter> byte_stream_input; 472 std::unique_ptr<ByteStreamWriter> byte_stream_input;
473 scoped_ptr<ByteStreamReader> byte_stream_output; 473 std::unique_ptr<ByteStreamReader> byte_stream_output;
474 CreateByteStream(task_runner, message_loop_.task_runner(), 10000, 474 CreateByteStream(task_runner, message_loop_.task_runner(), 10000,
475 &byte_stream_input, &byte_stream_output); 475 &byte_stream_input, &byte_stream_output);
476 476
477 scoped_refptr<net::IOBuffer> output_io_buffer; 477 scoped_refptr<net::IOBuffer> output_io_buffer;
478 size_t output_length; 478 size_t output_length;
479 base::Closure intermediate_callback; 479 base::Closure intermediate_callback;
480 480
481 // Setup state for test. 481 // Setup state for test.
482 int num_callbacks = 0; 482 int num_callbacks = 0;
483 byte_stream_input->RegisterCallback( 483 byte_stream_input->RegisterCallback(
(...skipping 29 matching lines...) Expand all
513 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 513 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
514 byte_stream_output->Read(&output_io_buffer, &output_length)); 514 byte_stream_output->Read(&output_io_buffer, &output_length));
515 } 515 }
516 516
517 // Confirm that callback is called on zero data transfer but source 517 // Confirm that callback is called on zero data transfer but source
518 // complete. 518 // complete.
519 TEST_F(ByteStreamTest, ByteStream_ZeroCallback) { 519 TEST_F(ByteStreamTest, ByteStream_ZeroCallback) {
520 scoped_refptr<base::TestSimpleTaskRunner> task_runner( 520 scoped_refptr<base::TestSimpleTaskRunner> task_runner(
521 new base::TestSimpleTaskRunner()); 521 new base::TestSimpleTaskRunner());
522 522
523 scoped_ptr<ByteStreamWriter> byte_stream_input; 523 std::unique_ptr<ByteStreamWriter> byte_stream_input;
524 scoped_ptr<ByteStreamReader> byte_stream_output; 524 std::unique_ptr<ByteStreamReader> byte_stream_output;
525 CreateByteStream(message_loop_.task_runner(), task_runner, 10000, 525 CreateByteStream(message_loop_.task_runner(), task_runner, 10000,
526 &byte_stream_input, &byte_stream_output); 526 &byte_stream_input, &byte_stream_output);
527 527
528 base::Closure intermediate_callback; 528 base::Closure intermediate_callback;
529 529
530 // Record initial state. 530 // Record initial state.
531 int num_callbacks = 0; 531 int num_callbacks = 0;
532 byte_stream_output->RegisterCallback( 532 byte_stream_output->RegisterCallback(
533 base::Bind(CountCallbacks, &num_callbacks)); 533 base::Bind(CountCallbacks, &num_callbacks));
534 534
535 // Immediately close the stream. 535 // Immediately close the stream.
536 byte_stream_input->Close(0); 536 byte_stream_input->Close(0);
537 task_runner->RunUntilIdle(); 537 task_runner->RunUntilIdle();
538 EXPECT_EQ(1, num_callbacks); 538 EXPECT_EQ(1, num_callbacks);
539 } 539 }
540 540
541 TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) { 541 TEST_F(ByteStreamTest, ByteStream_CloseWithoutAnyWrite) {
542 scoped_ptr<ByteStreamWriter> byte_stream_input; 542 std::unique_ptr<ByteStreamWriter> byte_stream_input;
543 scoped_ptr<ByteStreamReader> byte_stream_output; 543 std::unique_ptr<ByteStreamReader> byte_stream_output;
544 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 544 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
545 3 * 1024, &byte_stream_input, &byte_stream_output); 545 3 * 1024, &byte_stream_input, &byte_stream_output);
546 546
547 byte_stream_input->Close(0); 547 byte_stream_input->Close(0);
548 message_loop_.RunUntilIdle(); 548 message_loop_.RunUntilIdle();
549 549
550 scoped_refptr<net::IOBuffer> output_io_buffer; 550 scoped_refptr<net::IOBuffer> output_io_buffer;
551 size_t output_length; 551 size_t output_length;
552 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE, 552 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE,
553 byte_stream_output->Read(&output_io_buffer, &output_length)); 553 byte_stream_output->Read(&output_io_buffer, &output_length));
554 } 554 }
555 555
556 TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) { 556 TEST_F(ByteStreamTest, ByteStream_FlushWithoutAnyWrite) {
557 scoped_ptr<ByteStreamWriter> byte_stream_input; 557 std::unique_ptr<ByteStreamWriter> byte_stream_input;
558 scoped_ptr<ByteStreamReader> byte_stream_output; 558 std::unique_ptr<ByteStreamReader> byte_stream_output;
559 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 559 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
560 3 * 1024, &byte_stream_input, &byte_stream_output); 560 3 * 1024, &byte_stream_input, &byte_stream_output);
561 561
562 byte_stream_input->Flush(); 562 byte_stream_input->Flush();
563 message_loop_.RunUntilIdle(); 563 message_loop_.RunUntilIdle();
564 564
565 scoped_refptr<net::IOBuffer> output_io_buffer; 565 scoped_refptr<net::IOBuffer> output_io_buffer;
566 size_t output_length; 566 size_t output_length;
567 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 567 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
568 byte_stream_output->Read(&output_io_buffer, &output_length)); 568 byte_stream_output->Read(&output_io_buffer, &output_length));
569 569
570 byte_stream_input->Close(0); 570 byte_stream_input->Close(0);
571 message_loop_.RunUntilIdle(); 571 message_loop_.RunUntilIdle();
572 572
573 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE, 573 EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE,
574 byte_stream_output->Read(&output_io_buffer, &output_length)); 574 byte_stream_output->Read(&output_io_buffer, &output_length));
575 } 575 }
576 576
577 TEST_F(ByteStreamTest, ByteStream_WriteOverflow) { 577 TEST_F(ByteStreamTest, ByteStream_WriteOverflow) {
578 scoped_ptr<ByteStreamWriter> byte_stream_input; 578 std::unique_ptr<ByteStreamWriter> byte_stream_input;
579 scoped_ptr<ByteStreamReader> byte_stream_output; 579 std::unique_ptr<ByteStreamReader> byte_stream_output;
580 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(), 580 CreateByteStream(message_loop_.task_runner(), message_loop_.task_runner(),
581 std::numeric_limits<size_t>::max(), &byte_stream_input, 581 std::numeric_limits<size_t>::max(), &byte_stream_input,
582 &byte_stream_output); 582 &byte_stream_output);
583 583
584 EXPECT_TRUE(Write(byte_stream_input.get(), 1)); 584 EXPECT_TRUE(Write(byte_stream_input.get(), 1));
585 // 1 + size_t max -> Overflow. 585 // 1 + size_t max -> Overflow.
586 scoped_refptr<net::IOBuffer> empty_io_buffer; 586 scoped_refptr<net::IOBuffer> empty_io_buffer;
587 EXPECT_FALSE(byte_stream_input->Write(empty_io_buffer, 587 EXPECT_FALSE(byte_stream_input->Write(empty_io_buffer,
588 std::numeric_limits<size_t>::max())); 588 std::numeric_limits<size_t>::max()));
589 message_loop_.RunUntilIdle(); 589 message_loop_.RunUntilIdle();
590 590
591 // The first write is below PostToPeer threshold. We shouldn't get anything 591 // The first write is below PostToPeer threshold. We shouldn't get anything
592 // from the output. 592 // from the output.
593 scoped_refptr<net::IOBuffer> output_io_buffer; 593 scoped_refptr<net::IOBuffer> output_io_buffer;
594 size_t output_length; 594 size_t output_length;
595 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY, 595 EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
596 byte_stream_output->Read(&output_io_buffer, &output_length)); 596 byte_stream_output->Read(&output_io_buffer, &output_length));
597 } 597 }
598 598
599 } // namespace content 599 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/byte_stream.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698