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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/var_array_buffer.h"
6
7 #include <limits>
8
9 #include "ppapi/c/ppb_var_array_buffer.h"
10 #include "ppapi/cpp/logging.h"
11 #include "ppapi/cpp/module_impl.h"
12
13 namespace pp {
14
15 namespace {
16
17 template <> const char* interface_name<PPB_VarArrayBuffer>() {
18 return PPB_VAR_ARRAY_BUFFER_INTERFACE;
19 }
20
21 } // namespace
22
23 VarArrayBuffer::VarArrayBuffer(const Var& var) : Var(var) {
24 if (!var.is_array_buffer()) {
25 PP_NOTREACHED();
26 var_ = PP_MakeNull();
27 }
28 }
29
30 VarArrayBuffer::VarArrayBuffer(uint32_t size_in_bytes) {
31 if (has_interface<PPB_VarArrayBuffer>()) {
32 var_ = get_interface<PPB_VarArrayBuffer>()->Create(size_in_bytes);
33 needs_release_ = true;
34 } else {
35 PP_NOTREACHED();
36 var_ = PP_MakeNull();
37 }
38 }
39
40 pp::VarArrayBuffer& VarArrayBuffer::operator=(const VarArrayBuffer& other) {
41 Var::operator=(other);
42 return *this;
43 }
44
45 pp::Var& VarArrayBuffer::operator=(const Var& other) {
46 if (other.is_array_buffer()) {
47 return Var::operator=(other);
48 } else {
49 PP_NOTREACHED();
50 return *this;
51 }
52 }
53
54 uint32_t VarArrayBuffer::ByteLength() const {
55 uint32_t byte_length = std::numeric_limits<uint32_t>::max();
56 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
57 get_interface<PPB_VarArrayBuffer>()->ByteLength(var_, &byte_length);
58 else
59 PP_NOTREACHED();
60 return byte_length;
61 }
62
63 void* VarArrayBuffer::Map() {
64 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
65 return get_interface<PPB_VarArrayBuffer>()->Map(var_);
66 PP_NOTREACHED();
67 return NULL;
68 }
69
70 void VarArrayBuffer::Unmap() {
71 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer>())
72 get_interface<PPB_VarArrayBuffer>()->Unmap(var_);
73 else
74 PP_NOTREACHED();
75 }
76
77 } // namespace pp
OLDNEW
« 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