Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: ppapi/cpp/var_array_buffer.cc

Issue 9107046: PPAPI: Move PPB_ArrayBuffer out of Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor fixes Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/var_array_buffer.h ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/var_array_buffer.cc
diff --git a/ppapi/cpp/var_array_buffer.cc b/ppapi/cpp/var_array_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a4104fd228e3a651e3e2188781df5b660d2293f4
--- /dev/null
+++ b/ppapi/cpp/var_array_buffer.cc
@@ -0,0 +1,77 @@
+// 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/var_array_buffer.h"
+
+#include <limits>
+
+#include "ppapi/c/ppb_var_array_buffer.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_VarArrayBuffer>() {
+ return PPB_VAR_ARRAY_BUFFER_INTERFACE;
+}
+
+} // namespace
+
+VarArrayBuffer::VarArrayBuffer(const Var& var) : Var(var) {
+ if (!var.is_array_buffer()) {
+ PP_NOTREACHED();
+ var_ = PP_MakeNull();
+ }
+}
+
+VarArrayBuffer::VarArrayBuffer(uint32_t size_in_bytes) {
+ if (has_interface<PPB_VarArrayBuffer>()) {
+ var_ = get_interface<PPB_VarArrayBuffer>()->Create(size_in_bytes);
+ needs_release_ = true;
+ } else {
+ PP_NOTREACHED();
+ var_ = PP_MakeNull();
+ }
+}
+
+pp::VarArrayBuffer& VarArrayBuffer::operator=(const VarArrayBuffer& other) {
+ Var::operator=(other);
+ return *this;
+}
+
+pp::Var& VarArrayBuffer::operator=(const Var& other) {
+ if (other.is_array_buffer()) {
+ return Var::operator=(other);
+ } else {
+ PP_NOTREACHED();
+ return *this;
+ }
+}
+
+uint32_t VarArrayBuffer::ByteLength() const {
+ uint32_t byte_length = std::numeric_limits<uint32_t>::max();
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
+ get_interface<PPB_VarArrayBuffer>()->ByteLength(var_, &byte_length);
+ else
+ PP_NOTREACHED();
+ return byte_length;
+}
+
+void* VarArrayBuffer::Map() {
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
+ return get_interface<PPB_VarArrayBuffer>()->Map(var_);
+ PP_NOTREACHED();
+ return NULL;
+}
+
+void VarArrayBuffer::Unmap() {
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
+ get_interface<PPB_VarArrayBuffer>()->Unmap(var_);
+ else
+ PP_NOTREACHED();
+}
+
+} // namespace pp
« no previous file with comments | « ppapi/cpp/var_array_buffer.h ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698