| 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 <string> | 7 #include <string> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 "Invalid data handle received from renderer process."); | 78 "Invalid data handle received from renderer process."); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (size > kMaxBlobSizeBytes) { | 82 if (size > kMaxBlobSizeBytes) { |
| 83 mojo::ReportBadMessage("Blob size too large."); | 83 mojo::ReportBadMessage("Blob size too large."); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 mojo::ScopedSharedBufferMapping mapping = data->Map(size); | 87 mojo::ScopedSharedBufferMapping mapping = data->Map(size); |
| 88 CHECK(mapping) << "Failed to mmap region of " << size << " bytes."; | 88 // Failed to mmap region of |size| bytes. |
| 89 CHECK(mapping); |
| 89 | 90 |
| 90 scoped_refptr<BlobData> new_blob(new BlobData); | 91 scoped_refptr<BlobData> new_blob(new BlobData); |
| 91 new_blob->data.assign(reinterpret_cast<const char*>(mapping.get()), size); | 92 new_blob->data.assign(reinterpret_cast<const char*>(mapping.get()), size); |
| 92 | 93 |
| 93 blob_sender_task_runner_->PostTask(FROM_HERE, | 94 blob_sender_task_runner_->PostTask(FROM_HERE, |
| 94 base::Bind(&BlobChannelSender::PutBlob, | 95 base::Bind(&BlobChannelSender::PutBlob, |
| 95 blob_channel_sender_, | 96 blob_channel_sender_, |
| 96 id, | 97 id, |
| 97 base::Passed(std::move(new_blob)))); | 98 base::Passed(std::move(new_blob)))); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void BlobChannelService::DeliverBlob(const std::string& id) { | 101 void BlobChannelService::DeliverBlob(const std::string& id) { |
| 101 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
| 102 | 103 |
| 103 blob_sender_task_runner_->PostTask(FROM_HERE, | 104 blob_sender_task_runner_->PostTask(FROM_HERE, |
| 104 base::Bind(&BlobChannelSender::DeliverBlob, | 105 base::Bind(&BlobChannelSender::DeliverBlob, |
| 105 blob_channel_sender_, | 106 blob_channel_sender_, |
| 106 id)); | 107 id)); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void BlobChannelService::BindRequest( | 110 void BlobChannelService::BindRequest( |
| 110 mojo::InterfaceRequest<mojom::BlobChannel> request) { | 111 mojo::InterfaceRequest<mojom::BlobChannel> request) { |
| 111 DCHECK(thread_checker_.CalledOnValidThread()); | 112 DCHECK(thread_checker_.CalledOnValidThread()); |
| 112 | 113 |
| 113 bindings_.AddBinding(this, std::move(request)); | 114 bindings_.AddBinding(this, std::move(request)); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace engine | 117 } // namespace engine |
| 117 } // namespace blimp | 118 } // namespace blimp |
| OLD | NEW |