
This is a C++ wrapper for the C API PPB_VarResource_Dev. Also added methods to pp::FileSystem for converting a pp::Resource to a pp::FileSystem, which are necessary for making use of a resource extracted using pp::VarResource_Dev. (Committed by yzshen@chromium.org on behalf of mgiuca@chromium.org) BUG=177017 R=dmichael@chromium.org, noelallen@chromium.org, noelallen@google.com, yzshen@chromium.org Review URL: https://codereview.chromium.org/52233002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232482 0039d316-1c4b-4281-b951-d872f2087c98
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
|
// 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
|