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_file_ref_shared.h"
7 #include "base/logging.h"
8 #include "ppapi/shared_impl/var.h"
12 PPB_FileRef_Shared::PPB_FileRef_Shared(ResourceObjectType type
,
13 const PPB_FileRef_CreateInfo
& info
)
14 : Resource(type
, info
.resource
),
16 if (type
== OBJECT_IS_IMPL
) {
17 // Resource's constructor assigned a PP_Resource, so we can fill out our
19 create_info_
.resource
= host_resource();
20 DCHECK(!create_info_
.resource
.is_null());
24 PPB_FileRef_Shared::~PPB_FileRef_Shared() {
27 thunk::PPB_FileRef_API
* PPB_FileRef_Shared::AsPPB_FileRef_API() {
31 PP_FileSystemType
PPB_FileRef_Shared::GetFileSystemType() const {
32 return static_cast<PP_FileSystemType
>(create_info_
.file_system_type
);
35 PP_Var
PPB_FileRef_Shared::GetName() const {
36 if (!name_var_
.get()) {
37 name_var_
= new StringVar(create_info_
.name
);
39 return name_var_
->GetPPVar();
42 PP_Var
PPB_FileRef_Shared::GetPath() const {
43 if (create_info_
.file_system_type
== PP_FILESYSTEMTYPE_EXTERNAL
)
44 return PP_MakeUndefined();
45 if (!path_var_
.get()) {
46 path_var_
= new StringVar(create_info_
.path
);
48 return path_var_
->GetPPVar();
51 const PPB_FileRef_CreateInfo
& PPB_FileRef_Shared::GetCreateInfo() const {