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

Side by Side Diff: ppapi/cpp/var_array_buffer.cc

Issue 13985026: Add a default constructor for VarArrayBuffer, so that it can be used by ext::DictField. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « ppapi/cpp/var_array_buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/var_array_buffer.h" 5 #include "ppapi/cpp/var_array_buffer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ppapi/c/ppb_var_array_buffer.h" 9 #include "ppapi/c/ppb_var_array_buffer.h"
10 #include "ppapi/cpp/logging.h" 10 #include "ppapi/cpp/logging.h"
11 #include "ppapi/cpp/module_impl.h" 11 #include "ppapi/cpp/module_impl.h"
12 12
13 namespace pp { 13 namespace pp {
14 14
15 namespace { 15 namespace {
16 16
17 template <> const char* interface_name<PPB_VarArrayBuffer_1_0>() { 17 template <> const char* interface_name<PPB_VarArrayBuffer_1_0>() {
18 return PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0; 18 return PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0;
19 } 19 }
20 20
21 } // namespace 21 } // namespace
22 22
23 VarArrayBuffer::VarArrayBuffer() {
24 ConstructWithSize(0);
25 }
26
23 VarArrayBuffer::VarArrayBuffer(const Var& var) : Var(var) { 27 VarArrayBuffer::VarArrayBuffer(const Var& var) : Var(var) {
24 if (!var.is_array_buffer()) { 28 if (!var.is_array_buffer()) {
25 PP_NOTREACHED(); 29 PP_NOTREACHED();
26 var_ = PP_MakeNull(); 30 var_ = PP_MakeNull();
27 } 31 }
28 } 32 }
29 33
30 VarArrayBuffer::VarArrayBuffer(uint32_t size_in_bytes) { 34 VarArrayBuffer::VarArrayBuffer(uint32_t size_in_bytes) {
31 if (has_interface<PPB_VarArrayBuffer_1_0>()) { 35 ConstructWithSize(size_in_bytes);
32 var_ = get_interface<PPB_VarArrayBuffer_1_0>()->Create(size_in_bytes);
33 } else {
34 PP_NOTREACHED();
35 var_ = PP_MakeNull();
36 }
37 is_managed_ = true;
38 } 36 }
39 37
40 pp::VarArrayBuffer& VarArrayBuffer::operator=(const VarArrayBuffer& other) { 38 pp::VarArrayBuffer& VarArrayBuffer::operator=(const VarArrayBuffer& other) {
41 Var::operator=(other); 39 Var::operator=(other);
42 return *this; 40 return *this;
43 } 41 }
44 42
45 pp::Var& VarArrayBuffer::operator=(const Var& other) { 43 pp::Var& VarArrayBuffer::operator=(const Var& other) {
46 if (other.is_array_buffer()) { 44 if (other.is_array_buffer()) {
47 return Var::operator=(other); 45 return Var::operator=(other);
(...skipping 19 matching lines...) Expand all
67 return NULL; 65 return NULL;
68 } 66 }
69 67
70 void VarArrayBuffer::Unmap() { 68 void VarArrayBuffer::Unmap() {
71 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_1_0>()) 69 if (is_array_buffer() && has_interface<PPB_VarArrayBuffer_1_0>())
72 get_interface<PPB_VarArrayBuffer_1_0>()->Unmap(var_); 70 get_interface<PPB_VarArrayBuffer_1_0>()->Unmap(var_);
73 else 71 else
74 PP_NOTREACHED(); 72 PP_NOTREACHED();
75 } 73 }
76 74
75
76 void VarArrayBuffer::ConstructWithSize(uint32_t size_in_bytes) {
77 PP_DCHECK(is_undefined());
78
79 if (has_interface<PPB_VarArrayBuffer_1_0>()) {
80 var_ = get_interface<PPB_VarArrayBuffer_1_0>()->Create(size_in_bytes);
81 } else {
82 PP_NOTREACHED();
83 var_ = PP_MakeNull();
84 }
85 is_managed_ = true;
86 }
87
77 } // namespace pp 88 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/var_array_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698