| Index: content/browser/loader/mojo_stream_writer.h
|
| diff --git a/content/browser/loader/stream_writer.h b/content/browser/loader/mojo_stream_writer.h
|
| similarity index 58%
|
| copy from content/browser/loader/stream_writer.h
|
| copy to content/browser/loader/mojo_stream_writer.h
|
| index 0b243db8b68b42c01a383de2a8d8688de392649f..2bd245b7d8f64eb24209fc38c02f75c7d309bd88 100644
|
| --- a/content/browser/loader/stream_writer.h
|
| +++ b/content/browser/loader/mojo_stream_writer.h
|
| @@ -1,13 +1,14 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_LOADER_STREAM_WRITER_H_
|
| -#define CONTENT_BROWSER_LOADER_STREAM_WRITER_H_
|
| +#ifndef CONTENT_BROWSER_LOADER_MOJO_STREAM_WRITER_H_
|
| +#define CONTENT_BROWSER_LOADER_MOJO_STREAM_WRITER_H_
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| -#include "content/browser/streams/stream_write_observer.h"
|
| +#include "mojo/message_pump/handle_watcher.h"
|
| +#include "mojo/public/cpp/system/data_pipe.h"
|
|
|
| class GURL;
|
|
|
| @@ -18,20 +19,18 @@ class IOBuffer;
|
| namespace content {
|
|
|
| class ResourceController;
|
| -class Stream;
|
| -class StreamRegistry;
|
|
|
| -// StreamWriter is a helper class for ResourceHandlers which route their output
|
| +// MojoStreamWriter is a helper class for ResourceHandlers which route their output
|
| // into a Stream. It manages an internal buffer and handles back-pressure from
|
| // the Stream's reader.
|
| -class StreamWriter : public StreamWriteObserver {
|
| +class MojoStreamWriter {
|
| public:
|
| - // Creates a new StreamWriter without an initialized Stream or controller. The
|
| + // Creates a new MojoStreamWriter without an initialized Stream or controller. The
|
| // controller must be set before the writer is used.
|
| - StreamWriter();
|
| - ~StreamWriter() override;
|
| + MojoStreamWriter();
|
| + ~MojoStreamWriter();
|
|
|
| - Stream* stream() { return stream_.get(); }
|
| + bool has_stream() { return data_producer_handle_.is_valid(); }
|
|
|
| void set_controller(ResourceController* controller) {
|
| controller_ = controller;
|
| @@ -45,8 +44,7 @@ class StreamWriter : public StreamWriteObserver {
|
| // 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.
|
| - void InitializeStream(StreamRegistry* registry,
|
| - const GURL& origin);
|
| + void InitializeStream(mojo::ScopedDataPipeConsumerHandle* data_consumer_handle);
|
|
|
| // 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
|
| @@ -70,19 +68,29 @@ class StreamWriter : public StreamWriteObserver {
|
| // Called when there is no more data to read to the stream.
|
| void Finalize();
|
|
|
| + static const int kReadBufSize = 32768;
|
| +
|
| private:
|
| - // StreamWriteObserver implementation.
|
| - void OnSpaceAvailable(Stream* stream) override;
|
| - void OnClose(Stream* stream) override;
|
| + // TODO(carlosk): maybe there is (or we need to create) an "official" pipe
|
| + // observer API.
|
| + void OnSpaceAvailable(MojoResult result);
|
| + // void OnClose(Stream* stream) override;
|
|
|
| ResourceController* controller_;
|
| - scoped_refptr<Stream> stream_;
|
| - scoped_refptr<net::IOBuffer> read_buffer_;
|
| + // TODO(carlosk): do we need this with Mojo?
|
| bool immediate_mode_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(StreamWriter);
|
| + // MIGHT NEED TO MOVE THIS ELSEWHERE AND STILL OFFER THE ResourceController INTERFACE.
|
| + // https://code.google.com/p/chromium/codesearch#chromium/src/content/public/browser/resource_controller.h
|
| + // Use as model: https://code.google.com/p/chromium/codesearch#chromium/src/mojo/services/tracing/trace_data_sink.cc
|
| + mojo::ScopedDataPipeProducerHandle data_producer_handle_;
|
| + mojo::common::HandleWatcher handle_watcher_;
|
| + void* buffer_;
|
| + uint32_t buffer_size_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MojoStreamWriter);
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_LOADER_STREAM_WRITER_H_
|
| +#endif // CONTENT_BROWSER_LOADER_MOJO_STREAM_WRITER_H_
|
|
|