| Index: content/browser/loader/stream_writer.h
|
| diff --git a/content/browser/loader/stream_writer.h b/content/browser/loader/stream_writer.h
|
| index 64ce43e1528a3e992c8c1acc092162ca9c8913f3..f5aff2741eaa37fd1b6f410a116c1dafb9bc0b46 100644
|
| --- a/content/browser/loader/stream_writer.h
|
| +++ b/content/browser/loader/stream_writer.h
|
| @@ -5,6 +5,7 @@
|
| #ifndef CONTENT_BROWSER_LOADER_STREAM_WRITER_H_
|
| #define CONTENT_BROWSER_LOADER_STREAM_WRITER_H_
|
|
|
| +#include "base/callback.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "content/browser/streams/stream_write_observer.h"
|
| @@ -33,10 +34,6 @@ class StreamWriter : public StreamWriteObserver {
|
|
|
| Stream* stream() { return stream_.get(); }
|
|
|
| - void set_controller(ResourceController* controller) {
|
| - controller_ = controller;
|
| - }
|
| -
|
| // When immediate mode is enabled, the |stream_| is flushed every time new
|
| // data is made available by calls to OnReadCompleted.
|
| void set_immediate_mode(bool enabled) { immediate_mode_ = enabled; }
|
| @@ -44,9 +41,11 @@ class StreamWriter : public StreamWriteObserver {
|
| // Initializes the writer with a new Stream in |registry|. |origin| will be
|
| // used to construct the URL for the Stream. See WebCore::BlobURL and and
|
| // WebCore::SecurityOrigin in Blink to understand how origin check is done on
|
| - // resource loading.
|
| + // resource loading. |cancel_callback| must be called if the StreamWriter
|
| + // closes the stream.
|
| void InitializeStream(StreamRegistry* registry,
|
| - const GURL& origin);
|
| + const GURL& origin,
|
| + const base::Closure& cancel_callback);
|
|
|
| // Prepares a buffer to read data from the request. This call will be followed
|
| // by either OnReadCompleted (on successful read or EOF) or destruction. The
|
| @@ -60,12 +59,14 @@ class StreamWriter : public StreamWriteObserver {
|
| int* buf_size,
|
| int min_size);
|
|
|
| - // A read was completed, forward the data to the Stream. If |*defer| is set to
|
| - // true, the implementation must not continue to process the request until
|
| - // Resume is called on |controller_|.
|
| + // A read was completed, forward the data to the Stream.
|
| + // |need_more_data_callback| must be called (synchronously or asynchronously)
|
| + // once the writer is ready for more data. Invoking the callback may result
|
| + // in more data being received recursively.
|
| //
|
| // InitializeStream must have been called before calling OnReadCompleted.
|
| - void OnReadCompleted(int bytes_read, bool* defer);
|
| + void OnReadCompleted(int bytes_read,
|
| + const base::Closure& need_more_data_callback);
|
|
|
| // Called when there is no more data to read to the stream.
|
| void Finalize(int status);
|
| @@ -75,11 +76,13 @@ class StreamWriter : public StreamWriteObserver {
|
| void OnSpaceAvailable(Stream* stream) override;
|
| void OnClose(Stream* stream) override;
|
|
|
| - ResourceController* controller_;
|
| scoped_refptr<Stream> stream_;
|
| scoped_refptr<net::IOBuffer> read_buffer_;
|
| bool immediate_mode_;
|
|
|
| + base::Closure cancel_callback_;
|
| + base::Closure need_more_data_callback_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(StreamWriter);
|
| };
|
|
|
|
|