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

Unified Diff: ipc/ipc_mojo_param_traits.cc

Issue 2813243002: network service: pass PlzNavigate resulting data via mojo data pipe (Closed)
Patch Set: . Created 3 years, 8 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
« content/child/web_url_loader_impl.cc ('K') | « ipc/ipc_mojo_param_traits.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_mojo_param_traits.cc
diff --git a/ipc/ipc_mojo_param_traits.cc b/ipc/ipc_mojo_param_traits.cc
index 189af3511d35260a17b0e18e9d191385931b539c..32e1b7c7da02445d229d07fbb53431f9324083b3 100644
--- a/ipc/ipc_mojo_param_traits.cc
+++ b/ipc/ipc_mojo_param_traits.cc
@@ -5,6 +5,7 @@
#include "ipc/ipc_mojo_param_traits.h"
#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_mojo_handle_attachment.h"
#include "ipc/ipc_mojo_message_helper.h"
namespace IPC {
@@ -47,4 +48,62 @@ void ParamTraits<mojo::MessagePipeHandle>::Log(const param_type& p,
l->append(")");
}
+void ParamTraits<mojo::DataPipeConsumerHandle>::GetSize(
+ base::PickleSizer* sizer,
+ const param_type& p) {
+ GetParamSize(sizer, p.is_valid());
+ if (p.is_valid())
+ sizer->AddAttachment();
+}
+
+void ParamTraits<mojo::DataPipeConsumerHandle>::Write(base::Pickle* m,
+ const param_type& p) {
+ WriteParam(m, p.is_valid());
+ if (!p.is_valid())
+ return;
+
+ m->WriteAttachment(new internal::MojoHandleAttachment(
+ mojo::ScopedHandle::From(mojo::ScopedDataPipeConsumerHandle(p))));
+}
+
+bool ParamTraits<mojo::DataPipeConsumerHandle>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ bool is_valid;
+ if (!ReadParam(m, iter, &is_valid))
+ return false;
+ if (!is_valid)
+ return true;
+
+ scoped_refptr<base::Pickle::Attachment> attachment;
+ if (!m->ReadAttachment(iter, &attachment)) {
+ LOG(ERROR) << "Failed to read attachment for message pipe.";
dcheng 2017/04/12 21:18:16 Nit: DLOG(ERROR) here and 87
scottmg 2017/04/12 21:28:51 Done.
+ return false;
+ }
+
+ MessageAttachment::Type type =
+ static_cast<MessageAttachment*>(attachment.get())->GetType();
+ if (type != MessageAttachment::Type::MOJO_HANDLE) {
+ LOG(ERROR) << "Unxpected attachment type:" << type;
+ return false;
+ }
+
+ mojo::ScopedDataPipeConsumerHandle handle;
+ handle.reset(mojo::DataPipeConsumerHandle(
+ static_cast<internal::MojoHandleAttachment*>(attachment.get())
+ ->TakeHandle()
+ .release()
+ .value()));
+ DCHECK(handle.is_valid());
+ *r = handle.release();
+ return true;
+}
+
+void ParamTraits<mojo::DataPipeConsumerHandle>::Log(const param_type& p,
+ std::string* l) {
+ l->append("mojo::DataPipeConsumerHandle(");
+ LogParam(p.value(), l);
+ l->append(")");
+}
+
} // namespace IPC
« content/child/web_url_loader_impl.cc ('K') | « ipc/ipc_mojo_param_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698