| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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_media_stream_track_host_base.h" | 5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // that width != stride in an image buffer. | 45 // that width != stride in an image buffer. |
| 46 buffer_size_aligned += (4 - buffer_size % 4); | 46 buffer_size_aligned += (4 - buffer_size % 4); |
| 47 | 47 |
| 48 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should | 48 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should |
| 49 // avoid it. | 49 // avoid it. |
| 50 base::CheckedNumeric<int32_t> size = number_of_buffers * buffer_size_aligned; | 50 base::CheckedNumeric<int32_t> size = number_of_buffers * buffer_size_aligned; |
| 51 if (!size.IsValid()) | 51 if (!size.IsValid()) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 content::RenderThread* render_thread = content::RenderThread::Get(); | 54 content::RenderThread* render_thread = content::RenderThread::Get(); |
| 55 scoped_ptr<base::SharedMemory> shm( | 55 std::unique_ptr<base::SharedMemory> shm( |
| 56 render_thread->HostAllocateSharedMemoryBuffer(size.ValueOrDie())); | 56 render_thread->HostAllocateSharedMemoryBuffer(size.ValueOrDie())); |
| 57 if (!shm) | 57 if (!shm) |
| 58 return false; | 58 return false; |
| 59 | 59 |
| 60 base::SharedMemoryHandle shm_handle = shm->handle(); | 60 base::SharedMemoryHandle shm_handle = shm->handle(); |
| 61 if (!buffer_manager_.SetBuffers(number_of_buffers, | 61 if (!buffer_manager_.SetBuffers(number_of_buffers, |
| 62 buffer_size_aligned.ValueOrDie(), | 62 buffer_size_aligned.ValueOrDie(), |
| 63 std::move(shm), true)) { | 63 std::move(shm), true)) { |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return PP_OK; | 111 return PP_OK; |
| 112 } | 112 } |
| 113 | 113 |
| 114 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose( | 114 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose( |
| 115 HostMessageContext* context) { | 115 HostMessageContext* context) { |
| 116 OnClose(); | 116 OnClose(); |
| 117 return PP_OK; | 117 return PP_OK; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace content | 120 } // namespace content |
| OLD | NEW |