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

Side by Side Diff: media/capture/video/video_capture_buffer_pool_impl.cc

Issue 2410383002: VideoCapture: more migration IPC-->mojo, part 6 (Closed)
Patch Set: Comment correction Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "media/capture/video/video_capture_buffer_pool_impl.h" 5 #include "media/capture/video/video_capture_buffer_pool_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 12 matching lines...) Expand all
23 next_buffer_id_(0), 23 next_buffer_id_(0),
24 last_relinquished_buffer_id_(kInvalidId), 24 last_relinquished_buffer_id_(kInvalidId),
25 buffer_tracker_factory_(std::move(buffer_tracker_factory)) { 25 buffer_tracker_factory_(std::move(buffer_tracker_factory)) {
26 DCHECK_GT(count, 0); 26 DCHECK_GT(count, 0);
27 } 27 }
28 28
29 VideoCaptureBufferPoolImpl::~VideoCaptureBufferPoolImpl() { 29 VideoCaptureBufferPoolImpl::~VideoCaptureBufferPoolImpl() {
30 base::STLDeleteValues(&trackers_); 30 base::STLDeleteValues(&trackers_);
31 } 31 }
32 32
33 bool VideoCaptureBufferPoolImpl::ShareToProcess( 33 mojo::ScopedSharedBufferHandle VideoCaptureBufferPoolImpl::GetHandleForTransit(
34 int buffer_id, 34 int buffer_id) {
35 base::ProcessHandle process_handle,
36 base::SharedMemoryHandle* new_handle) {
37 base::AutoLock lock(lock_); 35 base::AutoLock lock(lock_);
38 36
39 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); 37 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id);
40 if (!tracker) { 38 if (!tracker) {
41 NOTREACHED() << "Invalid buffer_id."; 39 NOTREACHED() << "Invalid buffer_id.";
42 return false; 40 return mojo::ScopedSharedBufferHandle();
43 } 41 }
44 if (tracker->ShareToProcess(process_handle, new_handle)) 42 return tracker->GetHandleForTransit();
45 return true;
46 DPLOG(ERROR) << "Error mapping memory";
47 return false;
48 } 43 }
49 44
50 std::unique_ptr<VideoCaptureBufferHandle> 45 std::unique_ptr<VideoCaptureBufferHandle>
51 VideoCaptureBufferPoolImpl::GetBufferHandle(int buffer_id) { 46 VideoCaptureBufferPoolImpl::GetBufferHandle(int buffer_id) {
52 base::AutoLock lock(lock_); 47 base::AutoLock lock(lock_);
53 48
54 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); 49 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id);
55 if (!tracker) { 50 if (!tracker) {
56 NOTREACHED() << "Invalid buffer_id."; 51 NOTREACHED() << "Invalid buffer_id.";
57 return std::unique_ptr<VideoCaptureBufferHandle>(); 52 return std::unique_ptr<VideoCaptureBufferHandle>();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return buffer_id; 229 return buffer_id;
235 } 230 }
236 231
237 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker( 232 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker(
238 int buffer_id) { 233 int buffer_id) {
239 TrackerMap::const_iterator it = trackers_.find(buffer_id); 234 TrackerMap::const_iterator it = trackers_.find(buffer_id);
240 return (it == trackers_.end()) ? NULL : it->second; 235 return (it == trackers_.end()) ? NULL : it->second;
241 } 236 }
242 237
243 } // namespace media 238 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698