Chromium Code Reviews| 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 <vector> | |
| 8 | |
| 7 #include "blimp/net/blob_channel/blob_channel_sender.h" | 9 #include "blimp/net/blob_channel/blob_channel_sender.h" |
| 8 | 10 |
| 9 namespace blimp { | 11 namespace blimp { |
| 10 namespace engine { | 12 namespace engine { |
| 11 | 13 |
| 12 BlobChannelService::BlobChannelService(BlobChannelSender* blob_channel_sender, | 14 BlobChannelService::BlobChannelService(BlobChannelSender* blob_channel_sender, |
| 13 mojom::BlobChannelRequest request) | 15 mojom::BlobChannelRequest request) |
| 14 : binding_(this, std::move(request)), | 16 : binding_(this, std::move(request)), |
| 15 blob_channel_sender_(blob_channel_sender) { | 17 blob_channel_sender_(blob_channel_sender) { |
| 16 DCHECK(blob_channel_sender_); | 18 DCHECK(blob_channel_sender_); |
| 17 } | 19 } |
| 18 | 20 |
| 19 BlobChannelService::~BlobChannelService() {} | 21 BlobChannelService::~BlobChannelService() {} |
| 20 | 22 |
| 23 void BlobChannelService::GetCacheState( | |
| 24 const BlobChannelService::GetCacheStateCallback& callback) { | |
| 25 VLOG(1) << "BlobChannel::GetCacheState called."; | |
| 26 | |
| 27 // Get the cache state & marshal the contents to the Mojo response. | |
|
Wez
2016/06/21 00:33:33
"marshal the contents to ... response" sounds odd
Kevin M
2016/06/21 21:23:51
Done.
| |
| 28 std::vector<BlobChannelSender::CacheState> cache_state = | |
| 29 blob_channel_sender_->GetCacheState(); | |
| 30 auto output = mojo::Array<mojom::CacheStateEntryPtr>::New(cache_state.size()); | |
| 31 for (size_t i = 0; i < cache_state.size(); ++i) { | |
| 32 mojom::CacheStateEntryPtr converted(mojom::CacheStateEntry::New()); | |
| 33 converted->id = cache_state[i].id; | |
| 34 converted->is_replicated = cache_state[i].is_replicated; | |
| 35 output[i] = std::move(converted); | |
| 36 } | |
| 37 | |
| 38 callback.Run(std::move(output)); | |
| 39 } | |
| 40 | |
| 21 void BlobChannelService::PutBlob(const mojo::String& id, | 41 void BlobChannelService::PutBlob(const mojo::String& id, |
| 22 const mojo::String& data) { | 42 const mojo::String& data) { |
| 23 blob_channel_sender_->PutBlob(id, new BlobData(data)); | 43 blob_channel_sender_->PutBlob(id, new BlobData(data)); |
| 24 } | 44 } |
| 25 | 45 |
| 26 void BlobChannelService::DeliverBlob(const mojo::String& id) { | 46 void BlobChannelService::DeliverBlob(const mojo::String& id) { |
| 27 blob_channel_sender_->DeliverBlob(id); | 47 blob_channel_sender_->DeliverBlob(id); |
| 28 } | 48 } |
| 29 | 49 |
| 30 // static | 50 // static |
| 31 void BlobChannelService::Create( | 51 void BlobChannelService::Create( |
| 32 BlobChannelSender* blob_channel_sender, | 52 BlobChannelSender* blob_channel_sender, |
| 33 mojo::InterfaceRequest<mojom::BlobChannel> request) { | 53 mojo::InterfaceRequest<mojom::BlobChannel> request) { |
| 34 // Object lifetime is managed by BlobChannelService's StrongBinding | 54 // Object lifetime is managed by BlobChannelService's StrongBinding |
| 35 // |binding_|. | 55 // |binding_|. |
| 36 new BlobChannelService(blob_channel_sender, std::move(request)); | 56 new BlobChannelService(blob_channel_sender, std::move(request)); |
| 37 } | 57 } |
| 38 | 58 |
| 39 } // namespace engine | 59 } // namespace engine |
| 40 } // namespace blimp | 60 } // namespace blimp |
| OLD | NEW |