diff options
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_memory_impl.cc | 37 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_memory_impl.h | 23 |
3 files changed, 64 insertions, 0 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index bd7bf11..c9f98c6 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -31,6 +31,7 @@ #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" #include "ppapi/c/dev/ppb_graphics_3d_dev.h" #include "ppapi/c/dev/ppb_layer_compositor_dev.h" +#include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" @@ -89,6 +90,7 @@ #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" +#include "webkit/plugins/ppapi/ppb_memory_impl.h" #include "webkit/plugins/ppapi/ppb_opengles_impl.h" #include "webkit/plugins/ppapi/ppb_proxy_impl.h" #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" @@ -292,6 +294,8 @@ const void* GetInterface(const char* name) { return ::ppapi::thunk::GetPPB_Instance_0_5_Thunk(); if (strcmp(name, PPB_INSTANCE_PRIVATE_INTERFACE) == 0) return ::ppapi::thunk::GetPPB_Instance_Private_Thunk(); + if (strcmp(name, PPB_MEMORY_DEV_INTERFACE) == 0) + return PPB_Memory_Impl::GetInterface(); if (strcmp(name, PPB_MESSAGING_INTERFACE) == 0) return PluginInstance::GetMessagingInterface(); if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) diff --git a/webkit/plugins/ppapi/ppb_memory_impl.cc b/webkit/plugins/ppapi/ppb_memory_impl.cc new file mode 100644 index 0000000..a298d44 --- /dev/null +++ b/webkit/plugins/ppapi/ppb_memory_impl.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/plugins/ppapi/ppb_memory_impl.h" + +#include <stdlib.h> +#include "ppapi/c/dev/ppb_memory_dev.h" + +namespace webkit { +namespace ppapi { + +namespace { + +void* MemAlloc(uint32_t num_bytes) { + return malloc(num_bytes); +} + +void MemFree(void* ptr) { + free(ptr); +} + +const PPB_Memory_Dev ppb_memory = { + &MemAlloc, + &MemFree +}; + +} // namespace + +// static +const struct PPB_Memory_Dev* PPB_Memory_Impl::GetInterface() { + return &ppb_memory; +} + +} // namespace ppapi +} // namespace webkit + diff --git a/webkit/plugins/ppapi/ppb_memory_impl.h b/webkit/plugins/ppapi/ppb_memory_impl.h new file mode 100644 index 0000000..f07c055 --- /dev/null +++ b/webkit/plugins/ppapi/ppb_memory_impl.h @@ -0,0 +1,23 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_PLUGINS_PPAPI_PPB_MEMORY_IMPL_H_ +#define WEBKIT_PLUGINS_PPAPI_PPB_MEMORY_IMPL_H_ + +struct PPB_Memory_Dev; + +namespace webkit { +namespace ppapi { + +class PPB_Memory_Impl { + public: + // Returns a pointer to the interface implementing PPB_Memory_Dev that is + // exposed to the plugin. + static const PPB_Memory_Dev* GetInterface(); +}; + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_PPB_MEMORY_IMPL_H_ |