[email protected] | dc0156ac | 2011-07-06 22:17:14 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "ppapi/proxy/ppb_memory_proxy.h" |
| 6 | |
| 7 | #include "ppapi/c/dev/ppb_memory_dev.h" |
| 8 | #include "ppapi/proxy/plugin_var_tracker.h" |
| 9 | |
| 10 | namespace pp { |
| 11 | namespace proxy { |
| 12 | |
| 13 | namespace { |
| 14 | |
| 15 | // PPB_Memory_Dev plugin ------------------------------------------------------- |
| 16 | |
| 17 | void* MemAlloc(uint32_t num_bytes) { |
| 18 | return malloc(num_bytes); |
| 19 | } |
| 20 | |
| 21 | void MemFree(void *ptr) { |
| 22 | free(ptr); |
| 23 | } |
| 24 | |
| 25 | const PPB_Memory_Dev memory_dev_interface = { |
| 26 | &MemAlloc, |
| 27 | &MemFree |
| 28 | }; |
| 29 | |
| 30 | InterfaceProxy* CreateMemoryProxy(Dispatcher* dispatcher, |
| 31 | const void* target_interface) { |
| 32 | return new PPB_Memory_Proxy(dispatcher, target_interface); |
| 33 | } |
| 34 | |
| 35 | } // namespace |
| 36 | |
| 37 | PPB_Memory_Proxy::PPB_Memory_Proxy(Dispatcher* dispatcher, |
| 38 | const void* target_interface) |
| 39 | : InterfaceProxy(dispatcher, target_interface) { |
| 40 | } |
| 41 | |
| 42 | PPB_Memory_Proxy::~PPB_Memory_Proxy() { |
| 43 | } |
| 44 | |
| 45 | // static |
| 46 | const InterfaceProxy::Info* PPB_Memory_Proxy::GetInfo() { |
| 47 | static const Info info = { |
| 48 | &memory_dev_interface, |
| 49 | PPB_MEMORY_DEV_INTERFACE, |
| 50 | INTERFACE_ID_PPB_MEMORY, |
| 51 | false, |
| 52 | &CreateMemoryProxy, |
| 53 | }; |
| 54 | return &info; |
| 55 | } |
| 56 | |
| 57 | bool PPB_Memory_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 58 | // All PPB_Memory_Dev calls are handled locally; there is no need to send or |
| 59 | // receive messages here. |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | } // namespace proxy |
| 64 | } // namespace pp |