| 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/cpp/file_ref.h" | 5 #include "ppapi/cpp/file_ref.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/cpp/completion_callback.h" | 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/cpp/file_system.h" | 9 #include "ppapi/cpp/file_system.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
| 11 | 11 |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 template <> const char* interface_name<PPB_FileRef>() { | 17 template <> const char* interface_name<PPB_FileRef>() { |
| 18 return PPB_FILEREF_INTERFACE; | 18 return PPB_FILEREF_INTERFACE; |
| 19 } | 19 } |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 FileRef::FileRef(PP_Resource resource) : Resource(resource) { | 23 FileRef::FileRef(PP_Resource resource) : Resource(resource) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 FileRef::FileRef(PassRef, PP_Resource resource) { | 26 FileRef::FileRef(PassRef, PP_Resource resource) : Resource(PASS_REF, resource) { |
| 27 PassRefFromConstructor(resource); | |
| 28 } | 27 } |
| 29 | 28 |
| 30 FileRef::FileRef(const FileSystem& file_system, | 29 FileRef::FileRef(const FileSystem& file_system, |
| 31 const char* path) { | 30 const char* path) { |
| 32 if (!has_interface<PPB_FileRef>()) | 31 if (!has_interface<PPB_FileRef>()) |
| 33 return; | 32 return; |
| 34 PassRefFromConstructor(get_interface<PPB_FileRef>()->Create( | 33 PassRefFromConstructor(get_interface<PPB_FileRef>()->Create( |
| 35 file_system.pp_resource(), path)); | 34 file_system.pp_resource(), path)); |
| 36 } | 35 } |
| 37 | 36 |
| 38 FileRef::FileRef(const FileRef& other) | 37 FileRef::FileRef(const FileRef& other) |
| 39 : Resource(other) { | 38 : Resource(other) { |
| 40 } | 39 } |
| 41 | 40 |
| 42 PP_FileSystemType FileRef::GetFileSystemType() const { | 41 PP_FileSystemType FileRef::GetFileSystemType() const { |
| 43 if (!has_interface<PPB_FileRef>()) | 42 if (!has_interface<PPB_FileRef>()) |
| 44 return PP_FILESYSTEMTYPE_EXTERNAL; | 43 return PP_FILESYSTEMTYPE_EXTERNAL; |
| 45 return get_interface<PPB_FileRef>()->GetFileSystemType(pp_resource()); | 44 return get_interface<PPB_FileRef>()->GetFileSystemType(pp_resource()); |
| 46 } | 45 } |
| 47 | 46 |
| 48 Var FileRef::GetName() const { | 47 Var FileRef::GetName() const { |
| 49 if (!has_interface<PPB_FileRef>()) | 48 if (!has_interface<PPB_FileRef>()) |
| 50 return Var(); | 49 return Var(); |
| 51 return Var(Var::PassRef(), | 50 return Var(PASS_REF, get_interface<PPB_FileRef>()->GetName(pp_resource())); |
| 52 get_interface<PPB_FileRef>()->GetName(pp_resource())); | |
| 53 } | 51 } |
| 54 | 52 |
| 55 Var FileRef::GetPath() const { | 53 Var FileRef::GetPath() const { |
| 56 if (!has_interface<PPB_FileRef>()) | 54 if (!has_interface<PPB_FileRef>()) |
| 57 return Var(); | 55 return Var(); |
| 58 return Var(Var::PassRef(), | 56 return Var(PASS_REF, get_interface<PPB_FileRef>()->GetPath(pp_resource())); |
| 59 get_interface<PPB_FileRef>()->GetPath(pp_resource())); | |
| 60 } | 57 } |
| 61 | 58 |
| 62 FileRef FileRef::GetParent() const { | 59 FileRef FileRef::GetParent() const { |
| 63 if (!has_interface<PPB_FileRef>()) | 60 if (!has_interface<PPB_FileRef>()) |
| 64 return FileRef(); | 61 return FileRef(); |
| 65 return FileRef(PassRef(), | 62 return FileRef(PASS_REF, |
| 66 get_interface<PPB_FileRef>()->GetParent( | 63 get_interface<PPB_FileRef>()->GetParent(pp_resource())); |
| 67 pp_resource())); | |
| 68 } | 64 } |
| 69 | 65 |
| 70 int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { | 66 int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { |
| 71 if (!has_interface<PPB_FileRef>()) | 67 if (!has_interface<PPB_FileRef>()) |
| 72 return cc.MayForce(PP_ERROR_NOINTERFACE); | 68 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 73 return get_interface<PPB_FileRef>()->MakeDirectory( | 69 return get_interface<PPB_FileRef>()->MakeDirectory( |
| 74 pp_resource(), | 70 pp_resource(), |
| 75 PP_FALSE, // make_ancestors | 71 PP_FALSE, // make_ancestors |
| 76 cc.pp_completion_callback()); | 72 cc.pp_completion_callback()); |
| 77 } | 73 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 105 | 101 |
| 106 int32_t FileRef::Rename(const FileRef& new_file_ref, | 102 int32_t FileRef::Rename(const FileRef& new_file_ref, |
| 107 const CompletionCallback& cc) { | 103 const CompletionCallback& cc) { |
| 108 if (!has_interface<PPB_FileRef>()) | 104 if (!has_interface<PPB_FileRef>()) |
| 109 return cc.MayForce(PP_ERROR_NOINTERFACE); | 105 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 110 return get_interface<PPB_FileRef>()->Rename( | 106 return get_interface<PPB_FileRef>()->Rename( |
| 111 pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); | 107 pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); |
| 112 } | 108 } |
| 113 | 109 |
| 114 } // namespace pp | 110 } // namespace pp |
| OLD | NEW |