| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/file_ref_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ppapi/shared_impl/ppapi_globals.h" | |
| 9 #include "ppapi/shared_impl/var.h" | |
| 10 | |
| 11 namespace ppapi { | |
| 12 | |
| 13 FileRefImpl::FileRefImpl(const InitAsImpl&, const PPB_FileRef_CreateInfo& info) | |
| 14 : Resource(info.resource.instance()), | |
| 15 create_info_(info) { | |
| 16 // Should not have been passed a host resource for the trusted constructor. | |
| 17 DCHECK(info.resource.is_null()); | |
| 18 | |
| 19 // Resource's constructor assigned a PP_Resource, so we can fill out our | |
| 20 // host resource now. | |
| 21 create_info_.resource = host_resource(); | |
| 22 DCHECK(!create_info_.resource.is_null()); | |
| 23 } | |
| 24 | |
| 25 FileRefImpl::FileRefImpl(const InitAsProxy&, const PPB_FileRef_CreateInfo& info) | |
| 26 : Resource(info.resource), | |
| 27 create_info_(info) { | |
| 28 } | |
| 29 | |
| 30 FileRefImpl::~FileRefImpl() { | |
| 31 } | |
| 32 | |
| 33 thunk::PPB_FileRef_API* FileRefImpl::AsPPB_FileRef_API() { | |
| 34 return this; | |
| 35 } | |
| 36 | |
| 37 PP_FileSystemType FileRefImpl::GetFileSystemType() const { | |
| 38 return static_cast<PP_FileSystemType>(create_info_.file_system_type); | |
| 39 } | |
| 40 | |
| 41 PP_Var FileRefImpl::GetName() const { | |
| 42 if (!name_var_.get()) { | |
| 43 name_var_ = new StringVar( | |
| 44 PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), | |
| 45 create_info_.name); | |
| 46 } | |
| 47 return name_var_->GetPPVar(); | |
| 48 } | |
| 49 | |
| 50 PP_Var FileRefImpl::GetPath() const { | |
| 51 if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) | |
| 52 return PP_MakeUndefined(); | |
| 53 if (!path_var_.get()) { | |
| 54 path_var_ = new StringVar( | |
| 55 PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), | |
| 56 create_info_.path); | |
| 57 } | |
| 58 return path_var_->GetPPVar(); | |
| 59 } | |
| 60 | |
| 61 const PPB_FileRef_CreateInfo& FileRefImpl::GetCreateInfo() const { | |
| 62 return create_info_; | |
| 63 } | |
| 64 | |
| 65 } // namespace ppapi | |
| OLD | NEW |