summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 22:17:14 +0000
committerdspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 22:17:14 +0000
commitdc0156ac9d9f10a5a0f1cde94741b0c042c63ea6 (patch)
tree7f3dacaab478585c1116f58c7df880a58b838140 /ppapi
parent0d49c28e96dafa26e14976087e7a8d03e9613b64 (diff)
downloadchromium_src-dc0156ac9d9f10a5a0f1cde94741b0c042c63ea6.zip
chromium_src-dc0156ac9d9f10a5a0f1cde94741b0c042c63ea6.tar.gz
chromium_src-dc0156ac9d9f10a5a0f1cde94741b0c042c63ea6.tar.bz2
Add PPB_Memory_Dev to the proxy.
Includes both in- and out-of-process tests. BUG=80610 TEST=ui_tests Review URL: http://codereview.chromium.org/7307026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_proxy.gypi2
-rw-r--r--ppapi/proxy/dispatcher.cc2
-rw-r--r--ppapi/proxy/interface_id.h1
-rw-r--r--ppapi/proxy/ppb_memory_proxy.cc64
-rw-r--r--ppapi/proxy/ppb_memory_proxy.h36
-rw-r--r--ppapi/tests/test_memory.cc20
6 files changed, 111 insertions, 14 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 5af875d..43ffd3d 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -100,6 +100,8 @@
'proxy/ppb_image_data_proxy.h',
'proxy/ppb_instance_proxy.cc',
'proxy/ppb_instance_proxy.h',
+ 'proxy/ppb_memory_proxy.cc',
+ 'proxy/ppb_memory_proxy.h',
'proxy/ppb_opengles2_proxy.cc',
'proxy/ppb_opengles2_proxy.h',
'proxy/ppb_pdf_proxy.cc',
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index b8db635..7941992 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -67,6 +67,7 @@
#include "ppapi/proxy/ppb_graphics_2d_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/ppb_instance_proxy.h"
+#include "ppapi/proxy/ppb_memory_proxy.h"
#include "ppapi/proxy/ppb_opengles2_proxy.h"
#include "ppapi/proxy/ppb_pdf_proxy.h"
#include "ppapi/proxy/ppb_surface_3d_proxy.h"
@@ -139,6 +140,7 @@ InterfaceList::InterfaceList() {
AddPPB(PPB_Instance_Proxy::GetInfo0_4());
AddPPB(PPB_Instance_Proxy::GetInfo0_5());
AddPPB(PPB_Instance_Proxy::GetInfoFullscreen());
+ AddPPB(PPB_Memory_Proxy::GetInfo());
AddPPB(PPB_OpenGLES2_Proxy::GetInfo());
AddPPB(PPB_PDF_Proxy::GetInfo());
AddPPB(PPB_Surface3D_Proxy::GetInfo());
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h
index 8fccd1d..47d0083 100644
--- a/ppapi/proxy/interface_id.h
+++ b/ppapi/proxy/interface_id.h
@@ -39,6 +39,7 @@ enum InterfaceID {
INTERFACE_ID_PPB_IMAGE_DATA,
INTERFACE_ID_PPB_INSTANCE,
INTERFACE_ID_PPB_INSTANCE_PRIVATE,
+ INTERFACE_ID_PPB_MEMORY,
INTERFACE_ID_PPB_OPENGLES2,
INTERFACE_ID_PPB_PDF,
INTERFACE_ID_PPB_SURFACE_3D,
diff --git a/ppapi/proxy/ppb_memory_proxy.cc b/ppapi/proxy/ppb_memory_proxy.cc
new file mode 100644
index 0000000..616e789
--- /dev/null
+++ b/ppapi/proxy/ppb_memory_proxy.cc
@@ -0,0 +1,64 @@
+// 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 "ppapi/proxy/ppb_memory_proxy.h"
+
+#include "ppapi/c/dev/ppb_memory_dev.h"
+#include "ppapi/proxy/plugin_var_tracker.h"
+
+namespace pp {
+namespace proxy {
+
+namespace {
+
+// PPB_Memory_Dev plugin -------------------------------------------------------
+
+void* MemAlloc(uint32_t num_bytes) {
+ return malloc(num_bytes);
+}
+
+void MemFree(void *ptr) {
+ free(ptr);
+}
+
+const PPB_Memory_Dev memory_dev_interface = {
+ &MemAlloc,
+ &MemFree
+};
+
+InterfaceProxy* CreateMemoryProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_Memory_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_Memory_Proxy::PPB_Memory_Proxy(Dispatcher* dispatcher,
+ const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+}
+
+PPB_Memory_Proxy::~PPB_Memory_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPB_Memory_Proxy::GetInfo() {
+ static const Info info = {
+ &memory_dev_interface,
+ PPB_MEMORY_DEV_INTERFACE,
+ INTERFACE_ID_PPB_MEMORY,
+ false,
+ &CreateMemoryProxy,
+ };
+ return &info;
+}
+
+bool PPB_Memory_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ // All PPB_Memory_Dev calls are handled locally; there is no need to send or
+ // receive messages here.
+ return false;
+}
+
+} // namespace proxy
+} // namespace pp
diff --git a/ppapi/proxy/ppb_memory_proxy.h b/ppapi/proxy/ppb_memory_proxy.h
new file mode 100644
index 0000000..503dd70
--- /dev/null
+++ b/ppapi/proxy/ppb_memory_proxy.h
@@ -0,0 +1,36 @@
+// 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 PPAPI_PPB_MEMORY_PROXY_H_
+#define PPAPI_PPB_MEMORY_PROXY_H_
+
+#include "ppapi/proxy/interface_proxy.h"
+
+struct PPB_Memory_Dev;
+
+namespace pp {
+namespace proxy {
+
+class PPB_Memory_Proxy : public InterfaceProxy {
+ public:
+ PPB_Memory_Proxy(Dispatcher* dispatcher,
+ const void* target_interface);
+ virtual ~PPB_Memory_Proxy();
+
+ static const Info* GetInfo();
+
+ const PPB_Memory_Dev* ppb_memory_target() const {
+ return static_cast<const PPB_Memory_Dev*>(target_interface());
+ }
+
+ // InterfaceProxy implementation. In this case, no messages are sent or
+ // received, so this always returns false.
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+};
+
+} // namespace proxy
+} // namespace pp
+
+#endif // PPAPI_PPB_MEMORY_PROXY_H_
diff --git a/ppapi/tests/test_memory.cc b/ppapi/tests/test_memory.cc
index 1d44db4..1dedbd4 100644
--- a/ppapi/tests/test_memory.cc
+++ b/ppapi/tests/test_memory.cc
@@ -30,20 +30,12 @@ void TestMemory::RunTest() {
}
std::string TestMemory::TestMemAlloc() {
- uint32_t before_object = testing_interface_->GetLiveObjectsForInstance(
- instance_->pp_instance());
- {
- char* buffer = static_cast<char*>(
- memory_dev_interface_->MemAlloc(kTestBufferSize));
- // Touch a couple of locations. Failure will crash the test.
- buffer[0] = '1';
- buffer[kTestBufferSize - 1] = '1';
- memory_dev_interface_->MemFree(buffer);
- }
-
- // Make sure nothing leaked.
- ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance(
- instance_->pp_instance()) == before_object);
+ char* buffer = static_cast<char*>(
+ memory_dev_interface_->MemAlloc(kTestBufferSize));
+ // Touch a couple of locations. Failure will crash the test.
+ buffer[0] = '1';
+ buffer[kTestBufferSize - 1] = '1';
+ memory_dev_interface_->MemFree(buffer);
PASS();
}