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

Unified Diff: ipc/ipc_mojo_param_traits.cc

Issue 2813243002: network service: pass PlzNavigate resulting data via mojo data pipe (Closed)
Patch Set: ahem 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
« no previous file with comments | « 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..12aaacee10631a1141f4b25a9484b1bd0496b9c2 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)) {
+ DLOG(ERROR) << "Failed to read attachment for message pipe.";
+ return false;
+ }
+
+ MessageAttachment::Type type =
+ static_cast<MessageAttachment*>(attachment.get())->GetType();
+ if (type != MessageAttachment::Type::MOJO_HANDLE) {
+ DLOG(ERROR) << "Unexpected 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
« no previous file with comments | « ipc/ipc_mojo_param_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698