diff options
author | dspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-05 21:37:00 +0000 |
---|---|---|
committer | dspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-05 21:37:00 +0000 |
commit | 14710e220b1e6fb4db5661b0569f978d850a7be6 (patch) | |
tree | 16fbd38c33750147601521ad7199e3821f01f32c /ppapi/cpp | |
parent | abbd2f4b36da8c89e6f3002eb84f60064a6ff067 (diff) | |
download | chromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.zip chromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.tar.gz chromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.tar.bz2 |
Add PPB_Memory_Dev. This is the first of a few CLs needed to pull MemAlloc and
MemFree from PPB_Core.
BUG=80610
TEST=ui_tests
Review URL: http://codereview.chromium.org/7300010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/memory_dev.cc | 33 | ||||
-rw-r--r-- | ppapi/cpp/dev/memory_dev.h | 36 |
2 files changed, 69 insertions, 0 deletions
diff --git a/ppapi/cpp/dev/memory_dev.cc b/ppapi/cpp/dev/memory_dev.cc new file mode 100644 index 0000000..ca7c125f --- /dev/null +++ b/ppapi/cpp/dev/memory_dev.cc @@ -0,0 +1,33 @@ +// 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/cpp/dev/memory_dev.h" + +#include "ppapi/c/dev/ppb_memory_dev.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_Memory_Dev>() { + return PPB_MEMORY_DEV_INTERFACE; +} + +} // namespace + +void* Memory_Dev::MemAlloc(uint32_t num_bytes) { + if (!has_interface<PPB_Memory_Dev>()) + return NULL; + return get_interface<PPB_Memory_Dev>()->MemAlloc(num_bytes); +} + +void Memory_Dev::MemFree(void* ptr) { + if (!has_interface<PPB_Memory_Dev>() || !ptr) + return; + get_interface<PPB_Memory_Dev>()->MemFree(ptr); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/memory_dev.h b/ppapi/cpp/dev/memory_dev.h new file mode 100644 index 0000000..2695cae --- /dev/null +++ b/ppapi/cpp/dev/memory_dev.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_CPP_DEV_MEMORY_DEV_H_ +#define PPAPI_CPP_DEV_MEMORY_DEV_H_ + +#include "ppapi/c/pp_stdint.h" + +/// @file +/// This file defines APIs related to memory management. + +namespace pp { + +/// APIs related to memory management, time, and threads. +class Memory_Dev { + public: + Memory_Dev() {} + + /// A function that allocates memory. + /// + /// @param[in] num_bytes A number of bytes to allocate. + /// @return A pointer to the memory if successful, NULL If the + /// allocation fails. + void* MemAlloc(uint32_t num_bytes); + + /// A function that deallocates memory. + /// + /// @param[in] ptr A pointer to the memory to deallocate. It is safe to + /// pass NULL to this function. + void MemFree(void* ptr); +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_MEMORY_DEV_H_ |