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

Side by Side Diff: net/socket/socket_test_util.cc

Issue 10690104: DeterministicSocketDataProvider should not be RefCounted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more leak fix Created 8 years, 5 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
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_http_stream_spdy3_unittest.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 "net/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 size_t reads_count, MockWrite* writes, size_t writes_count) 445 size_t reads_count, MockWrite* writes, size_t writes_count)
446 : StaticSocketDataProvider(reads, reads_count, writes, writes_count), 446 : StaticSocketDataProvider(reads, reads_count, writes, writes_count),
447 sequence_number_(0), 447 sequence_number_(0),
448 current_read_(), 448 current_read_(),
449 current_write_(), 449 current_write_(),
450 stopping_sequence_number_(0), 450 stopping_sequence_number_(0),
451 stopped_(false), 451 stopped_(false),
452 print_debug_(false) { 452 print_debug_(false) {
453 } 453 }
454 454
455 DeterministicSocketData::~DeterministicSocketData() {}
456
455 void DeterministicSocketData::Run() { 457 void DeterministicSocketData::Run() {
456 SetStopped(false); 458 SetStopped(false);
457 int counter = 0; 459 int counter = 0;
458 // Continue to consume data until all data has run out, or the stopped_ flag 460 // Continue to consume data until all data has run out, or the stopped_ flag
459 // has been set. Consuming data requires two separate operations -- running 461 // has been set. Consuming data requires two separate operations -- running
460 // the tasks in the message loop, and explicitly invoking the read/write 462 // the tasks in the message loop, and explicitly invoking the read/write
461 // callbacks (simulating network I/O). We check our conditions between each, 463 // callbacks (simulating network I/O). We check our conditions between each,
462 // since they can change in either. 464 // since they can change in either.
463 while ((!at_write_eof() || !at_read_eof()) && !stopped()) { 465 while ((!at_write_eof() || !at_read_eof()) && !stopped()) {
464 if (counter % 2 == 0) 466 if (counter % 2 == 0)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 573 }
572 574
573 void DeterministicSocketData::Reset() { 575 void DeterministicSocketData::Reset() {
574 NET_TRACE(INFO, " *** ") << "Stage " 576 NET_TRACE(INFO, " *** ") << "Stage "
575 << sequence_number_ << ": Reset()"; 577 << sequence_number_ << ": Reset()";
576 sequence_number_ = 0; 578 sequence_number_ = 0;
577 StaticSocketDataProvider::Reset(); 579 StaticSocketDataProvider::Reset();
578 NOTREACHED(); 580 NOTREACHED();
579 } 581 }
580 582
581 DeterministicSocketData::~DeterministicSocketData() {}
582
583 void DeterministicSocketData::InvokeCallbacks() { 583 void DeterministicSocketData::InvokeCallbacks() {
584 if (socket_ && socket_->write_pending() && 584 if (socket_ && socket_->write_pending() &&
585 (current_write().sequence_number == sequence_number())) { 585 (current_write().sequence_number == sequence_number())) {
586 socket_->CompleteWrite(); 586 socket_->CompleteWrite();
587 NextStep(); 587 NextStep();
588 return; 588 return;
589 } 589 }
590 if (socket_ && socket_->read_pending() && 590 if (socket_ && socket_->read_pending() &&
591 (current_read().sequence_number == sequence_number())) { 591 (current_read().sequence_number == sequence_number())) {
592 socket_->CompleteRead(); 592 socket_->CompleteRead();
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 1641
1642 const char kSOCKS5OkRequest[] = 1642 const char kSOCKS5OkRequest[] =
1643 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1643 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1644 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1644 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1645 1645
1646 const char kSOCKS5OkResponse[] = 1646 const char kSOCKS5OkResponse[] =
1647 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1647 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1648 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1648 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1649 1649
1650 } // namespace net 1650 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698