OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "content/renderer/pepper/pepper_video_decoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 return PP_ERROR_FAILED; | 197 return PP_ERROR_FAILED; |
198 | 198 |
199 content::RenderThread* render_thread = content::RenderThread::Get(); | 199 content::RenderThread* render_thread = content::RenderThread::Get(); |
200 std::unique_ptr<base::SharedMemory> shm( | 200 std::unique_ptr<base::SharedMemory> shm( |
201 render_thread->HostAllocateSharedMemoryBuffer(shm_size)); | 201 render_thread->HostAllocateSharedMemoryBuffer(shm_size)); |
202 if (!shm || !shm->Map(shm_size)) | 202 if (!shm || !shm->Map(shm_size)) |
203 return PP_ERROR_FAILED; | 203 return PP_ERROR_FAILED; |
204 | 204 |
205 base::SharedMemoryHandle shm_handle = shm->handle(); | 205 base::SharedMemoryHandle shm_handle = shm->handle(); |
206 if (shm_id == shm_buffers_.size()) { | 206 if (shm_id == shm_buffers_.size()) { |
207 shm_buffers_.push_back(shm.release()); | 207 shm_buffers_.push_back(std::move(shm)); |
208 shm_buffer_busy_.push_back(false); | 208 shm_buffer_busy_.push_back(false); |
209 } else { | 209 } else { |
210 // Remove the old buffer. Delete manually since ScopedVector won't delete | 210 shm_buffers_[shm_id] = std::move(shm); |
211 // the existing element if we just assign over it. | |
Avi (use Gerrit)
2017/02/21 16:01:36
Holy cow, this comment is correct. I thought that
| |
212 delete shm_buffers_[shm_id]; | |
213 shm_buffers_[shm_id] = shm.release(); | |
214 } | 211 } |
215 | 212 |
216 SerializedHandle handle( | 213 SerializedHandle handle( |
217 renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote(shm_handle), | 214 renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote(shm_handle), |
218 shm_size); | 215 shm_size); |
219 ppapi::host::ReplyMessageContext reply_context = | 216 ppapi::host::ReplyMessageContext reply_context = |
220 context->MakeReplyMessageContext(); | 217 context->MakeReplyMessageContext(); |
221 reply_context.params.AppendHandle(handle); | 218 reply_context.params.AppendHandle(handle); |
222 host()->SendReply(reply_context, | 219 host()->SendReply(reply_context, |
223 PpapiPluginMsg_VideoDecoder_GetShmReply(shm_size)); | 220 PpapiPluginMsg_VideoDecoder_GetShmReply(shm_size)); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 | 556 |
560 PepperVideoDecoderHost::PendingDecodeList::iterator | 557 PepperVideoDecoderHost::PendingDecodeList::iterator |
561 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { | 558 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { |
562 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), | 559 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), |
563 [decode_id](const PendingDecode& item) { | 560 [decode_id](const PendingDecode& item) { |
564 return item.decode_id == decode_id; | 561 return item.decode_id == decode_id; |
565 }); | 562 }); |
566 } | 563 } |
567 | 564 |
568 } // namespace content | 565 } // namespace content |
OLD | NEW |