OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "blimp/engine/mojo/blob_channel_service.h" | 5 #include "blimp/engine/mojo/blob_channel_service.h" |
6 | 6 |
7 #include "blimp/net/blob_channel/blob_channel_sender.h" | 7 #include "blimp/net/blob_channel/blob_channel_sender.h" |
8 #include "mojo/public/cpp/system/buffer.h" | |
8 | 9 |
9 namespace blimp { | 10 namespace blimp { |
10 namespace engine { | 11 namespace engine { |
11 | 12 |
12 BlobChannelService::BlobChannelService(BlobChannelSender* blob_channel_sender, | 13 BlobChannelService::BlobChannelService(BlobChannelSender* blob_channel_sender, |
13 mojom::BlobChannelRequest request) | 14 mojom::BlobChannelRequest request) |
14 : binding_(this, std::move(request)), | 15 : binding_(this, std::move(request)), |
15 blob_channel_sender_(blob_channel_sender) { | 16 blob_channel_sender_(blob_channel_sender) { |
16 DCHECK(blob_channel_sender_); | 17 DCHECK(blob_channel_sender_); |
17 } | 18 } |
18 | 19 |
19 BlobChannelService::~BlobChannelService() {} | 20 BlobChannelService::~BlobChannelService() {} |
20 | 21 |
21 void BlobChannelService::PutBlob(const mojo::String& id, | 22 void BlobChannelService::PutBlob(const mojo::String& id, |
22 const mojo::String& data) { | 23 mojo::ScopedSharedBufferHandle data, |
23 blob_channel_sender_->PutBlob(id, new BlobData(data)); | 24 uint32_t size) { |
25 // Map |data| into the address space and copy out its contents. | |
26 DCHECK(data.is_valid()); | |
dcheng
2016/06/25 01:06:31
The comments imply this is coming from the rendere
Kevin M
2016/06/27 17:31:12
Done.
| |
27 scoped_refptr<BlobData> new_blob(new BlobData); | |
28 auto mapping = data->Map(size); | |
29 new_blob->data.assign(reinterpret_cast<const char*>(mapping.get()), size); | |
30 blob_channel_sender_->PutBlob(id, std::move(new_blob)); | |
24 } | 31 } |
25 | 32 |
26 void BlobChannelService::DeliverBlob(const mojo::String& id) { | 33 void BlobChannelService::DeliverBlob(const mojo::String& id) { |
27 blob_channel_sender_->DeliverBlob(id); | 34 blob_channel_sender_->DeliverBlob(id); |
28 } | 35 } |
29 | 36 |
30 // static | 37 // static |
31 void BlobChannelService::Create( | 38 void BlobChannelService::Create( |
32 BlobChannelSender* blob_channel_sender, | 39 BlobChannelSender* blob_channel_sender, |
33 mojo::InterfaceRequest<mojom::BlobChannel> request) { | 40 mojo::InterfaceRequest<mojom::BlobChannel> request) { |
34 // Object lifetime is managed by BlobChannelService's StrongBinding | 41 // Object lifetime is managed by BlobChannelService's StrongBinding |
35 // |binding_|. | 42 // |binding_|. |
36 new BlobChannelService(blob_channel_sender, std::move(request)); | 43 new BlobChannelService(blob_channel_sender, std::move(request)); |
37 } | 44 } |
38 | 45 |
39 } // namespace engine | 46 } // namespace engine |
40 } // namespace blimp | 47 } // namespace blimp |
OLD | NEW |