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

Unified Diff: content/child/mojo_pipe_received_data.cc

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/child/mojo_pipe_received_data.h ('k') | content/child/request_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/mojo_pipe_received_data.cc
diff --git a/content/child/mojo_pipe_received_data.cc b/content/child/mojo_pipe_received_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6db61d8275fe25c5ff77e6b0f63a2ff9a0a1fe09
--- /dev/null
+++ b/content/child/mojo_pipe_received_data.cc
@@ -0,0 +1,55 @@
+// 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.
+
+#include "content/child/mojo_pipe_received_data.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+// static
+scoped_ptr<RequestPeer::ReceivedData> MojoPipeReceivedData::Create(
+ mojo::DataPipeConsumerHandle source,
+ const void* buffer,
+ uint32_t num_bytes) {
+ return make_scoped_ptr(new MojoPipeReceivedData(source, buffer, num_bytes));
+}
+
+MojoPipeReceivedData::MojoPipeReceivedData(mojo::DataPipeConsumerHandle source,
+ const void* buffer,
+ uint32_t num_bytes)
+ : num_bytes_(num_bytes) {
+ real_contents_ = make_scoped_ptr(new char[num_bytes_]);
+ memcpy(real_contents_.get(), buffer, num_bytes_);
+ CHECK_EQ(EndReadDataRaw(source, num_bytes_), MOJO_RESULT_OK);
+}
+
+MojoPipeReceivedData::~MojoPipeReceivedData() {
+ // TODO(carlosk): in the final implementation EndReadDataRaw should be called
+ // here.
+ // TODO(carlosk): most probably needs stronger checks to decide if
+ // EndReadDataRaw should be called at all. Is the pointer still valid? Is the
+ // pipe still open? Etc...
+ // CHECK_EQ(EndReadDataRaw(UNSAFEPTR_source_, num_bytes_), MOJO_RESULT_OK);
+}
+
+const char* MojoPipeReceivedData::payload() const {
+ return real_contents_.get();
+}
+
+int MojoPipeReceivedData::length() const {
+ // TODO(carlosk): Must take care of integer range conversion from uint32_t to
+ // int.
+ return num_bytes_;
+}
+
+int MojoPipeReceivedData::encoded_length() const {
+ // TODO(carlosk): we have to figure out how to send the encoded_length
+ // information from the browser to here as it used to be send along with the
+ // shared memory buffer flow control messages. For now just returning the same
+ // value as length.
+ return num_bytes_;
+}
+
+} // namespace content
« no previous file with comments | « content/child/mojo_pipe_received_data.h ('k') | content/child/request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698