Remove redundant deinitialization code from HttpCache::Transaction.
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_resource_array_shared.cc
blobf7353f116620c3571c7d96bdf5f1a39cdaaad872
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.
5 #include "ppapi/shared_impl/ppb_resource_array_shared.h"
7 #include "base/logging.h"
8 #include "ppapi/shared_impl/ppapi_globals.h"
9 #include "ppapi/shared_impl/resource_tracker.h"
11 using ppapi::thunk::PPB_ResourceArray_API;
13 namespace ppapi {
15 PPB_ResourceArray_Shared::PPB_ResourceArray_Shared(ResourceObjectType type,
16 PP_Instance instance,
17 const PP_Resource elements[],
18 uint32_t size)
19 : Resource(type, instance) {
20 DCHECK(resources_.empty());
22 resources_.reserve(size);
23 for (uint32_t index = 0; index < size; ++index) {
24 PP_Resource element = elements[index];
25 if (element)
26 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(element);
27 resources_.push_back(element);
31 PPB_ResourceArray_Shared::~PPB_ResourceArray_Shared() {
32 for (std::vector<PP_Resource>::iterator iter = resources_.begin();
33 iter != resources_.end(); ++iter) {
34 if (*iter)
35 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(*iter);
39 PPB_ResourceArray_API* PPB_ResourceArray_Shared::AsPPB_ResourceArray_API() {
40 return this;
43 uint32_t PPB_ResourceArray_Shared::GetSize() {
44 return static_cast<uint32_t>(resources_.size());
47 PP_Resource PPB_ResourceArray_Shared::GetAt(uint32_t index) {
48 return index < resources_.size() ? resources_[index] : 0;
51 } // namespace ppapi