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..8a0246c9df859100a36a2e174e375ee09b97c61d 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,23 @@ 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."; |
Wez
2016/07/01 01:06:56
Not for this CL: We should work out how in general
Kevin M
2016/07/18 16:35:16
Filed crbug.com/629096
|
+ return; |
+ } |
+ |
+ if (size > kMaxBlobSizeBytes) { |
+ LOG(ERROR) << "Blob size too big: " << size; |
+ return; |
+ } |
+ |
+ scoped_refptr<BlobData> new_blob(new BlobData); |
+ auto mapping = data->Map(size); |
Wez
2016/07/01 01:06:56
nit: Don't use auto here, since it's not obvious t
dcheng
2016/07/01 02:04:28
I missed this, but we need to check that the Map()
Kevin M
2016/07/18 16:35:16
Done.
Kevin M
2016/07/18 16:35:16
Done.
|
+ 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) { |