OLD | NEW |
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/shared_impl/scoped_pp_var.h" | 5 #include "ppapi/shared_impl/scoped_pp_var.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_memory_dev.h" | 7 #include "ppapi/c/dev/ppb_memory_dev.h" |
8 #include "ppapi/shared_impl/ppapi_globals.h" | 8 #include "ppapi/shared_impl/ppapi_globals.h" |
9 #include "ppapi/shared_impl/var_tracker.h" | 9 #include "ppapi/shared_impl/var_tracker.h" |
10 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 ScopedPPVarArray::~ScopedPPVarArray() { | 68 ScopedPPVarArray::~ScopedPPVarArray() { |
69 for (size_t i = 0; i < size_; ++i) | 69 for (size_t i = 0; i < size_; ++i) |
70 CallRelease(array_[i]); | 70 CallRelease(array_[i]); |
71 if (size_ > 0) | 71 if (size_ > 0) |
72 thunk::GetPPB_Memory_Dev_0_1_Thunk()->MemFree(array_); | 72 thunk::GetPPB_Memory_Dev_0_1_Thunk()->MemFree(array_); |
73 | 73 |
74 } | 74 } |
75 | 75 |
76 PP_Var* ScopedPPVarArray::Release(const PassPPBMemoryAllocatedArray&) { | 76 PP_Var* ScopedPPVarArray::Release(const PassPPBMemoryAllocatedArray&, |
| 77 size_t* size) { |
77 PP_Var* result = array_; | 78 PP_Var* result = array_; |
| 79 *size = size_; |
78 array_ = NULL; | 80 array_ = NULL; |
79 size_ = 0; | 81 size_ = 0; |
80 return result; | 82 return result; |
81 } | 83 } |
82 | 84 |
83 void ScopedPPVarArray::Set(size_t index, const ScopedPPVar& var) { | 85 void ScopedPPVarArray::Set(size_t index, PP_Var var) { |
84 DCHECK(index < size_); | 86 DCHECK(index < size_); |
85 CallAddRef(var.get()); | 87 CallAddRef(var); |
86 CallRelease(array_[index]); | 88 CallRelease(array_[index]); |
87 array_[index] = var.get(); | 89 array_[index] = var; |
88 } | 90 } |
89 | 91 |
90 } // namespace ppapi | 92 } // namespace ppapi |
OLD | NEW |