Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: ppapi/proxy/video_encoder_resource.cc

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/proxy/video_encoder_resource.h ('k') | ppapi/proxy/video_encoder_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ppapi/proxy/video_encoder_resource.h" 5 #include "ppapi/proxy/video_encoder_resource.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
10 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
11 #include "ppapi/c/pp_array_output.h" 12 #include "ppapi/c/pp_array_output.h"
12 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
13 #include "ppapi/proxy/video_frame_resource.h" 14 #include "ppapi/proxy/video_frame_resource.h"
14 #include "ppapi/shared_impl/array_writer.h" 15 #include "ppapi/shared_impl/array_writer.h"
15 #include "ppapi/shared_impl/media_stream_buffer.h" 16 #include "ppapi/shared_impl/media_stream_buffer.h"
16 #include "ppapi/shared_impl/media_stream_buffer_manager.h" 17 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
17 #include "ppapi/thunk/enter.h" 18 #include "ppapi/thunk/enter.h"
18 19
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 : PP_HARDWAREACCELERATION_NONE; 52 : PP_HARDWAREACCELERATION_NONE;
52 53
53 profiles_0_1.push_back(profile_0_1); 54 profiles_0_1.push_back(profile_0_1);
54 } 55 }
55 56
56 return profiles_0_1; 57 return profiles_0_1;
57 } 58 }
58 59
59 } // namespace 60 } // namespace
60 61
61 VideoEncoderResource::ShmBuffer::ShmBuffer(uint32_t id, 62 VideoEncoderResource::ShmBuffer::ShmBuffer(
62 scoped_ptr<base::SharedMemory> shm) 63 uint32_t id,
64 std::unique_ptr<base::SharedMemory> shm)
63 : id(id), shm(std::move(shm)) {} 65 : id(id), shm(std::move(shm)) {}
64 66
65 VideoEncoderResource::ShmBuffer::~ShmBuffer() { 67 VideoEncoderResource::ShmBuffer::~ShmBuffer() {
66 } 68 }
67 69
68 VideoEncoderResource::BitstreamBuffer::BitstreamBuffer(uint32_t id, 70 VideoEncoderResource::BitstreamBuffer::BitstreamBuffer(uint32_t id,
69 uint32_t size, 71 uint32_t size,
70 bool key_frame) 72 bool key_frame)
71 : id(id), size(size), key_frame(key_frame) { 73 : id(id), size(size), key_frame(key_frame) {
72 } 74 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (error) { 344 if (error) {
343 NotifyError(error); 345 NotifyError(error);
344 return; 346 return;
345 } 347 }
346 348
347 base::SharedMemoryHandle buffer_handle; 349 base::SharedMemoryHandle buffer_handle;
348 params.TakeSharedMemoryHandleAtIndex(0, &buffer_handle); 350 params.TakeSharedMemoryHandleAtIndex(0, &buffer_handle);
349 351
350 if (!buffer_manager_.SetBuffers( 352 if (!buffer_manager_.SetBuffers(
351 frame_count, frame_length, 353 frame_count, frame_length,
352 make_scoped_ptr(new base::SharedMemory(buffer_handle, false)), 354 base::WrapUnique(new base::SharedMemory(buffer_handle, false)),
353 true)) { 355 true)) {
354 NotifyError(PP_ERROR_FAILED); 356 NotifyError(PP_ERROR_FAILED);
355 return; 357 return;
356 } 358 }
357 359
358 if (TrackedCallback::IsPending(get_video_frame_callback_)) 360 if (TrackedCallback::IsPending(get_video_frame_callback_))
359 TryWriteVideoFrame(); 361 TryWriteVideoFrame();
360 } 362 }
361 363
362 void VideoEncoderResource::OnPluginMsgEncodeReply( 364 void VideoEncoderResource::OnPluginMsgEncodeReply(
(...skipping 26 matching lines...) Expand all
389 const ResourceMessageReplyParams& params, 391 const ResourceMessageReplyParams& params,
390 uint32_t buffer_length) { 392 uint32_t buffer_length) {
391 std::vector<base::SharedMemoryHandle> shm_handles; 393 std::vector<base::SharedMemoryHandle> shm_handles;
392 params.TakeAllSharedMemoryHandles(&shm_handles); 394 params.TakeAllSharedMemoryHandles(&shm_handles);
393 if (shm_handles.size() == 0) { 395 if (shm_handles.size() == 0) {
394 NotifyError(PP_ERROR_FAILED); 396 NotifyError(PP_ERROR_FAILED);
395 return; 397 return;
396 } 398 }
397 399
398 for (uint32_t i = 0; i < shm_handles.size(); ++i) { 400 for (uint32_t i = 0; i < shm_handles.size(); ++i) {
399 scoped_ptr<base::SharedMemory> shm( 401 std::unique_ptr<base::SharedMemory> shm(
400 new base::SharedMemory(shm_handles[i], true)); 402 new base::SharedMemory(shm_handles[i], true));
401 CHECK(shm->Map(buffer_length)); 403 CHECK(shm->Map(buffer_length));
402 404
403 ShmBuffer* buffer = new ShmBuffer(i, std::move(shm)); 405 ShmBuffer* buffer = new ShmBuffer(i, std::move(shm));
404 shm_buffers_.push_back(buffer); 406 shm_buffers_.push_back(buffer);
405 bitstream_buffer_map_.insert( 407 bitstream_buffer_map_.insert(
406 std::make_pair(buffer->shm->memory(), buffer->id)); 408 std::make_pair(buffer->shm->memory(), buffer->id));
407 } 409 }
408 } 410 }
409 411
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 for (VideoFrameMap::iterator it = video_frames_.begin(); 477 for (VideoFrameMap::iterator it = video_frames_.begin();
476 it != video_frames_.end(); ++it) { 478 it != video_frames_.end(); ++it) {
477 it->second->Invalidate(); 479 it->second->Invalidate();
478 it->second = nullptr; 480 it->second = nullptr;
479 } 481 }
480 video_frames_.clear(); 482 video_frames_.clear();
481 } 483 }
482 484
483 } // namespace proxy 485 } // namespace proxy
484 } // namespace ppapi 486 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/video_encoder_resource.h ('k') | ppapi/proxy/video_encoder_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698