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

Unified Diff: content/child/mojo_pipe_received_data.h

Issue 1693563002: PROTOTYPE: PlzNavigate: use a Mojo data pipe to stream navigation data to the renderer. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser sends URLRequest id to the renderer and renderer uses intermediary buffer for data: none he… Created 4 years, 9 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/resource_dispatcher_host_impl.cc ('k') | content/child/mojo_pipe_received_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/mojo_pipe_received_data.h
diff --git a/content/child/mojo_pipe_received_data.h b/content/child/mojo_pipe_received_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..c7314f50c8933cd7706dddda8debe1a0dd2420e4
--- /dev/null
+++ b/content/child/mojo_pipe_received_data.h
@@ -0,0 +1,68 @@
+// Copyright 2015 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_CHILD_MOJO_PIPI_RECEIVED_DATA_
+#define CONTENT_CHILD_MOJO_PIPI_RECEIVED_DATA_
+
+#include "content/public/child/request_peer.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+
+// This class implements a minimal RequestPeer::ReceivedData for consuming data
+// from a Mojo pipe.
+//
+// This is based off of:
+// * mojo/common/data_pipe_drainer.cc for consuming a Mojo data pipe.
+// * content/child/shared_memory_received_data_factory.h for ReceivedData
+// implementation.
+//
+// TODO(carlosk): We might need a factory model as well like it's done in
+// SharedMemoryReceivedDataFactory to handle the case of the pipe being closed
+// while there are results floating around. This is a problem similar to the one
+// with the buffer on the browser side.
+
+namespace content {
+
+class MojoPipeReceivedData final : public RequestPeer::ReceivedData {
+ public:
+ static scoped_ptr<RequestPeer::ReceivedData> Create(
+ mojo::DataPipeConsumerHandle source,
+ const void* buffer,
+ uint32_t num_bytes);
+
+ ~MojoPipeReceivedData() override;
+
+ // RequestPeer::ReceivedData implementation.
+ const char* payload() const override;
+ int length() const override;
+ int encoded_length() const override;
+
+ private:
+ MojoPipeReceivedData(mojo::DataPipeConsumerHandle source,
+ const void* buffer,
+ uint32_t num_bytes);
+
+ // TODO(carlosk): to be safer and simpler I'm making a copy of the data to a
+ // intermediary buffer. Final implementation should hold the internal Mojo
+ // buffer alive until being destroyed.
+ // TODO(carlosk): we need to hold a reference to the source pipe to be able to
+ // get then later release the internal Mojo buffer with the data (instead of
+ // having an extra step of copying it out into another buffer). This *might*
+ // also be required to stop the producer of sending more data while we haven't
+ // consumed the current bundle (otherwise how does Mojo know about this at
+ // all?).
+ // The problems is that we don't want its ownership. Maybe we should switch to
+ // using a linked_ptr shared with the ResourceLoader (instead of
+ // ScopedDataPipeConsumerHandle). This might be enough to make so that we
+ // don't need a factory as described above.
+ // mojo::DataPipeConsumerHandle UNSAFEPTR_source_;
+ // const void* const buffer_;
+ const uint32_t num_bytes_;
+ scoped_ptr<char> real_contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoPipeReceivedData);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_MOJO_PIPI_RECEIVED_DATA_
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/child/mojo_pipe_received_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698