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

Unified Diff: content/browser/loader/stream_writer.h

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Response to comments Created 3 years, 11 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
« no previous file with comments | « content/browser/loader/stream_resource_handler.cc ('k') | content/browser/loader/stream_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f6d974de0dd8c6fa2f6f4208eab60a8ba38320c8 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"
@@ -17,7 +18,6 @@ class IOBuffer;
namespace content {
-class ResourceController;
class Stream;
class StreamRegistry;
@@ -33,10 +33,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 +40,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 +58,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 +75,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);
};
« no previous file with comments | « content/browser/loader/stream_resource_handler.cc ('k') | content/browser/loader/stream_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698