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
3 // found in the LICENSE file.
5 #include "ppapi/cpp/dev/buffer_dev.h"
7 #include "ppapi/c/dev/ppb_buffer_dev.h"
8 #include "ppapi/cpp/instance_handle.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h"
16 template <> const char* interface_name
<PPB_Buffer_Dev
>() {
17 return PPB_BUFFER_DEV_INTERFACE
;
22 Buffer_Dev::Buffer_Dev() : data_(NULL
), size_(0) {
25 Buffer_Dev::Buffer_Dev(const Buffer_Dev
& other
)
30 Buffer_Dev::Buffer_Dev(PP_Resource resource
)
31 : Resource(resource
) {
35 Buffer_Dev::Buffer_Dev(const InstanceHandle
& instance
, uint32_t size
)
38 if (!has_interface
<PPB_Buffer_Dev
>())
41 PassRefFromConstructor(get_interface
<PPB_Buffer_Dev
>()->Create(
42 instance
.pp_instance(), size
));
46 Buffer_Dev::Buffer_Dev(PassRef
, PP_Resource resource
)
47 : Resource(PassRef(), resource
) {
51 Buffer_Dev::~Buffer_Dev() {
52 get_interface
<PPB_Buffer_Dev
>()->Unmap(pp_resource());
55 Buffer_Dev
& Buffer_Dev::operator=(const Buffer_Dev
& rhs
) {
56 Resource::operator=(rhs
);
61 void Buffer_Dev::Init() {
62 if (get_interface
<PPB_Buffer_Dev
>()->Describe(pp_resource(), &size_
)) {
63 data_
= get_interface
<PPB_Buffer_Dev
>()->Map(pp_resource());