OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/ppb_buffer_impl.h" | 5 #include "content/renderer/pepper/ppb_buffer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 if (map_count_++ == 0) | 71 if (map_count_++ == 0) |
72 shared_memory_->Map(size_); | 72 shared_memory_->Map(size_); |
73 return shared_memory_->memory(); | 73 return shared_memory_->memory(); |
74 } | 74 } |
75 | 75 |
76 void PPB_Buffer_Impl::Unmap() { | 76 void PPB_Buffer_Impl::Unmap() { |
77 if (--map_count_ == 0) | 77 if (--map_count_ == 0) |
78 shared_memory_->Unmap(); | 78 shared_memory_->Unmap(); |
79 } | 79 } |
80 | 80 |
81 int32_t PPB_Buffer_Impl::GetSharedMemory(int* shm_handle) { | 81 int32_t PPB_Buffer_Impl::GetSharedMemory(base::SharedMemory* shm) { |
82 *shm_handle = reinterpret_cast<int>(PlatformFileFromSharedMemoryHandle( | 82 shm = shared_memory_.get(); |
piman
2015/06/02 00:00:15
Same here
erikchen
2015/06/02 00:28:37
Fixed.
| |
83 shared_memory_->handle())); | |
84 return PP_OK; | 83 return PP_OK; |
85 } | 84 } |
86 | 85 |
87 BufferAutoMapper::BufferAutoMapper(PPB_Buffer_API* api) : api_(api) { | 86 BufferAutoMapper::BufferAutoMapper(PPB_Buffer_API* api) : api_(api) { |
88 needs_unmap_ = !PP_ToBool(api->IsMapped()); | 87 needs_unmap_ = !PP_ToBool(api->IsMapped()); |
89 data_ = api->Map(); | 88 data_ = api->Map(); |
90 api->Describe(&size_); | 89 api->Describe(&size_); |
91 } | 90 } |
92 | 91 |
93 BufferAutoMapper::~BufferAutoMapper() { | 92 BufferAutoMapper::~BufferAutoMapper() { |
94 if (needs_unmap_) | 93 if (needs_unmap_) |
95 api_->Unmap(); | 94 api_->Unmap(); |
96 } | 95 } |
97 | 96 |
98 } // namespace content | 97 } // namespace content |
OLD | NEW |