1 // Copyright (c) 2010 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/cpp/resource.h"
9 #include "ppapi/cpp/logging.h"
10 #include "ppapi/cpp/module.h"
14 Resource::Resource() : pp_resource_(0) {
17 Resource::Resource(const Resource
& other
) : pp_resource_(other
.pp_resource_
) {
19 Module::Get()->core()->AddRefResource(pp_resource_
);
22 Resource::~Resource() {
24 Module::Get()->core()->ReleaseResource(pp_resource_
);
27 Resource
& Resource::operator=(const Resource
& other
) {
29 Module::Get()->core()->AddRefResource(other
.pp_resource_
);
31 Module::Get()->core()->ReleaseResource(pp_resource_
);
32 pp_resource_
= other
.pp_resource_
;
36 PP_Resource
Resource::detach() {
37 PP_Resource ret
= pp_resource_
;
42 Resource::Resource(PP_Resource resource
) : pp_resource_(resource
) {
44 Module::Get()->core()->AddRefResource(pp_resource_
);
47 Resource::Resource(PassRef
, PP_Resource resource
) : pp_resource_(resource
) {
50 void Resource::PassRefFromConstructor(PP_Resource resource
) {
51 PP_DCHECK(!pp_resource_
);
52 pp_resource_
= resource
;
55 void Resource::Clear() {
58 Module::Get()->core()->ReleaseResource(pp_resource_
);