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

Unified Diff: ppapi/cpp/dev/var_array_buffer_dev.cc

Issue 9169052: Tweaks to PPB_VarArrayBuffer in preperation for taking out of Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes based on reviews 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/dev/var_array_buffer_dev.h ('k') | ppapi/cpp/var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/var_array_buffer_dev.cc
diff --git a/ppapi/cpp/dev/var_array_buffer_dev.cc b/ppapi/cpp/dev/var_array_buffer_dev.cc
index 61f697efa2150ff29bc267264eeb48db51eb8d53..47ad9b31731361df332c4b45cea7dadc7fb71555 100644
--- a/ppapi/cpp/dev/var_array_buffer_dev.cc
+++ b/ppapi/cpp/dev/var_array_buffer_dev.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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/var_array_buffer_dev.h"
+#include <limits>
+
#include "ppapi/c/dev/ppb_var_array_buffer_dev.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module_impl.h"
@@ -18,50 +20,59 @@ template <> const char* interface_name<PPB_VarArrayBuffer_Dev>() {
} // namespace
-VarArrayBuffer_Dev::VarArrayBuffer_Dev(const Var& var)
- : Var(var), buffer_(NULL) {
- if (var.is_array_buffer()) {
- buffer_ = Map();
- } else {
+VarArrayBuffer_Dev::VarArrayBuffer_Dev(const Var& var) : Var(var) {
+ if (!var.is_array_buffer()) {
PP_NOTREACHED();
var_ = PP_MakeNull();
}
}
-VarArrayBuffer_Dev::VarArrayBuffer_Dev(uint32_t size_in_bytes)
- : buffer_(NULL) {
+VarArrayBuffer_Dev::VarArrayBuffer_Dev(uint32_t size_in_bytes) {
if (has_interface<PPB_VarArrayBuffer_Dev>()) {
var_ = get_interface<PPB_VarArrayBuffer_Dev>()->Create(size_in_bytes);
needs_release_ = true;
- buffer_ = Map();
} else {
PP_NOTREACHED();
var_ = PP_MakeNull();
}
}
-uint32_t VarArrayBuffer_Dev::ByteLength() const {
- if (has_interface<PPB_VarArrayBuffer_Dev>()) {
- return get_interface<PPB_VarArrayBuffer_Dev>()->ByteLength(var_);
+pp::VarArrayBuffer_Dev& VarArrayBuffer_Dev::operator=(
+ const VarArrayBuffer_Dev& other) {
+ Var::operator=(other);
+ return *this;
+}
+
+pp::Var& VarArrayBuffer_Dev::operator=(const Var& other) {
+ if (other.is_array_buffer()) {
+ return Var::operator=(other);
+ } else {
+ PP_NOTREACHED();
+ return *this;
}
- PP_NOTREACHED();
- return 0;
}
-const void* VarArrayBuffer_Dev::Map() const {
- return const_cast<VarArrayBuffer_Dev*>(this)->Map();
+uint32_t VarArrayBuffer_Dev::ByteLength() const {
+ uint32_t byte_length = std::numeric_limits<uint32_t>::max();
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>())
+ get_interface<PPB_VarArrayBuffer_Dev>()->ByteLength(var_, &byte_length);
+ else
+ PP_NOTREACHED();
+ return byte_length;
}
void* VarArrayBuffer_Dev::Map() {
- // TODO(dmichael): This is not thread-safe.
- if (buffer_)
- return buffer_;
- if (has_interface<PPB_VarArrayBuffer_Dev>()) {
- buffer_ = get_interface<PPB_VarArrayBuffer_Dev>()->Map(var_);
- return buffer_;
- }
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>())
+ return get_interface<PPB_VarArrayBuffer_Dev>()->Map(var_);
PP_NOTREACHED();
- return 0;
+ return NULL;
+}
+
+void VarArrayBuffer_Dev::Unmap() {
+ if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>())
+ get_interface<PPB_VarArrayBuffer_Dev>()->Unmap(var_);
+ else
+ PP_NOTREACHED();
}
} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/var_array_buffer_dev.h ('k') | ppapi/cpp/var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698