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

Side by Side Diff: content/browser/renderer_host/media/shared_memory_buffer_tracker.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 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 "content/browser/renderer_host/media/shared_memory_buffer_tracker.h" 5 #include "content/browser/renderer_host/media/shared_memory_buffer_tracker.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/browser/renderer_host/media/shared_memory_buffer_handle.h" 8 #include "content/browser/renderer_host/media/shared_memory_buffer_handle.h"
9 #include "mojo/public/cpp/system/platform_handle.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 SharedMemoryBufferTracker::SharedMemoryBufferTracker() 13 SharedMemoryBufferTracker::SharedMemoryBufferTracker()
13 : VideoCaptureBufferTracker() {} 14 : VideoCaptureBufferTracker() {}
14 15
15 bool SharedMemoryBufferTracker::Init(const gfx::Size& dimensions, 16 bool SharedMemoryBufferTracker::Init(const gfx::Size& dimensions,
16 media::VideoPixelFormat format, 17 media::VideoPixelFormat format,
17 media::VideoPixelStorage storage_type, 18 media::VideoPixelStorage storage_type,
18 base::Lock* lock) { 19 base::Lock* lock) {
19 DVLOG(2) << "allocating ShMem of " << dimensions.ToString(); 20 DVLOG(2) << __func__ << "allocating ShMem of " << dimensions.ToString();
20 set_dimensions(dimensions); 21 set_dimensions(dimensions);
21 // |dimensions| can be 0x0 for trackers that do not require memory backing. 22 // |dimensions| can be 0x0 for trackers that do not require memory backing.
22 set_max_pixel_count(dimensions.GetArea()); 23 set_max_pixel_count(dimensions.GetArea());
23 set_pixel_format(format); 24 set_pixel_format(format);
24 set_storage_type(storage_type); 25 set_storage_type(storage_type);
25 mapped_size_ = 26 mapped_size_ =
26 media::VideoCaptureFormat(dimensions, 0.0f, format, storage_type) 27 media::VideoCaptureFormat(dimensions, 0.0f, format, storage_type)
27 .ImageAllocationSize(); 28 .ImageAllocationSize();
28 if (!mapped_size_) 29 if (!mapped_size_)
29 return true; 30 return true;
30 return shared_memory_.CreateAndMapAnonymous(mapped_size_); 31 return shared_memory_.CreateAndMapAnonymous(mapped_size_);
31 } 32 }
32 33
33 std::unique_ptr<media::VideoCaptureBufferHandle> 34 std::unique_ptr<media::VideoCaptureBufferHandle>
34 SharedMemoryBufferTracker::GetBufferHandle() { 35 SharedMemoryBufferTracker::GetBufferHandle() {
35 return base::MakeUnique<SharedMemoryBufferHandle>(this); 36 return base::MakeUnique<SharedMemoryBufferHandle>(this);
36 } 37 }
37 38
38 bool SharedMemoryBufferTracker::ShareToProcess( 39 mojo::ScopedSharedBufferHandle
39 base::ProcessHandle process_handle, 40 SharedMemoryBufferTracker::GetHandleForTransit() {
40 base::SharedMemoryHandle* new_handle) { 41 return mojo::WrapSharedMemoryHandle(
41 return shared_memory_.ShareToProcess(process_handle, new_handle); 42 base::SharedMemory::DuplicateHandle(shared_memory_.handle()),
43 mapped_size_, false /* read_only */);
42 } 44 }
43 45
44 } // namespace content 46 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698