OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "ppapi/shared_impl/var.h" | |
9 | |
10 namespace ppapi { | |
11 | |
12 PPB_FileRef_Shared::PPB_FileRef_Shared(ResourceObjectType type, | |
13 const PPB_FileRef_CreateInfo& info) | |
14 : Resource(type, info.resource), | |
15 create_info_(info) { | |
16 if (type == OBJECT_IS_IMPL) { | |
17 // Resource's constructor assigned a PP_Resource, so we can fill out our | |
18 // host resource now. | |
19 create_info_.resource = host_resource(); | |
20 } | |
21 } | |
22 | |
23 PPB_FileRef_Shared::~PPB_FileRef_Shared() { | |
24 } | |
25 | |
26 thunk::PPB_FileRef_API* PPB_FileRef_Shared::AsPPB_FileRef_API() { | |
27 return this; | |
28 } | |
29 | |
30 PP_FileSystemType PPB_FileRef_Shared::GetFileSystemType() const { | |
31 return static_cast<PP_FileSystemType>(create_info_.file_system_type); | |
32 } | |
33 | |
34 PP_Var PPB_FileRef_Shared::GetName() const { | |
35 if (!name_var_.get()) { | |
36 name_var_ = new StringVar(create_info_.name); | |
37 } | |
38 return name_var_->GetPPVar(); | |
39 } | |
40 | |
41 PP_Var PPB_FileRef_Shared::GetPath() const { | |
42 if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) | |
43 return PP_MakeUndefined(); | |
44 if (!path_var_.get()) { | |
45 path_var_ = new StringVar(create_info_.path); | |
46 } | |
47 return path_var_->GetPPVar(); | |
48 } | |
49 | |
50 const PPB_FileRef_CreateInfo& PPB_FileRef_Shared::GetCreateInfo() const { | |
51 return create_info_; | |
52 } | |
53 | |
54 } // namespace ppapi | |
OLD | NEW |