Commit 748561e0 authored by yhirano's avatar yhirano Committed by Commit bot

Add WARN_UNUSED_RESULT to BytesConsumer read methods.

BUG=610195

Review-Url: https://codereview.chromium.org/2319033002
Cr-Commit-Position: refs/heads/master@{#418506}
parent 106e57c5
......@@ -9,6 +9,7 @@
#include "platform/blob/BlobData.h"
#include "platform/heap/Handle.h"
#include "platform/network/EncodedFormData.h"
#include "wtf/Compiler.h"
#include "wtf/PassRefPtr.h"
#include "wtf/text/WTFString.h"
......@@ -82,7 +83,7 @@ public:
// Returns Error when errored.
// |buffer| can be null if |size| is 0.
// |*readSize| will be set to 0 if not readable.
virtual Result read(char* buffer, size_t /* size */, size_t* readSize);
virtual Result read(char* buffer, size_t /* size */, size_t* readSize) WARN_UNUSED_RESULT;
// Begins a two-phase read. On success, the function stores a buffer
// that contains the read data of length |*available| into |*buffer|.
......@@ -98,10 +99,10 @@ public:
//
// |*buffer| will be set to null and |*available| will be set to 0 if not
// readable.
virtual Result beginRead(const char** buffer, size_t* available) = 0;
virtual Result beginRead(const char** buffer, size_t* available) WARN_UNUSED_RESULT = 0;
// Ends a two-phase read.
virtual Result endRead(size_t readSize) = 0;
virtual Result endRead(size_t readSize) WARN_UNUSED_RESULT = 0;
// Drains the data as a BlobDataHandle.
// When this function returns a non-null value, the returned blob handle
......
......@@ -209,7 +209,10 @@ void BytesConsumerTestUtil::TwoPhaseReader::onStateChange()
// because of the same reasons as Reader::onStateChange.
size_t read = std::max(static_cast<size_t>(3), available);
m_data.append(buffer, read);
m_consumer->endRead(read);
if (m_consumer->endRead(read) != BytesConsumer::Result::Ok) {
m_result = BytesConsumer::Result::Error;
return;
}
break;
}
case BytesConsumer::Result::ShouldWait:
......
......@@ -63,7 +63,10 @@ public:
switch (m_consumer->beginRead(&buffer, &available)) {
case BytesConsumer::Result::Ok:
m_blobData->appendBytes(buffer, available);
m_consumer->endRead(available);
if (m_consumer->endRead(available) != BytesConsumer::Result::Ok) {
m_client->didFetchDataLoadFailed();
return;
}
break;
case BytesConsumer::Result::ShouldWait:
return;
......@@ -125,14 +128,18 @@ public:
if (available > 0) {
unsigned bytesAppended = m_rawData->append(buffer, available);
if (!bytesAppended) {
m_consumer->endRead(0);
auto unused = m_consumer->endRead(0);
ALLOW_UNUSED_LOCAL(unused);
m_consumer->cancel();
m_client->didFetchDataLoadFailed();
return;
}
DCHECK_EQ(bytesAppended, available);
}
m_consumer->endRead(available);
if (m_consumer->endRead(available) != BytesConsumer::Result::Ok) {
m_client->didFetchDataLoadFailed();
return;
}
break;
case BytesConsumer::Result::ShouldWait:
return;
......@@ -185,7 +192,10 @@ public:
case BytesConsumer::Result::Ok:
if (available > 0)
m_builder.append(m_decoder->decode(buffer, available));
m_consumer->endRead(available);
if (m_consumer->endRead(available) != BytesConsumer::Result::Ok) {
m_client->didFetchDataLoadFailed();
return;
}
break;
case BytesConsumer::Result::ShouldWait:
return;
......@@ -248,7 +258,11 @@ public:
switch (m_consumer->beginRead(&buffer, &available)) {
case BytesConsumer::Result::Ok:
m_outStream->addData(buffer, available);
m_consumer->endRead(available);
if (m_consumer->endRead(available) != BytesConsumer::Result::Ok) {
m_outStream->abort();
m_client->didFetchDataLoadFailed();
return;
}
needToFlush = true;
break;
case BytesConsumer::Result::ShouldWait:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment