OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_buffer_impl.h" | 5 #include "webkit/plugins/ppapi/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 23 matching lines...) Expand all Loading... |
34 scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(instance)); | 34 scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(instance)); |
35 if (!buffer->Init(size)) | 35 if (!buffer->Init(size)) |
36 return 0; | 36 return 0; |
37 return buffer->GetReference(); | 37 return buffer->GetReference(); |
38 } | 38 } |
39 | 39 |
40 PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { | 40 PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { |
41 return this; | 41 return this; |
42 } | 42 } |
43 | 43 |
44 PPB_Buffer_API* PPB_Buffer_Impl::AsBuffer_API() { | 44 PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() { |
45 return this; | 45 return this; |
46 } | 46 } |
47 | 47 |
48 bool PPB_Buffer_Impl::Init(uint32_t size) { | 48 bool PPB_Buffer_Impl::Init(uint32_t size) { |
49 if (size == 0 || !instance()) | 49 if (size == 0 || !instance()) |
50 return false; | 50 return false; |
51 size_ = size; | 51 size_ = size; |
52 shared_memory_.reset( | 52 shared_memory_.reset( |
53 instance()->delegate()->CreateAnonymousSharedMemory(size)); | 53 instance()->delegate()->CreateAnonymousSharedMemory(size)); |
54 return shared_memory_.get() != NULL; | 54 return shared_memory_.get() != NULL; |
(...skipping 26 matching lines...) Expand all Loading... |
81 api->Describe(&size_); | 81 api->Describe(&size_); |
82 } | 82 } |
83 | 83 |
84 BufferAutoMapper::~BufferAutoMapper() { | 84 BufferAutoMapper::~BufferAutoMapper() { |
85 if (needs_unmap_) | 85 if (needs_unmap_) |
86 api_->Unmap(); | 86 api_->Unmap(); |
87 } | 87 } |
88 | 88 |
89 } // namespace ppapi | 89 } // namespace ppapi |
90 } // namespace webkit | 90 } // namespace webkit |
OLD | NEW |