diff options
author | honghaiz@chromium.org <honghaiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 23:57:17 +0000 |
---|---|---|
committer | honghaiz@chromium.org <honghaiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 23:57:17 +0000 |
commit | f1cc7472027ca129e07f99b5d7978c4c5b28b62e (patch) | |
tree | eea369acd5d306a66fcf72b9940cd5c41598c7cd | |
parent | 6454e352e6e65d4dc3f462f0edfd1d9d3cda3c9b (diff) | |
download | chromium_src-f1cc7472027ca129e07f99b5d7978c4c5b28b62e.zip chromium_src-f1cc7472027ca129e07f99b5d7978c4c5b28b62e.tar.gz chromium_src-f1cc7472027ca129e07f99b5d7978c4c5b28b62e.tar.bz2 |
This attempts to fix a chrome crash bug.
BUG=273917
Review URL: https://chromiumcodereview.appspot.com/23025006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218122 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/network_stats.cc | 24 | ||||
-rw-r--r-- | chrome/browser/net/network_stats.h | 4 |
2 files changed, 16 insertions, 12 deletions
diff --git a/chrome/browser/net/network_stats.cc b/chrome/browser/net/network_stats.cc index 4898a4b..9f1ae72 100644 --- a/chrome/browser/net/network_stats.cc +++ b/chrome/browser/net/network_stats.cc @@ -237,7 +237,9 @@ void NetworkStats::SendHelloRequest() { probe_packet.set_group_id(current_test_index_); std::string output = probe_message_.MakeEncodedPacket(probe_packet); - SendData(output); + int result = SendData(output); + if (result < 0 && result != net::ERR_IO_PENDING) + TestPhaseComplete(WRITE_FAILED, result); } void NetworkStats::SendProbeRequest() { @@ -284,7 +286,9 @@ void NetworkStats::SendProbeRequest() { StartReadDataTimer(timeout_seconds, current_test_index_); probe_request_time_ = base::TimeTicks::Now(); - SendData(output); + int result = SendData(output); + if (result < 0 && result != net::ERR_IO_PENDING) + TestPhaseComplete(WRITE_FAILED, result); } void NetworkStats::ReadData() { @@ -407,8 +411,9 @@ bool NetworkStats::UpdateReception(const ProbePacket& probe_packet) { return true; } -void NetworkStats::SendData(const std::string& output) { - DCHECK(!write_buffer_.get()); +int NetworkStats::SendData(const std::string& output) { + if (write_buffer_.get() || !socket_.get()) + return net::ERR_UNEXPECTED; scoped_refptr<net::StringIOBuffer> buffer(new net::StringIOBuffer(output)); write_buffer_ = new net::DrainableIOBuffer(buffer.get(), buffer->size()); @@ -416,13 +421,10 @@ void NetworkStats::SendData(const std::string& output) { write_buffer_.get(), write_buffer_->BytesRemaining(), base::Bind(&NetworkStats::OnWriteComplete, base::Unretained(this))); - if (bytes_written < 0) { - if (bytes_written != net::ERR_IO_PENDING) - // There is some unexpected error. - TestPhaseComplete(WRITE_FAILED, bytes_written); - } else { - UpdateSendBuffer(bytes_written); - } + if (bytes_written < 0) + return bytes_written; + UpdateSendBuffer(bytes_written); + return net::OK; } void NetworkStats::OnWriteComplete(int result) { diff --git a/chrome/browser/net/network_stats.h b/chrome/browser/net/network_stats.h index 7f80a031..59bf0b0 100644 --- a/chrome/browser/net/network_stats.h +++ b/chrome/browser/net/network_stats.h @@ -146,7 +146,9 @@ class NetworkStats { void ReadData(); // Send data contained in |str| to server. - void SendData(const std::string& str); + // Return a negative value if IO blocking occurs or there is an error. + // Otherwise return net::OK. + int SendData(const std::string& str); // Update the send buffer (telling it that |bytes_sent| has been sent). // And reset |write_buffer_|. |