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 "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" |
11 #include "ppapi/c/dev/ppb_buffer_dev.h" | 11 #include "ppapi/c/dev/ppb_buffer_dev.h" |
12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "webkit/plugins/ppapi/common.h" | 14 #include "webkit/plugins/ppapi/common.h" |
15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
16 #include "webkit/plugins/ppapi/resource_helper.h" | 16 #include "webkit/plugins/ppapi/resource_helper.h" |
17 | 17 |
18 using ::ppapi::thunk::PPB_Buffer_API; | 18 using ::ppapi::thunk::PPB_Buffer_API; |
19 using ::ppapi::thunk::PPB_BufferTrusted_API; | |
20 | 19 |
21 namespace webkit { | 20 namespace webkit { |
22 namespace ppapi { | 21 namespace ppapi { |
23 | 22 |
24 PPB_Buffer_Impl::PPB_Buffer_Impl(PP_Instance instance) | 23 PPB_Buffer_Impl::PPB_Buffer_Impl(PP_Instance instance) |
25 : Resource(::ppapi::OBJECT_IS_IMPL, instance), | 24 : Resource(::ppapi::OBJECT_IS_IMPL, instance), |
26 size_(0), | 25 size_(0), |
27 map_count_(0) { | 26 map_count_(0) { |
28 } | 27 } |
29 | 28 |
(...skipping 19 matching lines...) Expand all Loading... |
49 } | 48 } |
50 | 49 |
51 PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { | 50 PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() { |
52 return this; | 51 return this; |
53 } | 52 } |
54 | 53 |
55 PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() { | 54 PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() { |
56 return this; | 55 return this; |
57 } | 56 } |
58 | 57 |
59 PPB_BufferTrusted_API* PPB_Buffer_Impl::AsPPB_BufferTrusted_API() { | |
60 return this; | |
61 } | |
62 | |
63 bool PPB_Buffer_Impl::Init(uint32_t size) { | 58 bool PPB_Buffer_Impl::Init(uint32_t size) { |
64 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 59 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
65 if (size == 0 || !plugin_delegate) | 60 if (size == 0 || !plugin_delegate) |
66 return false; | 61 return false; |
67 size_ = size; | 62 size_ = size; |
68 shared_memory_.reset(plugin_delegate->CreateAnonymousSharedMemory(size)); | 63 shared_memory_.reset(plugin_delegate->CreateAnonymousSharedMemory(size)); |
69 return shared_memory_.get() != NULL; | 64 return shared_memory_.get() != NULL; |
70 } | 65 } |
71 | 66 |
72 PP_Bool PPB_Buffer_Impl::Describe(uint32_t* size_in_bytes) { | 67 PP_Bool PPB_Buffer_Impl::Describe(uint32_t* size_in_bytes) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 api->Describe(&size_); | 104 api->Describe(&size_); |
110 } | 105 } |
111 | 106 |
112 BufferAutoMapper::~BufferAutoMapper() { | 107 BufferAutoMapper::~BufferAutoMapper() { |
113 if (needs_unmap_) | 108 if (needs_unmap_) |
114 api_->Unmap(); | 109 api_->Unmap(); |
115 } | 110 } |
116 | 111 |
117 } // namespace ppapi | 112 } // namespace ppapi |
118 } // namespace webkit | 113 } // namespace webkit |
OLD | NEW |