Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/modules/desktop_capture/shared_memory.h" | 11 #include "webrtc/modules/desktop_capture/shared_memory.h" |
| 12 | 12 |
| 13 #include <utility> | |
| 14 | |
| 15 #include "webrtc/base/checks.h" | |
| 16 | |
| 13 namespace webrtc { | 17 namespace webrtc { |
| 14 | 18 |
| 15 #if defined(WEBRTC_WIN) | 19 #if defined(WEBRTC_WIN) |
| 16 const SharedMemory::Handle SharedMemory::kInvalidHandle = NULL; | 20 const SharedMemory::Handle SharedMemory::kInvalidHandle = NULL; |
| 17 #else | 21 #else |
| 18 const SharedMemory::Handle SharedMemory::kInvalidHandle = -1; | 22 const SharedMemory::Handle SharedMemory::kInvalidHandle = -1; |
| 19 #endif | 23 #endif |
| 20 | 24 |
| 21 SharedMemory::SharedMemory(void* data, size_t size, Handle handle, int id) | 25 SharedMemory::SharedMemory(void* data, size_t size, Handle handle, int id) |
| 22 : data_(data), | 26 : data_(data), |
| 23 size_(size), | 27 size_(size), |
| 24 handle_(handle), | 28 handle_(handle), |
| 25 id_(id) { | 29 id_(id) { |
| 26 } | 30 } |
| 27 | 31 |
| 32 SharedMemoryFactoryWrapper::SharedMemoryFactoryWrapper( | |
| 33 std::unique_ptr<SharedMemoryFactory> factory) { | |
| 34 RTC_DCHECK(factory); | |
| 35 owned_factory_ = std::move(factory); | |
| 36 shared_factory_ = owned_factory_.get(); | |
| 37 } | |
| 38 | |
| 39 SharedMemoryFactoryWrapper::SharedMemoryFactoryWrapper( | |
| 40 SharedMemoryFactory* factory) { | |
| 41 RTC_DCHECK(factory); | |
| 42 shared_factory_ = factory; | |
| 43 } | |
| 44 | |
| 45 SharedMemoryFactoryWrapper::~SharedMemoryFactoryWrapper() = default; | |
| 46 | |
| 47 std::unique_ptr<SharedMemoryFactory> SharedMemoryFactoryWrapper::Wrap() const { | |
| 48 return std::unique_ptr<SharedMemoryFactory>(new SharedMemoryFactoryWrapper( | |
|
Sergey Ulanov
2017/02/15 23:08:43
A better solution would be use a ref-counted holde
Hzj_jie
2017/02/16 01:57:07
I have added comments for both SharedMemoryFactory
| |
| 49 owned_factory_.get())); | |
| 50 } | |
| 51 | |
| 52 std::unique_ptr<SharedMemory> SharedMemoryFactoryWrapper::CreateSharedMemory( | |
| 53 size_t size) { | |
| 54 return shared_factory_->CreateSharedMemory(size); | |
| 55 } | |
| 56 | |
| 28 } // namespace webrtc | 57 } // namespace webrtc |
| OLD | NEW |