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

Side by Side Diff: content/browser/renderer_host/media/video_capture_buffer_pool.cc

Issue 1197853004: Revert of Revert of Make SharedMemoryHandle a class on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Created 5 years, 6 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 | « base/memory/shared_memory_win.cc ('k') | ipc/ipc_message_utils.h » ('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 (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 "content/browser/renderer_host/media/video_capture_buffer_pool.h" 5 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 public: 63 public:
64 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle) 64 SimpleBufferHandle(void* data, size_t size, base::SharedMemoryHandle handle)
65 : data_(data), size_(size), handle_(handle) {} 65 : data_(data), size_(size), handle_(handle) {}
66 ~SimpleBufferHandle() override {} 66 ~SimpleBufferHandle() override {}
67 67
68 size_t size() const override { return size_; } 68 size_t size() const override { return size_; }
69 void* data() override { return data_; } 69 void* data() override { return data_; }
70 ClientBuffer AsClientBuffer() override { return nullptr; } 70 ClientBuffer AsClientBuffer() override { return nullptr; }
71 #if defined(OS_POSIX) 71 #if defined(OS_POSIX)
72 base::FileDescriptor AsPlatformFile() override { 72 base::FileDescriptor AsPlatformFile() override {
73 #if defined(OS_MACOSX)
74 return handle_.GetFileDescriptor();
75 #else
73 return handle_; 76 return handle_;
77 #endif // defined(OS_MACOSX)
74 } 78 }
75 #endif 79 #endif
76 80
77 private: 81 private:
78 void* const data_; 82 void* const data_;
79 const size_t size_; 83 const size_t size_;
80 const base::SharedMemoryHandle handle_; 84 const base::SharedMemoryHandle handle_;
81 }; 85 };
82 86
83 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on 87 // A holder of a GpuMemoryBuffer-backed buffer, Map()ed on ctor and Unmap()ed on
(...skipping 11 matching lines...) Expand all
95 DCHECK(gmb && !gmb_->IsMapped()); 99 DCHECK(gmb && !gmb_->IsMapped());
96 gmb_->Map(data_.get()); 100 gmb_->Map(data_.get());
97 } 101 }
98 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); } 102 ~GpuMemoryBufferBufferHandle() override { gmb_->Unmap(); }
99 103
100 size_t size() const override { return size_; } 104 size_t size() const override { return size_; }
101 void* data() override { return data_[0]; } 105 void* data() override { return data_[0]; }
102 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); } 106 ClientBuffer AsClientBuffer() override { return gmb_->AsClientBuffer(); }
103 #if defined(OS_POSIX) 107 #if defined(OS_POSIX)
104 base::FileDescriptor AsPlatformFile() override { 108 base::FileDescriptor AsPlatformFile() override {
109 #if defined(OS_MACOSX)
110 return gmb_->GetHandle().handle.GetFileDescriptor();
111 #else
105 return gmb_->GetHandle().handle; 112 return gmb_->GetHandle().handle;
113 #endif // defined(OS_MACOSX)
106 } 114 }
107 #endif 115 #endif
108 116
109 private: 117 private:
110 gfx::GpuMemoryBuffer* const gmb_; 118 gfx::GpuMemoryBuffer* const gmb_;
111 scoped_ptr<void*[]> data_; 119 scoped_ptr<void*[]> data_;
112 const size_t size_; 120 const size_t size_;
113 }; 121 };
114 122
115 // Tracker specifics for SharedMemory. 123 // Tracker specifics for SharedMemory.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return buffer_id; 405 return buffer_id;
398 } 406 }
399 407
400 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker( 408 VideoCaptureBufferPool::Tracker* VideoCaptureBufferPool::GetTracker(
401 int buffer_id) { 409 int buffer_id) {
402 TrackerMap::const_iterator it = trackers_.find(buffer_id); 410 TrackerMap::const_iterator it = trackers_.find(buffer_id);
403 return (it == trackers_.end()) ? NULL : it->second; 411 return (it == trackers_.end()) ? NULL : it->second;
404 } 412 }
405 413
406 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « base/memory/shared_memory_win.cc ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698