| 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) { | |
| 78 PP_Var* result = array_; | 77 PP_Var* result = array_; |
| 79 *size = size_; | |
| 80 array_ = NULL; | 78 array_ = NULL; |
| 81 size_ = 0; | 79 size_ = 0; |
| 82 return result; | 80 return result; |
| 83 } | 81 } |
| 84 | 82 |
| 85 void ScopedPPVarArray::Set(size_t index, PP_Var var) { | 83 void ScopedPPVarArray::Set(size_t index, const ScopedPPVar& var) { |
| 86 DCHECK(index < size_); | 84 DCHECK(index < size_); |
| 87 CallAddRef(var); | 85 CallAddRef(var.get()); |
| 88 CallRelease(array_[index]); | 86 CallRelease(array_[index]); |
| 89 array_[index] = var; | 87 array_[index] = var.get(); |
| 90 } | 88 } |
| 91 | 89 |
| 92 } // namespace ppapi | 90 } // namespace ppapi |
| OLD | NEW |