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

Unified Diff: content/browser/byte_stream.cc

Issue 18284005: Make ByteStream independent from DownloadInterruptReason (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reupload with the change made for rdsmith's comment Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/byte_stream.cc
diff --git a/content/browser/byte_stream.cc b/content/browser/byte_stream.cc
index f83e8c31641f7ee4a1763ec662e1d1d36439bb75..4b06ac54f5e8132202f512be6b6f2db45dcba44d 100644
--- a/content/browser/byte_stream.cc
+++ b/content/browser/byte_stream.cc
@@ -55,7 +55,7 @@ class ByteStreamWriterImpl : public ByteStreamWriter {
// Overridden from ByteStreamWriter.
virtual bool Write(scoped_refptr<net::IOBuffer> buffer,
size_t byte_count) OVERRIDE;
- virtual void Close(DownloadInterruptReason status) OVERRIDE;
+ virtual void Close(int status) OVERRIDE;
virtual void RegisterCallback(const base::Closure& source_callback) OVERRIDE;
// PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|.
@@ -67,7 +67,7 @@ class ByteStreamWriterImpl : public ByteStreamWriter {
// Called from UpdateWindow when object existence has been validated.
void UpdateWindowInternal(size_t bytes_consumed);
- void PostToPeer(bool complete, DownloadInterruptReason status);
+ void PostToPeer(bool complete, int status);
const size_t total_buffer_size_;
@@ -113,7 +113,7 @@ class ByteStreamReaderImpl : public ByteStreamReader {
// Overridden from ByteStreamReader.
virtual StreamState Read(scoped_refptr<net::IOBuffer>* data,
size_t* length) OVERRIDE;
- virtual DownloadInterruptReason GetStatus() const OVERRIDE;
+ virtual int GetStatus() const OVERRIDE;
virtual void RegisterCallback(const base::Closure& sink_callback) OVERRIDE;
// PostTask target from |ByteStreamWriterImpl::MaybePostToPeer| and
@@ -128,7 +128,7 @@ class ByteStreamReaderImpl : public ByteStreamReader {
scoped_ptr<ContentVector> transfer_buffer,
size_t transfer_buffer_bytes,
bool source_complete,
- DownloadInterruptReason status);
+ int status);
private:
// Called from TransferData once object existence has been validated.
@@ -136,7 +136,7 @@ class ByteStreamReaderImpl : public ByteStreamReader {
scoped_ptr<ContentVector> transfer_buffer,
size_t transfer_buffer_bytes,
bool source_complete,
- DownloadInterruptReason status);
+ int status);
void MaybeUpdateInput();
@@ -150,7 +150,7 @@ class ByteStreamReaderImpl : public ByteStreamReader {
ContentVector available_contents_;
bool received_status_;
- DownloadInterruptReason status_;
+ int status_;
base::Closure data_available_callback_;
@@ -210,13 +210,12 @@ bool ByteStreamWriterImpl::Write(
// Arbitrarily, we buffer to a third of the total size before sending.
if (input_contents_size_ > total_buffer_size_ / kFractionBufferBeforeSending)
- PostToPeer(false, DOWNLOAD_INTERRUPT_REASON_NONE);
+ PostToPeer(false, 0 /* status */);
return (input_contents_size_ + output_size_used_ <= total_buffer_size_);
}
-void ByteStreamWriterImpl::Close(
- DownloadInterruptReason status) {
+void ByteStreamWriterImpl::Close(int status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
PostToPeer(true, status);
}
@@ -252,8 +251,7 @@ void ByteStreamWriterImpl::UpdateWindowInternal(size_t bytes_consumed) {
space_available_callback_.Run();
}
-void ByteStreamWriterImpl::PostToPeer(
- bool complete, DownloadInterruptReason status) {
+void ByteStreamWriterImpl::PostToPeer(bool complete, int status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
// Valid contexts in which to call.
DCHECK(complete || 0 != input_contents_size_);
@@ -286,7 +284,7 @@ ByteStreamReaderImpl::ByteStreamReaderImpl(
my_task_runner_(task_runner),
my_lifetime_flag_(lifetime_flag),
received_status_(false),
- status_(DOWNLOAD_INTERRUPT_REASON_NONE),
+ status_(0),
unreported_consumed_bytes_(0),
peer_(NULL) {
DCHECK(my_lifetime_flag_.get());
@@ -326,7 +324,7 @@ ByteStreamReaderImpl::Read(scoped_refptr<net::IOBuffer>* data,
return STREAM_EMPTY;
}
-DownloadInterruptReason ByteStreamReaderImpl::GetStatus() const {
+int ByteStreamReaderImpl::GetStatus() const {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
DCHECK(received_status_);
return status_;
@@ -346,7 +344,7 @@ void ByteStreamReaderImpl::TransferData(
scoped_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
- DownloadInterruptReason status) {
+ int status) {
// If our target is no longer alive, do nothing.
if (!object_lifetime_flag->is_alive) return;
@@ -358,7 +356,7 @@ void ByteStreamReaderImpl::TransferDataInternal(
scoped_ptr<ContentVector> transfer_buffer,
size_t buffer_size,
bool source_complete,
- DownloadInterruptReason status) {
+ int status) {
DCHECK(my_task_runner_->RunsTasksOnCurrentThread());
bool was_empty = available_contents_.empty();

Powered by Google App Engine
This is Rietveld 408576698