
The methodology used to generate this CL is documented in https://crbug.com/1098010#c95. No-Try: true Bug: 1098010 Change-Id: I6ae92e5d7ccbf73b176588124b2f8b4067f805b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900575 Reviewed-by: Mark Mentovai <mark@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Auto-Submit: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1047628}
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
// Copyright 2010 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "ppapi/cpp/resource.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "ppapi/cpp/logging.h"
|
|
#include "ppapi/cpp/module.h"
|
|
|
|
namespace pp {
|
|
|
|
Resource::Resource() : pp_resource_(0) {
|
|
}
|
|
|
|
Resource::Resource(const Resource& other) : pp_resource_(other.pp_resource_) {
|
|
if (!is_null())
|
|
Module::Get()->core()->AddRefResource(pp_resource_);
|
|
}
|
|
|
|
Resource::~Resource() {
|
|
if (!is_null())
|
|
Module::Get()->core()->ReleaseResource(pp_resource_);
|
|
}
|
|
|
|
Resource& Resource::operator=(const Resource& other) {
|
|
if (!other.is_null())
|
|
Module::Get()->core()->AddRefResource(other.pp_resource_);
|
|
if (!is_null())
|
|
Module::Get()->core()->ReleaseResource(pp_resource_);
|
|
pp_resource_ = other.pp_resource_;
|
|
return *this;
|
|
}
|
|
|
|
PP_Resource Resource::detach() {
|
|
PP_Resource ret = pp_resource_;
|
|
pp_resource_ = 0;
|
|
return ret;
|
|
}
|
|
|
|
Resource::Resource(PP_Resource resource) : pp_resource_(resource) {
|
|
if (!is_null())
|
|
Module::Get()->core()->AddRefResource(pp_resource_);
|
|
}
|
|
|
|
Resource::Resource(PassRef, PP_Resource resource) : pp_resource_(resource) {
|
|
}
|
|
|
|
void Resource::PassRefFromConstructor(PP_Resource resource) {
|
|
PP_DCHECK(!pp_resource_);
|
|
pp_resource_ = resource;
|
|
}
|
|
|
|
void Resource::Clear() {
|
|
if (is_null())
|
|
return;
|
|
Module::Get()->core()->ReleaseResource(pp_resource_);
|
|
pp_resource_ = 0;
|
|
}
|
|
|
|
} // namespace pp
|