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

Unified Diff: blimp/engine/mojo/blob_channel_service.cc

Issue 2033013003: Use shared memory for moving data over BlobChannel Mojo interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-master
Patch Set: dcheng feedback Created 4 years, 6 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
Index: blimp/engine/mojo/blob_channel_service.cc
diff --git a/blimp/engine/mojo/blob_channel_service.cc b/blimp/engine/mojo/blob_channel_service.cc
index 0234df60698b3a2c2628537b7e66cfd9ae44bfd9..25a7ee3cdd7d1d0cafa067bd1adefc02122b5817 100644
--- a/blimp/engine/mojo/blob_channel_service.cc
+++ b/blimp/engine/mojo/blob_channel_service.cc
@@ -5,6 +5,7 @@
#include "blimp/engine/mojo/blob_channel_service.h"
#include "blimp/net/blob_channel/blob_channel_sender.h"
+#include "mojo/public/cpp/system/buffer.h"
namespace blimp {
namespace engine {
@@ -19,8 +20,18 @@ BlobChannelService::BlobChannelService(BlobChannelSender* blob_channel_sender,
BlobChannelService::~BlobChannelService() {}
void BlobChannelService::PutBlob(const mojo::String& id,
- const mojo::String& data) {
- blob_channel_sender_->PutBlob(id, new BlobData(data));
+ mojo::ScopedSharedBufferHandle data,
+ uint32_t size) {
+ // Map |data| into the address space and copy out its contents.
+ if (!data.is_valid()) {
+ LOG(ERROR) << "Invalid data handle received from renderer process.";
+ return;
+ }
+
+ scoped_refptr<BlobData> new_blob(new BlobData);
+ auto mapping = data->Map(size);
+ new_blob->data.assign(reinterpret_cast<const char*>(mapping.get()), size);
+ blob_channel_sender_->PutBlob(id, std::move(new_blob));
}
void BlobChannelService::DeliverBlob(const mojo::String& id) {

Powered by Google App Engine
This is Rietveld 408576698