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