| 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_1_0>() { |
| 18 return PPB_FILEREF_INTERFACE; | 18 return PPB_FILEREF_INTERFACE_1_0; |
| 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) : Resource(PASS_REF, resource) { | 26 FileRef::FileRef(PassRef, PP_Resource resource) : Resource(PASS_REF, resource) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 FileRef::FileRef(const FileSystem& file_system, | 29 FileRef::FileRef(const FileSystem& file_system, |
| 30 const char* path) { | 30 const char* path) { |
| 31 if (!has_interface<PPB_FileRef>()) | 31 if (!has_interface<PPB_FileRef_1_0>()) |
| 32 return; | 32 return; |
| 33 PassRefFromConstructor(get_interface<PPB_FileRef>()->Create( | 33 PassRefFromConstructor(get_interface<PPB_FileRef_1_0>()->Create( |
| 34 file_system.pp_resource(), path)); | 34 file_system.pp_resource(), path)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 FileRef::FileRef(const FileRef& other) | 37 FileRef::FileRef(const FileRef& other) |
| 38 : Resource(other) { | 38 : Resource(other) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 PP_FileSystemType FileRef::GetFileSystemType() const { | 41 PP_FileSystemType FileRef::GetFileSystemType() const { |
| 42 if (!has_interface<PPB_FileRef>()) | 42 if (!has_interface<PPB_FileRef_1_0>()) |
| 43 return PP_FILESYSTEMTYPE_EXTERNAL; | 43 return PP_FILESYSTEMTYPE_EXTERNAL; |
| 44 return get_interface<PPB_FileRef>()->GetFileSystemType(pp_resource()); | 44 return get_interface<PPB_FileRef_1_0>()->GetFileSystemType(pp_resource()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 Var FileRef::GetName() const { | 47 Var FileRef::GetName() const { |
| 48 if (!has_interface<PPB_FileRef>()) | 48 if (!has_interface<PPB_FileRef_1_0>()) |
| 49 return Var(); | 49 return Var(); |
| 50 return Var(PASS_REF, get_interface<PPB_FileRef>()->GetName(pp_resource())); | 50 return Var(PASS_REF, |
| 51 get_interface<PPB_FileRef_1_0>()->GetName(pp_resource())); |
| 51 } | 52 } |
| 52 | 53 |
| 53 Var FileRef::GetPath() const { | 54 Var FileRef::GetPath() const { |
| 54 if (!has_interface<PPB_FileRef>()) | 55 if (!has_interface<PPB_FileRef_1_0>()) |
| 55 return Var(); | 56 return Var(); |
| 56 return Var(PASS_REF, get_interface<PPB_FileRef>()->GetPath(pp_resource())); | 57 return Var(PASS_REF, |
| 58 get_interface<PPB_FileRef_1_0>()->GetPath(pp_resource())); |
| 57 } | 59 } |
| 58 | 60 |
| 59 FileRef FileRef::GetParent() const { | 61 FileRef FileRef::GetParent() const { |
| 60 if (!has_interface<PPB_FileRef>()) | 62 if (!has_interface<PPB_FileRef_1_0>()) |
| 61 return FileRef(); | 63 return FileRef(); |
| 62 return FileRef(PASS_REF, | 64 return FileRef(PASS_REF, |
| 63 get_interface<PPB_FileRef>()->GetParent(pp_resource())); | 65 get_interface<PPB_FileRef_1_0>()->GetParent(pp_resource())); |
| 64 } | 66 } |
| 65 | 67 |
| 66 int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { | 68 int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { |
| 67 if (!has_interface<PPB_FileRef>()) | 69 if (!has_interface<PPB_FileRef_1_0>()) |
| 68 return cc.MayForce(PP_ERROR_NOINTERFACE); | 70 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 69 return get_interface<PPB_FileRef>()->MakeDirectory( | 71 return get_interface<PPB_FileRef_1_0>()->MakeDirectory( |
| 70 pp_resource(), | 72 pp_resource(), |
| 71 PP_FALSE, // make_ancestors | 73 PP_FALSE, // make_ancestors |
| 72 cc.pp_completion_callback()); | 74 cc.pp_completion_callback()); |
| 73 } | 75 } |
| 74 | 76 |
| 75 int32_t FileRef::MakeDirectoryIncludingAncestors( | 77 int32_t FileRef::MakeDirectoryIncludingAncestors( |
| 76 const CompletionCallback& cc) { | 78 const CompletionCallback& cc) { |
| 77 if (!has_interface<PPB_FileRef>()) | 79 if (!has_interface<PPB_FileRef_1_0>()) |
| 78 return cc.MayForce(PP_ERROR_NOINTERFACE); | 80 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 79 return get_interface<PPB_FileRef>()->MakeDirectory( | 81 return get_interface<PPB_FileRef_1_0>()->MakeDirectory( |
| 80 pp_resource(), | 82 pp_resource(), |
| 81 PP_TRUE, // make_ancestors | 83 PP_TRUE, // make_ancestors |
| 82 cc.pp_completion_callback()); | 84 cc.pp_completion_callback()); |
| 83 } | 85 } |
| 84 | 86 |
| 85 int32_t FileRef::Touch(PP_Time last_access_time, | 87 int32_t FileRef::Touch(PP_Time last_access_time, |
| 86 PP_Time last_modified_time, | 88 PP_Time last_modified_time, |
| 87 const CompletionCallback& cc) { | 89 const CompletionCallback& cc) { |
| 88 if (!has_interface<PPB_FileRef>()) | 90 if (!has_interface<PPB_FileRef_1_0>()) |
| 89 return cc.MayForce(PP_ERROR_NOINTERFACE); | 91 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 90 return get_interface<PPB_FileRef>()->Touch( | 92 return get_interface<PPB_FileRef_1_0>()->Touch( |
| 91 pp_resource(), last_access_time, last_modified_time, | 93 pp_resource(), last_access_time, last_modified_time, |
| 92 cc.pp_completion_callback()); | 94 cc.pp_completion_callback()); |
| 93 } | 95 } |
| 94 | 96 |
| 95 int32_t FileRef::Delete(const CompletionCallback& cc) { | 97 int32_t FileRef::Delete(const CompletionCallback& cc) { |
| 96 if (!has_interface<PPB_FileRef>()) | 98 if (!has_interface<PPB_FileRef_1_0>()) |
| 97 return cc.MayForce(PP_ERROR_NOINTERFACE); | 99 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 98 return get_interface<PPB_FileRef>()->Delete( | 100 return get_interface<PPB_FileRef_1_0>()->Delete( |
| 99 pp_resource(), cc.pp_completion_callback()); | 101 pp_resource(), cc.pp_completion_callback()); |
| 100 } | 102 } |
| 101 | 103 |
| 102 int32_t FileRef::Rename(const FileRef& new_file_ref, | 104 int32_t FileRef::Rename(const FileRef& new_file_ref, |
| 103 const CompletionCallback& cc) { | 105 const CompletionCallback& cc) { |
| 104 if (!has_interface<PPB_FileRef>()) | 106 if (!has_interface<PPB_FileRef_1_0>()) |
| 105 return cc.MayForce(PP_ERROR_NOINTERFACE); | 107 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 106 return get_interface<PPB_FileRef>()->Rename( | 108 return get_interface<PPB_FileRef_1_0>()->Rename( |
| 107 pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); | 109 pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace pp | 112 } // namespace pp |
| OLD | NEW |