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

Unified Diff: content/common/content_param_traits.cc

Issue 2892953006: WIP POC blob transport over mojo
Patch Set: pass mojo blobs over ipc Created 3 years, 7 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/common/content_param_traits.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/content_param_traits.cc
diff --git a/content/common/content_param_traits.cc b/content/common/content_param_traits.cc
index 514473020a17eed4f9447e0eabc6c718e35567ce..3586c6c06fe58fea8ca0ad7d0462d6a6e43cdb2a 100644
--- a/content/common/content_param_traits.cc
+++ b/content/common/content_param_traits.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_number_conversions.h"
#include "content/common/accessibility_mode.h"
#include "content/common/message_port.h"
+#include "ipc/ipc_mojo_message_helper.h"
#include "ipc/ipc_mojo_param_traits.h"
#include "net/base/ip_endpoint.h"
#include "ui/events/blink/web_input_event_traits.h"
@@ -112,6 +113,52 @@ bool ParamTraits<content::AccessibilityMode>::Read(const base::Pickle* m,
void ParamTraits<content::AccessibilityMode>::Log(const param_type& p,
std::string* l) {}
+
+void ParamTraits<storage::mojom::BlobPtr>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.is_bound());
+ if (p.is_bound()) {
+ s->AddUInt32();
+ s->AddAttachment();
+ }
+}
+
+void ParamTraits<storage::mojom::BlobPtr>::Write(base::Pickle* m,
+ const param_type& p) {
+ WriteParam(m, p.is_bound());
+ if (p.is_bound()) {
+ storage::mojom::BlobPtr clone;
+ p->Clone(MakeRequest(&clone));
+ auto info = clone.PassInterface();
+ m->WriteUInt32(info.version());
+ MojoMessageHelper::WriteMessagePipeTo(m, info.PassHandle());
+ }
+}
+
+bool ParamTraits<storage::mojom::BlobPtr>::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;
+
+ uint32_t version;
+ if (!ReadParam(m, iter, &version))
+ return false;
+ mojo::ScopedMessagePipeHandle handle;
+ if (!MojoMessageHelper::ReadMessagePipeFrom(m, iter, &handle))
+ return false;
+ DCHECK(handle.is_valid());
+ r->Bind(
+ mojo::InterfacePtrInfo<storage::mojom::Blob>(std::move(handle), version));
+ return true;
+}
+
+void ParamTraits<storage::mojom::BlobPtr>::Log(const param_type& p,
+ std::string* l) {}
+
} // namespace IPC
// Generate param traits size methods.
« no previous file with comments | « content/common/content_param_traits.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698