OLD | NEW |
| (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/dev/var_array_buffer_dev.h" | |
6 | |
7 #include <limits> | |
8 | |
9 #include "ppapi/c/dev/ppb_var_array_buffer_dev.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_Dev>() { | |
18 return PPB_VAR_ARRAY_BUFFER_DEV_INTERFACE; | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 VarArrayBuffer_Dev::VarArrayBuffer_Dev(const Var& var) : Var(var) { | |
24 if (!var.is_array_buffer()) { | |
25 PP_NOTREACHED(); | |
26 var_ = PP_MakeNull(); | |
27 } | |
28 } | |
29 | |
30 VarArrayBuffer_Dev::VarArrayBuffer_Dev(uint32_t size_in_bytes) { | |
31 if (has_interface<PPB_VarArrayBuffer_Dev>()) { | |
32 var_ = get_interface<PPB_VarArrayBuffer_Dev>()->Create(size_in_bytes); | |
33 needs_release_ = true; | |
34 } else { | |
35 PP_NOTREACHED(); | |
36 var_ = PP_MakeNull(); | |
37 } | |
38 } | |
39 | |
40 pp::VarArrayBuffer_Dev& VarArrayBuffer_Dev::operator=( | |
41 const VarArrayBuffer_Dev& other) { | |
42 Var::operator=(other); | |
43 return *this; | |
44 } | |
45 | |
46 pp::Var& VarArrayBuffer_Dev::operator=(const Var& other) { | |
47 if (other.is_array_buffer()) { | |
48 return Var::operator=(other); | |
49 } else { | |
50 PP_NOTREACHED(); | |
51 return *this; | |
52 } | |
53 } | |
54 | |
55 uint32_t VarArrayBuffer_Dev::ByteLength() const { | |
56 uint32_t byte_length = std::numeric_limits<uint32_t>::max(); | |
57 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>()) | |
58 get_interface<PPB_VarArrayBuffer_Dev>()->ByteLength(var_, &byte_length); | |
59 else | |
60 PP_NOTREACHED(); | |
61 return byte_length; | |
62 } | |
63 | |
64 void* VarArrayBuffer_Dev::Map() { | |
65 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>()) | |
66 return get_interface<PPB_VarArrayBuffer_Dev>()->Map(var_); | |
67 PP_NOTREACHED(); | |
68 return NULL; | |
69 } | |
70 | |
71 void VarArrayBuffer_Dev::Unmap() { | |
72 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_Dev>()) | |
73 get_interface<PPB_VarArrayBuffer_Dev>()->Unmap(var_); | |
74 else | |
75 PP_NOTREACHED(); | |
76 } | |
77 | |
78 } // namespace pp | |
OLD | NEW |