diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-18 23:40:30 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-18 23:40:30 +0000 |
commit | 779f5051b3c48d2deef2832131c7f3c49304e02f (patch) | |
tree | 0bb9e1af718cb6047105cb660391e74edb6a4a3c | |
parent | 1c4f28f1b6d4cb4e1b0e5a655067271494dc5cbf (diff) | |
download | chromium_src-779f5051b3c48d2deef2832131c7f3c49304e02f.zip chromium_src-779f5051b3c48d2deef2832131c7f3c49304e02f.tar.gz chromium_src-779f5051b3c48d2deef2832131c7f3c49304e02f.tar.bz2 |
PPAPI: Add a (trivial) C++ wrapper for PPB_Crypto_Dev.
Review URL: https://chromiumcodereview.appspot.com/11185055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162844 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/cpp/dev/crypto_dev.cc | 29 | ||||
-rw-r--r-- | ppapi/cpp/dev/crypto_dev.h | 31 | ||||
-rw-r--r-- | ppapi/ppapi_sources.gypi | 2 |
3 files changed, 62 insertions, 0 deletions
diff --git a/ppapi/cpp/dev/crypto_dev.cc b/ppapi/cpp/dev/crypto_dev.cc new file mode 100644 index 0000000..fb9328d --- /dev/null +++ b/ppapi/cpp/dev/crypto_dev.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2012 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/crypto_dev.h" + +#include "ppapi/c/dev/ppb_crypto_dev.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_Crypto_Dev_0_1>() { + return PPB_CRYPTO_DEV_INTERFACE_0_1; +} + +} // namespace + +bool Crypto_Dev::GetRandomBytes(char* buffer, uint32_t num_bytes) { + if (has_interface<PPB_Crypto_Dev_0_1>()) { + get_interface<PPB_Crypto_Dev_0_1>()->GetRandomBytes(buffer, num_bytes); + return true; + } + return false; +} + +} // namespace pp diff --git a/ppapi/cpp/dev/crypto_dev.h b/ppapi/cpp/dev/crypto_dev.h new file mode 100644 index 0000000..2bbd43d8 --- /dev/null +++ b/ppapi/cpp/dev/crypto_dev.h @@ -0,0 +1,31 @@ +// Copyright (c) 2012 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_CRYPTO_DEV_H_ +#define PPAPI_CPP_DEV_CRYPTO_DEV_H_ + +#include "ppapi/c/pp_stdint.h" + +/// @file +/// This file defines APIs related to cryptography. + +namespace pp { + +/// APIs related to cryptography. +class Crypto_Dev { + public: + Crypto_Dev() {} + + /// A function that fills the buffer with random bytes. This may be slow, so + /// avoid getting more bytes than needed. + /// + /// @param[out] buffer The buffer to receive the random bytes. + /// @param[in] num_bytes A number of random bytes to produce. + /// @return True on success, false on failure. + bool GetRandomBytes(char* buffer, uint32_t num_bytes); +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_CRYPTO_DEV_H_ diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index eb60006..541cfbd 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -201,6 +201,8 @@ 'cpp/dev/audio_input_dev.h', 'cpp/dev/buffer_dev.cc', 'cpp/dev/buffer_dev.h', + 'cpp/dev/crypto_dev.cc', + 'cpp/dev/crypto_dev.h', 'cpp/dev/device_ref_dev.cc', 'cpp/dev/device_ref_dev.h', 'cpp/dev/directory_entry_dev.cc', |