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