diff options
29 files changed, 393 insertions, 126 deletions
diff --git a/chrome/browser/component_updater/ppapi_utils.cc b/chrome/browser/component_updater/ppapi_utils.cc index 8e0886e..de9dc84 100644 --- a/chrome/browser/component_updater/ppapi_utils.cc +++ b/chrome/browser/component_updater/ppapi_utils.cc @@ -124,6 +124,7 @@ bool IsSupportedPepperInterface(const char* name) { #include "ppapi/thunk/interfaces_ppb_private_flash.h" #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" #include "ppapi/thunk/interfaces_ppb_public_dev.h" + #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" #include "ppapi/thunk/interfaces_ppb_public_stable.h" #undef UNPROXIED_IFACE diff --git a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc index 4517e37..4cea3d8 100644 --- a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc @@ -33,7 +33,7 @@ PepperExternalFileRefBackend::~PepperExternalFileRefBackend() { int32_t PepperExternalFileRefBackend::MakeDirectory( ppapi::host::ReplyMessageContext reply_context, - bool make_ancestors) { + int32_t make_directory_flags) { // This operation isn't supported for external filesystems. return PP_ERROR_NOACCESS; } diff --git a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h index 525749d..70cacb5 100644 --- a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h +++ b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h @@ -28,7 +28,7 @@ class PepperExternalFileRefBackend : public PepperFileRefBackend { // PepperFileRefBackend overrides. virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context, - bool make_ancestors) OVERRIDE; + int32_t make_directory_flags) OVERRIDE; virtual int32_t Touch(ppapi::host::ReplyMessageContext context, PP_Time last_accessed_time, PP_Time last_modified_time) OVERRIDE; diff --git a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc b/content/browser/renderer_host/pepper/pepper_file_ref_host.cc index bf2fb76..0a94bce 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_ref_host.cc @@ -180,12 +180,12 @@ int32_t PepperFileRefHost::OnResourceMessageReceived( int32_t PepperFileRefHost::OnMakeDirectory( ppapi::host::HostMessageContext* context, - bool make_ancestors) { + int32_t make_directory_flags) { int32_t rv = CanCreate(); if (rv != PP_OK) return rv; - return backend_->MakeDirectory(context->MakeReplyMessageContext(), - make_ancestors); + return backend_->MakeDirectory( + context->MakeReplyMessageContext(), make_directory_flags); } int32_t PepperFileRefHost::OnTouch(ppapi::host::HostMessageContext* context, diff --git a/content/browser/renderer_host/pepper/pepper_file_ref_host.h b/content/browser/renderer_host/pepper/pepper_file_ref_host.h index 10d9a3e..9ae7931 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_ref_host.h @@ -29,7 +29,7 @@ class PepperFileRefBackend { virtual ~PepperFileRefBackend(); virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context, - bool make_ancestors) = 0; + int32_t make_directory_flags) = 0; virtual int32_t Touch(ppapi::host::ReplyMessageContext context, PP_Time last_accessed_time, PP_Time last_modified_time) = 0; @@ -89,7 +89,7 @@ class CONTENT_EXPORT PepperFileRefHost private: int32_t OnMakeDirectory(ppapi::host::HostMessageContext* context, - bool make_ancestors); + int32_t make_directory_flags); int32_t OnTouch(ppapi::host::HostMessageContext* context, PP_Time last_access_time, PP_Time last_modified_time); diff --git a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc index e57a237..3d19146 100644 --- a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc @@ -21,6 +21,7 @@ #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/c/ppb_file_ref.h" #include "ppapi/host/dispatch_host_message.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/proxy/ppapi_messages.h" @@ -92,14 +93,14 @@ void PepperInternalFileRefBackend::DidFinish( int32_t PepperInternalFileRefBackend::MakeDirectory( ppapi::host::ReplyMessageContext reply_context, - bool make_ancestors) { + int32_t make_directory_flags) { if (!GetFileSystemURL().is_valid()) return PP_ERROR_FAILED; GetFileSystemContext()->operation_runner()->CreateDirectory( GetFileSystemURL(), - false, - make_ancestors, + !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_EXCLUSIVE), + !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS), base::Bind(&PepperInternalFileRefBackend::DidFinish, weak_factory_.GetWeakPtr(), reply_context, diff --git a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h index 93dbab9..f75e32a 100644 --- a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h +++ b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h @@ -32,7 +32,7 @@ class PepperInternalFileRefBackend : public PepperFileRefBackend { // PepperFileRefBackend overrides. virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context, - bool make_ancestors) OVERRIDE; + int32_t make_directory_flags) OVERRIDE; virtual int32_t Touch(ppapi::host::ReplyMessageContext context, PP_Time last_accessed_time, PP_Time last_modified_time) OVERRIDE; diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index 700cba7..269b930 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -315,11 +315,12 @@ const void* InternalGetInterface(const char* name) { #define PROXIED_IFACE(iface_str, iface_struct) \ UNPROXIED_IFACE(iface_str, iface_struct) - #include "ppapi/thunk/interfaces_ppb_public_stable.h" - #include "ppapi/thunk/interfaces_ppb_public_dev.h" #include "ppapi/thunk/interfaces_ppb_private.h" - #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" #include "ppapi/thunk/interfaces_ppb_private_flash.h" + #include "ppapi/thunk/interfaces_ppb_private_no_permissions.h" + #include "ppapi/thunk/interfaces_ppb_public_dev.h" + #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" + #include "ppapi/thunk/interfaces_ppb_public_stable.h" #undef UNPROXIED_API #undef PROXIED_IFACE diff --git a/native_client_sdk/src/doc/devguide/coding/file-io.rst b/native_client_sdk/src/doc/devguide/coding/file-io.rst index fd2a38c..b63f3c8 100644 --- a/native_client_sdk/src/doc/devguide/coding/file-io.rst +++ b/native_client_sdk/src/doc/devguide/coding/file-io.rst @@ -548,7 +548,8 @@ Then the ``pp::FileRef::MakeDirectory`` function is called. .. naclcode:: - int32_t result = ref.MakeDirectory(pp::BlockUntilComplete()); + int32_t result = ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, pp::BlockUntilComplete()); if (result != PP_OK) { ShowErrorMessage("Make directory failed", result); return; diff --git a/native_client_sdk/src/examples/api/file_io/file_io.cc b/native_client_sdk/src/examples/api/file_io/file_io.cc index 2b2745d..ae8df85 100644 --- a/native_client_sdk/src/examples/api/file_io/file_io.cc +++ b/native_client_sdk/src/examples/api/file_io/file_io.cc @@ -312,7 +312,8 @@ class FileIoInstance : public pp::Instance { } pp::FileRef ref(file_system_, dir_name.c_str()); - int32_t result = ref.MakeDirectory(pp::BlockUntilComplete()); + int32_t result = ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, pp::BlockUntilComplete()); if (result != PP_OK) { ShowErrorMessage("Make directory failed", result); return; diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc index c7c52f4..64a1f47 100644 --- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc +++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc @@ -75,7 +75,8 @@ Error Html5Fs::Mkdir(const Path& path, int permissions) { return ENOENT; int32_t result = ppapi()->GetFileRefInterface()->MakeDirectory( - fileref_resource.pp_resource(), PP_FALSE, PP_BlockUntilComplete()); + fileref_resource.pp_resource(), PP_MAKEDIRECTORYFLAG_NONE, + PP_BlockUntilComplete()); if (result != PP_OK) return PPErrorToErrno(result); diff --git a/native_client_sdk/src/libraries/nacl_io/pepper/all_interfaces.h b/native_client_sdk/src/libraries/nacl_io/pepper/all_interfaces.h index c667802..6c6ec23 100644 --- a/native_client_sdk/src/libraries/nacl_io/pepper/all_interfaces.h +++ b/native_client_sdk/src/libraries/nacl_io/pepper/all_interfaces.h @@ -47,17 +47,17 @@ BEGIN_INTERFACE(FileIoInterface, PPB_FileIO_1_0, PPB_FILEIO_INTERFACE_1_0) const char*, int32_t, PP_CompletionCallback) END_INTERFACE(FileIoInterface, PPB_FileIO_1_0) -BEGIN_INTERFACE(FileRefInterface, PPB_FileRef_1_1, PPB_FILEREF_INTERFACE_1_1) +BEGIN_INTERFACE(FileRefInterface, PPB_FileRef_1_2, PPB_FILEREF_INTERFACE_1_2) METHOD2(FileRefInterface, PP_Resource, Create, PP_Resource, const char*) METHOD2(FileRefInterface, int32_t, Delete, PP_Resource, PP_CompletionCallback) METHOD1(FileRefInterface, PP_Var, GetName, PP_Resource) - METHOD3(FileRefInterface, int32_t, MakeDirectory, PP_Resource, PP_Bool, + METHOD3(FileRefInterface, int32_t, MakeDirectory, PP_Resource, int32_t, PP_CompletionCallback) METHOD3(FileRefInterface, int32_t, Query, PP_Resource, PP_FileInfo*, PP_CompletionCallback) METHOD3(FileRefInterface, int32_t, ReadDirectoryEntries, PP_Resource, const PP_ArrayOutput&, PP_CompletionCallback) -END_INTERFACE(FileRefInterface, PPB_FileRef_1_1) +END_INTERFACE(FileRefInterface, PPB_FileRef_1_2) BEGIN_INTERFACE(FileSystemInterface, PPB_FileSystem_1_0, PPB_FILESYSTEM_INTERFACE_1_0) diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc index eacb9c4..7b61f33 100644 --- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc +++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.cc @@ -500,7 +500,7 @@ PP_Var FakeFileRefInterface::GetName(PP_Resource file_ref) { } int32_t FakeFileRefInterface::MakeDirectory(PP_Resource directory_ref, - PP_Bool make_ancestors, + int32_t make_directory_flags, PP_CompletionCallback callback) { FakeFileRefResource* directory_ref_resource = core_interface_->resource_manager()->Get<FakeFileRefResource>( @@ -508,9 +508,9 @@ int32_t FakeFileRefInterface::MakeDirectory(PP_Resource directory_ref, if (directory_ref_resource == NULL) return PP_ERROR_BADRESOURCE; - // TODO(binji): We don't currently use make_ancestors==PP_TRUE in nacl_io, so + // TODO(binji): We don't currently use make_directory_flags in nacl_io, so // I won't bother implementing it. - if (make_ancestors == PP_TRUE) + if (make_directory_flags) return PP_ERROR_FAILED; FakeHtml5FsFilesystem* filesystem = directory_ref_resource->filesystem; diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h index 2ccad3a7..1c0325f 100644 --- a/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h +++ b/native_client_sdk/src/tests/nacl_io_test/fake_pepper_interface_html5_fs.h @@ -136,7 +136,7 @@ class FakeFileRefInterface : public nacl_io::FileRefInterface { virtual PP_Resource Create(PP_Resource file_system, const char* path); virtual PP_Var GetName(PP_Resource file_ref); virtual int32_t MakeDirectory(PP_Resource directory_ref, - PP_Bool make_ancestors, + int32_t make_directory_flags, PP_CompletionCallback callback); virtual int32_t Delete(PP_Resource file_ref, PP_CompletionCallback callback); virtual int32_t Query(PP_Resource file_ref, diff --git a/ppapi/api/ppb_file_ref.idl b/ppapi/api/ppb_file_ref.idl index d922647..7685836 100644 --- a/ppapi/api/ppb_file_ref.idl +++ b/ppapi/api/ppb_file_ref.idl @@ -10,7 +10,25 @@ label Chrome { M14 = 1.0, - M28 = 1.1 + M28 = 1.1, + [channel=dev] M34 = 1.2 +}; + +/** + * The <code>PP_MakeDirectoryFlags</code> enum contains flags used to control + * behavior of <code>PPB_FileRef.MakeDirectory()</code>. + */ +enum PP_MakeDirectoryFlags { + PP_MAKEDIRECTORYFLAG_NONE = 0 << 0, + + /** Requests that ancestor directories are created if they do not exist. */ + PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS = 1 << 0, + + /** + * Requests that the PPB_FileRef.MakeDirectory() call fails if the directory + * already exists. + */ + PP_MAKEDIRECTORYFLAG_EXCLUSIVE = 1 << 1 }; /** @@ -105,17 +123,40 @@ interface PPB_FileRef { * @param[in] make_ancestors A <code>PP_Bool</code> set to * <code>PP_TRUE</code> to make ancestor directories or <code>PP_FALSE</code> * if ancestor directories are not needed. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of MakeDirectory(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. * Succeeds if the directory already exists. Fails if ancestor directories * do not exist and <code>make_ancestors</code> was passed as * <code>PP_FALSE</code>. */ + [deprecate=1.2] int32_t MakeDirectory([in] PP_Resource directory_ref, [in] PP_Bool make_ancestors, [in] PP_CompletionCallback callback); /** + * MakeDirectory() makes a new directory in the file system according to the + * given <code>make_directory_flags</code>, which is a bit-mask of the + * <code>PP_MakeDirectoryFlags</code> values. It is not valid to make a + * directory in the external file system. + * + * @param[in] file_ref A <code>PP_Resource</code> corresponding to a file + * reference. + * @param[in] make_directory_flags A bit-mask of the + * <code>PP_MakeDirectoryFlags</code> values. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of MakeDirectory(). + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + [version=1.2] + int32_t MakeDirectory([in] PP_Resource directory_ref, + [in] int32_t make_directory_flags, + [in] PP_CompletionCallback callback); + + /** * Touch() Updates time stamps for a file. You must have write access to the * file if it exists in the external filesystem. * diff --git a/ppapi/c/ppb_file_ref.h b/ppapi/c/ppb_file_ref.h index 873ef18..035e3ee 100644 --- a/ppapi/c/ppb_file_ref.h +++ b/ppapi/c/ppb_file_ref.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_file_ref.idl modified Thu Aug 15 10:50:43 2013. */ +/* From ppb_file_ref.idl modified Wed Jan 8 12:40:12 2014. */ #ifndef PPAPI_C_PPB_FILE_REF_H_ #define PPAPI_C_PPB_FILE_REF_H_ @@ -20,6 +20,7 @@ #define PPB_FILEREF_INTERFACE_1_0 "PPB_FileRef;1.0" #define PPB_FILEREF_INTERFACE_1_1 "PPB_FileRef;1.1" +#define PPB_FILEREF_INTERFACE_1_2 "PPB_FileRef;1.2" /* dev */ #define PPB_FILEREF_INTERFACE PPB_FILEREF_INTERFACE_1_1 /** @@ -30,6 +31,28 @@ /** + * @addtogroup Enums + * @{ + */ +/** + * The <code>PP_MakeDirectoryFlags</code> enum contains flags used to control + * behavior of <code>PPB_FileRef.MakeDirectory()</code>. + */ +typedef enum { + PP_MAKEDIRECTORYFLAG_NONE = 0 << 0, + /** Requests that ancestor directories are created if they do not exist. */ + PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS = 1 << 0, + /** + * Requests that the PPB_FileRef.MakeDirectory() call fails if the directory + * already exists. + */ + PP_MAKEDIRECTORYFLAG_EXCLUSIVE = 1 << 1 +} PP_MakeDirectoryFlags; +/** + * @} + */ + +/** * @addtogroup Interfaces * @{ */ @@ -38,7 +61,7 @@ * a file system. This struct contains a <code>PP_FileSystemType</code> * identifier and a file path string. */ -struct PPB_FileRef_1_1 { +struct PPB_FileRef_1_2 { /* dev */ /** * Create() creates a weak pointer to a file in the given file system. File * paths are POSIX style. @@ -110,24 +133,22 @@ struct PPB_FileRef_1_1 { */ PP_Resource (*GetParent)(PP_Resource file_ref); /** - * MakeDirectory() makes a new directory in the file system as well as any - * parent directories if the <code>make_ancestors</code> argument is - * <code>PP_TRUE</code>. It is not valid to make a directory in the external - * file system. + * MakeDirectory() makes a new directory in the file system according to the + * given <code>make_directory_flags</code>, which is a bit-mask of the + * <code>PP_MakeDirectoryFlags</code> values. It is not valid to make a + * directory in the external file system. * * @param[in] file_ref A <code>PP_Resource</code> corresponding to a file * reference. - * @param[in] make_ancestors A <code>PP_Bool</code> set to - * <code>PP_TRUE</code> to make ancestor directories or <code>PP_FALSE</code> - * if ancestor directories are not needed. + * @param[in] make_directory_flags A bit-mask of the + * <code>PP_MakeDirectoryFlags</code> values. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of MakeDirectory(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. - * Succeeds if the directory already exists. Fails if ancestor directories - * do not exist and <code>make_ancestors</code> was passed as - * <code>PP_FALSE</code>. */ int32_t (*MakeDirectory)(PP_Resource directory_ref, - PP_Bool make_ancestors, + int32_t make_directory_flags, struct PP_CompletionCallback callback); /** * Touch() Updates time stamps for a file. You must have write access to the @@ -212,8 +233,6 @@ struct PPB_FileRef_1_1 { struct PP_CompletionCallback callback); }; -typedef struct PPB_FileRef_1_1 PPB_FileRef; - struct PPB_FileRef_1_0 { PP_Resource (*Create)(PP_Resource file_system, const char* path); PP_Bool (*IsFileRef)(PP_Resource resource); @@ -234,6 +253,35 @@ struct PPB_FileRef_1_0 { PP_Resource new_file_ref, struct PP_CompletionCallback callback); }; + +struct PPB_FileRef_1_1 { + PP_Resource (*Create)(PP_Resource file_system, const char* path); + PP_Bool (*IsFileRef)(PP_Resource resource); + PP_FileSystemType (*GetFileSystemType)(PP_Resource file_ref); + struct PP_Var (*GetName)(PP_Resource file_ref); + struct PP_Var (*GetPath)(PP_Resource file_ref); + PP_Resource (*GetParent)(PP_Resource file_ref); + int32_t (*MakeDirectory)(PP_Resource directory_ref, + PP_Bool make_ancestors, + struct PP_CompletionCallback callback); + int32_t (*Touch)(PP_Resource file_ref, + PP_Time last_access_time, + PP_Time last_modified_time, + struct PP_CompletionCallback callback); + int32_t (*Delete)(PP_Resource file_ref, + struct PP_CompletionCallback callback); + int32_t (*Rename)(PP_Resource file_ref, + PP_Resource new_file_ref, + struct PP_CompletionCallback callback); + int32_t (*Query)(PP_Resource file_ref, + struct PP_FileInfo* info, + struct PP_CompletionCallback callback); + int32_t (*ReadDirectoryEntries)(PP_Resource file_ref, + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_FileRef_1_1 PPB_FileRef; /** * @} */ diff --git a/ppapi/cpp/file_ref.cc b/ppapi/cpp/file_ref.cc index 0bc9487..f9294a7 100644 --- a/ppapi/cpp/file_ref.cc +++ b/ppapi/cpp/file_ref.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/file_ref.h" +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/directory_entry.h" @@ -22,6 +23,10 @@ template <> const char* interface_name<PPB_FileRef_1_1>() { return PPB_FILEREF_INTERFACE_1_1; } +template <> const char* interface_name<PPB_FileRef_1_2>() { + return PPB_FILEREF_INTERFACE_1_2; +} + } // namespace FileRef::FileRef(PP_Resource resource) : Resource(resource) { @@ -32,7 +37,10 @@ FileRef::FileRef(PassRef, PP_Resource resource) : Resource(PASS_REF, resource) { FileRef::FileRef(const FileSystem& file_system, const char* path) { - if (has_interface<PPB_FileRef_1_1>()) { + if (has_interface<PPB_FileRef_1_2>()) { + PassRefFromConstructor(get_interface<PPB_FileRef_1_2>()->Create( + file_system.pp_resource(), path)); + } else if (has_interface<PPB_FileRef_1_1>()) { PassRefFromConstructor(get_interface<PPB_FileRef_1_1>()->Create( file_system.pp_resource(), path)); } else if (has_interface<PPB_FileRef_1_0>()) { @@ -46,6 +54,8 @@ FileRef::FileRef(const FileRef& other) } PP_FileSystemType FileRef::GetFileSystemType() const { + if (has_interface<PPB_FileRef_1_2>()) + return get_interface<PPB_FileRef_1_2>()->GetFileSystemType(pp_resource()); if (has_interface<PPB_FileRef_1_1>()) return get_interface<PPB_FileRef_1_1>()->GetFileSystemType(pp_resource()); if (has_interface<PPB_FileRef_1_0>()) @@ -54,6 +64,10 @@ PP_FileSystemType FileRef::GetFileSystemType() const { } Var FileRef::GetName() const { + if (has_interface<PPB_FileRef_1_2>()) { + return Var(PASS_REF, + get_interface<PPB_FileRef_1_2>()->GetName(pp_resource())); + } if (has_interface<PPB_FileRef_1_1>()) { return Var(PASS_REF, get_interface<PPB_FileRef_1_1>()->GetName(pp_resource())); @@ -66,6 +80,10 @@ Var FileRef::GetName() const { } Var FileRef::GetPath() const { + if (has_interface<PPB_FileRef_1_2>()) { + return Var(PASS_REF, + get_interface<PPB_FileRef_1_2>()->GetPath(pp_resource())); + } if (has_interface<PPB_FileRef_1_1>()) { return Var(PASS_REF, get_interface<PPB_FileRef_1_1>()->GetPath(pp_resource())); @@ -78,6 +96,10 @@ Var FileRef::GetPath() const { } FileRef FileRef::GetParent() const { + if (has_interface<PPB_FileRef_1_2>()) { + return FileRef(PASS_REF, + get_interface<PPB_FileRef_1_2>()->GetParent(pp_resource())); + } if (has_interface<PPB_FileRef_1_1>()) { return FileRef(PASS_REF, get_interface<PPB_FileRef_1_1>()->GetParent(pp_resource())); @@ -89,34 +111,28 @@ FileRef FileRef::GetParent() const { return FileRef(); } -int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { - if (has_interface<PPB_FileRef_1_1>()) { - return get_interface<PPB_FileRef_1_1>()->MakeDirectory( - pp_resource(), - PP_FALSE, // make_ancestors - cc.pp_completion_callback()); - } - if (has_interface<PPB_FileRef_1_0>()) { - return get_interface<PPB_FileRef_1_0>()->MakeDirectory( +int32_t FileRef::MakeDirectory(int32_t make_directory_flags, + const CompletionCallback& cc) { + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->MakeDirectory( pp_resource(), - PP_FALSE, // make_ancestors + make_directory_flags, cc.pp_completion_callback()); } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t FileRef::MakeDirectoryIncludingAncestors( - const CompletionCallback& cc) { if (has_interface<PPB_FileRef_1_1>()) { + if (make_directory_flags & ~PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS) + return cc.MayForce(PP_ERROR_NOTSUPPORTED); return get_interface<PPB_FileRef_1_1>()->MakeDirectory( pp_resource(), - PP_TRUE, // make_ancestors + PP_FromBool(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS), cc.pp_completion_callback()); } if (has_interface<PPB_FileRef_1_0>()) { + if (make_directory_flags & ~PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS) + return cc.MayForce(PP_ERROR_NOTSUPPORTED); return get_interface<PPB_FileRef_1_0>()->MakeDirectory( pp_resource(), - PP_TRUE, // make_ancestors + PP_FromBool(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS), cc.pp_completion_callback()); } return cc.MayForce(PP_ERROR_NOINTERFACE); @@ -125,6 +141,11 @@ int32_t FileRef::MakeDirectoryIncludingAncestors( int32_t FileRef::Touch(PP_Time last_access_time, PP_Time last_modified_time, const CompletionCallback& cc) { + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->Touch( + pp_resource(), last_access_time, last_modified_time, + cc.pp_completion_callback()); + } if (has_interface<PPB_FileRef_1_1>()) { return get_interface<PPB_FileRef_1_1>()->Touch( pp_resource(), last_access_time, last_modified_time, @@ -139,6 +160,10 @@ int32_t FileRef::Touch(PP_Time last_access_time, } int32_t FileRef::Delete(const CompletionCallback& cc) { + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->Delete( + pp_resource(), cc.pp_completion_callback()); + } if (has_interface<PPB_FileRef_1_1>()) { return get_interface<PPB_FileRef_1_1>()->Delete( pp_resource(), cc.pp_completion_callback()); @@ -152,6 +177,10 @@ int32_t FileRef::Delete(const CompletionCallback& cc) { int32_t FileRef::Rename(const FileRef& new_file_ref, const CompletionCallback& cc) { + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->Rename( + pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); + } if (has_interface<PPB_FileRef_1_1>()) { return get_interface<PPB_FileRef_1_1>()->Rename( pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); @@ -164,19 +193,29 @@ int32_t FileRef::Rename(const FileRef& new_file_ref, } int32_t FileRef::Query(const CompletionCallbackWithOutput<PP_FileInfo>& cc) { - if (!has_interface<PPB_FileRef_1_1>()) - return cc.MayForce(PP_ERROR_NOINTERFACE); - return get_interface<PPB_FileRef_1_1>()->Query( - pp_resource(), cc.output(), cc.pp_completion_callback()); + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->Query( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } + if (has_interface<PPB_FileRef_1_1>()) { + return get_interface<PPB_FileRef_1_1>()->Query( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); } int32_t FileRef::ReadDirectoryEntries( const CompletionCallbackWithOutput<std::vector<DirectoryEntry> >& callback) { - if (!has_interface<PPB_FileRef_1_1>()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - return get_interface<PPB_FileRef_1_1>()->ReadDirectoryEntries( - pp_resource(), callback.output(), callback.pp_completion_callback()); + if (has_interface<PPB_FileRef_1_2>()) { + return get_interface<PPB_FileRef_1_2>()->ReadDirectoryEntries( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + if (has_interface<PPB_FileRef_1_1>()) { + return get_interface<PPB_FileRef_1_1>()->ReadDirectoryEntries( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); } } // namespace pp diff --git a/ppapi/cpp/file_ref.h b/ppapi/cpp/file_ref.h index 452d2a6..9f94088 100644 --- a/ppapi/cpp/file_ref.h +++ b/ppapi/cpp/file_ref.h @@ -90,30 +90,20 @@ class FileRef : public Resource { /// <code>PP_FileSystemType_External</code>. FileRef GetParent() const; - /// MakeDirectory() makes a new directory in the file system. It is not - /// valid to make a directory in the external file system. - /// <strong>Note:</strong> Use MakeDirectoryIncludingAncestors() to create - /// parent directories. - /// - /// @param[in] cc A <code>CompletionCallback</code> to be called upon - /// completion of MakeDirectory(). - /// - /// @return An int32_t containing an error code from <code>pp_errors.h</code>. - /// Succeeds if the directory already exists. Fails if ancestor - /// directortories do not exist (see MakeDirectoryIncludingAncestors for the - /// alternative). - int32_t MakeDirectory(const CompletionCallback& cc); - - /// MakeDirectoryIncludingAncestors() makes a new directory in the file - /// system as well as any parent directories. It is not valid to make a + /// MakeDirectory() makes a new directory in the file system according to the + /// given <code>make_directory_flags</code>, which is a bit-mask of the + /// <code>PP_MakeDirectoryFlags</code> values. It is not valid to make a /// directory in the external file system. /// + /// @param[in] make_directory_flags A bit-mask of the + /// <code>PP_MakeDirectoryFlags</code> values. + /// See <code>ppb_file_ref.h</code> for more details. /// @param[in] cc A <code>CompletionCallback</code> to be called upon - /// completion of MakeDirectoryIncludingAncestors(). + /// completion of MakeDirectory(). /// /// @return An int32_t containing an error code from <code>pp_errors.h</code>. - /// Succeeds if the directory already exists. - int32_t MakeDirectoryIncludingAncestors(const CompletionCallback& cc); + int32_t MakeDirectory(int32_t make_directory_flags, + const CompletionCallback& cc); /// Touch() Updates time stamps for a file. You must have write access to the /// file if it exists in the external filesystem. diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 7ac0227..5988173 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -145,6 +145,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileSystem_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_1; @@ -531,6 +532,70 @@ static int32_t Pnacl_M28_PPB_FileRef_ReadDirectoryEntries(PP_Resource file_ref, /* End wrapper methods for PPB_FileRef_1_1 */ +/* Begin wrapper methods for PPB_FileRef_1_2 */ + +static PP_Resource Pnacl_M34_PPB_FileRef_Create(PP_Resource file_system, const char* path) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->Create(file_system, path); +} + +static PP_Bool Pnacl_M34_PPB_FileRef_IsFileRef(PP_Resource resource) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->IsFileRef(resource); +} + +static PP_FileSystemType Pnacl_M34_PPB_FileRef_GetFileSystemType(PP_Resource file_ref) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->GetFileSystemType(file_ref); +} + +static void Pnacl_M34_PPB_FileRef_GetName(struct PP_Var* _struct_result, PP_Resource file_ref) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + *_struct_result = iface->GetName(file_ref); +} + +static void Pnacl_M34_PPB_FileRef_GetPath(struct PP_Var* _struct_result, PP_Resource file_ref) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + *_struct_result = iface->GetPath(file_ref); +} + +static PP_Resource Pnacl_M34_PPB_FileRef_GetParent(PP_Resource file_ref) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->GetParent(file_ref); +} + +static int32_t Pnacl_M34_PPB_FileRef_MakeDirectory(PP_Resource directory_ref, int32_t make_directory_flags, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->MakeDirectory(directory_ref, make_directory_flags, *callback); +} + +static int32_t Pnacl_M34_PPB_FileRef_Touch(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->Touch(file_ref, last_access_time, last_modified_time, *callback); +} + +static int32_t Pnacl_M34_PPB_FileRef_Delete(PP_Resource file_ref, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->Delete(file_ref, *callback); +} + +static int32_t Pnacl_M34_PPB_FileRef_Rename(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->Rename(file_ref, new_file_ref, *callback); +} + +static int32_t Pnacl_M34_PPB_FileRef_Query(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->Query(file_ref, info, *callback); +} + +static int32_t Pnacl_M34_PPB_FileRef_ReadDirectoryEntries(PP_Resource file_ref, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) { + const struct PPB_FileRef_1_2 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_2.real_iface; + return iface->ReadDirectoryEntries(file_ref, *output, *callback); +} + +/* End wrapper methods for PPB_FileRef_1_2 */ + /* Begin wrapper methods for PPB_FileSystem_1_0 */ static PP_Resource Pnacl_M14_PPB_FileSystem_Create(PP_Instance instance, PP_FileSystemType type) { @@ -4143,6 +4208,21 @@ static struct PPB_FileRef_1_1 Pnacl_Wrappers_PPB_FileRef_1_1 = { .ReadDirectoryEntries = (int32_t (*)(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_ReadDirectoryEntries }; +static struct PPB_FileRef_1_2 Pnacl_Wrappers_PPB_FileRef_1_2 = { + .Create = (PP_Resource (*)(PP_Resource file_system, const char* path))&Pnacl_M34_PPB_FileRef_Create, + .IsFileRef = (PP_Bool (*)(PP_Resource resource))&Pnacl_M34_PPB_FileRef_IsFileRef, + .GetFileSystemType = (PP_FileSystemType (*)(PP_Resource file_ref))&Pnacl_M34_PPB_FileRef_GetFileSystemType, + .GetName = (struct PP_Var (*)(PP_Resource file_ref))&Pnacl_M34_PPB_FileRef_GetName, + .GetPath = (struct PP_Var (*)(PP_Resource file_ref))&Pnacl_M34_PPB_FileRef_GetPath, + .GetParent = (PP_Resource (*)(PP_Resource file_ref))&Pnacl_M34_PPB_FileRef_GetParent, + .MakeDirectory = (int32_t (*)(PP_Resource directory_ref, int32_t make_directory_flags, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_MakeDirectory, + .Touch = (int32_t (*)(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_Touch, + .Delete = (int32_t (*)(PP_Resource file_ref, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_Delete, + .Rename = (int32_t (*)(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_Rename, + .Query = (int32_t (*)(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_Query, + .ReadDirectoryEntries = (int32_t (*)(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M34_PPB_FileRef_ReadDirectoryEntries +}; + static struct PPB_FileSystem_1_0 Pnacl_Wrappers_PPB_FileSystem_1_0 = { .Create = (PP_Resource (*)(PP_Instance instance, PP_FileSystemType type))&Pnacl_M14_PPB_FileSystem_Create, .IsFileSystem = (PP_Bool (*)(PP_Resource resource))&Pnacl_M14_PPB_FileSystem_IsFileSystem, @@ -5175,6 +5255,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_1 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_2 = { + .iface_macro = PPB_FILEREF_INTERFACE_1_2, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_FileRef_1_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileSystem_1_0 = { .iface_macro = PPB_FILESYSTEM_INTERFACE_1_0, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_FileSystem_1_0, @@ -5752,6 +5838,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_FileIO_1_1, &Pnacl_WrapperInfo_PPB_FileRef_1_0, &Pnacl_WrapperInfo_PPB_FileRef_1_1, + &Pnacl_WrapperInfo_PPB_FileRef_1_2, &Pnacl_WrapperInfo_PPB_FileSystem_1_0, &Pnacl_WrapperInfo_PPB_Graphics2D_1_0, &Pnacl_WrapperInfo_PPB_Graphics2D_1_1, diff --git a/ppapi/proxy/file_ref_resource.cc b/ppapi/proxy/file_ref_resource.cc index 7cd96bc..ec6662f 100644 --- a/ppapi/proxy/file_ref_resource.cc +++ b/ppapi/proxy/file_ref_resource.cc @@ -129,11 +129,11 @@ PP_Resource FileRefResource::GetParent() { } int32_t FileRefResource::MakeDirectory( - PP_Bool make_ancestors, + int32_t make_directory_flags, scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_MakeDirectoryReply>( BROWSER, - PpapiHostMsg_FileRef_MakeDirectory(PP_TRUE == make_ancestors), + PpapiHostMsg_FileRef_MakeDirectory(make_directory_flags), base::Bind(&FileRefResource::RunTrackedCallback, this, callback)); return PP_OK_COMPLETIONPENDING; } diff --git a/ppapi/proxy/file_ref_resource.h b/ppapi/proxy/file_ref_resource.h index f982438..96f71db 100644 --- a/ppapi/proxy/file_ref_resource.h +++ b/ppapi/proxy/file_ref_resource.h @@ -42,8 +42,8 @@ class PPAPI_PROXY_EXPORT FileRefResource virtual PP_Var GetPath() const OVERRIDE; virtual PP_Resource GetParent() OVERRIDE; virtual int32_t MakeDirectory( - PP_Bool make_ancestors, - scoped_refptr<TrackedCallback> callback) OVERRIDE; + int32_t make_directory_flags, + scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual int32_t Touch(PP_Time last_access_time, PP_Time last_modified_time, scoped_refptr<TrackedCallback> callback) OVERRIDE; diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 154ffc1..327d9be1 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -194,12 +194,8 @@ InterfaceList::InterfaceList() { #endif // !defined(OS_NACL) } { - // TODO(teravest): These lines should be uncommented when a dev channel - // interface is added. They're commented right now because they cause an - // unused variable warning. - // - // Permission current_required_permission = PERMISSION_DEV_CHANNEL; - // #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" + Permission current_required_permission = PERMISSION_DEV_CHANNEL; + #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" } #undef PROXIED_API diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 65d7ee2..fbccd54 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1256,7 +1256,7 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_FileRef_CreateInternal, // Requests that the browser create a directory at the location indicated by // the FileRef. IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileRef_MakeDirectory, - bool /* make_ancestors */) + int32_t /* make_directory_flags */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_FileRef_MakeDirectoryReply) // Requests that the browser update the last accessed and last modified times diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index f699ba1..ec547f1 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -296,7 +296,8 @@ std::string TestFileIO::TestOpenDirectory() { // Make a directory. pp::FileRef dir_ref(file_system, "/test_dir_open_directory"); - callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(dir_ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc index 0a10a32..015f54c 100644 --- a/ppapi/tests/test_file_ref.cc +++ b/ppapi/tests/test_file_ref.cc @@ -298,41 +298,59 @@ std::string TestFileRef::TestMakeDirectory() { CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); - // MakeDirectory. - pp::FileRef dir_ref(file_system, "/test_dir_make_directory"); - callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback())); + // Make a directory. + pp::FileRef dir_ref(file_system, "/dir_make_dir"); + callback.WaitForResult( + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); + CHECK_CALLBACK_BEHAVIOR(callback); + ASSERT_EQ(PP_OK, callback.result()); + + // Make a directory on the existing path without exclusive flag. + callback.WaitForResult( + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); - // MakeDirectory aborted. + // Making a directory should be aborted. int32_t rv = PP_ERROR_FAILED; { - rv = pp::FileRef(file_system, "/test_dir_make_abort") - .MakeDirectory(callback.GetCallback()); + rv = pp::FileRef(file_system, "/dir_make_dir_abort") + .MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()); } callback.WaitForAbortResult(rv); CHECK_CALLBACK_BEHAVIOR(callback); - // MakeDirectoryIncludingAncestors. - dir_ref = pp::FileRef(file_system, "/dir_make_dir_1/dir_make_dir_2"); + // Make nested directories. + dir_ref = pp::FileRef(file_system, "/dir_make_nested_dir_1/dir"); callback.WaitForResult( - dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback())); + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS, + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); - // MakeDirectoryIncludingAncestors aborted. - { - rv = pp::FileRef(file_system, "/dir_make_abort_1/dir_make_abort_2") - .MakeDirectoryIncludingAncestors(callback.GetCallback()); - } - callback.WaitForAbortResult(rv); + dir_ref = pp::FileRef(file_system, "/dir_make_nested_dir_2/dir"); + callback.WaitForResult( + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); + ASSERT_EQ(PP_ERROR_FILENOTFOUND, callback.result()); + + // Ensure there is no directory on the path to test exclusive cases. + dir_ref = pp::FileRef(file_system, "/dir_make_dir_exclusive"); + rv = DeleteDirectoryRecursively(&dir_ref); + ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND); + + // Make a directory exclusively. + callback.WaitForResult( + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_EXCLUSIVE, + callback.GetCallback())); + CHECK_CALLBACK_BEHAVIOR(callback); + ASSERT_EQ(PP_OK, callback.result()); - // MakeDirectory with nested path should fail. - dir_ref = pp::FileRef(file_system, "/dir_make_dir_3/dir_make_dir_4"); - callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult( + dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_EXCLUSIVE, + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); - ASSERT_NE(PP_OK, callback.result()); + ASSERT_EQ(PP_ERROR_FILEEXISTS, callback.result()); PASS(); } @@ -432,7 +450,8 @@ std::string TestFileRef::TestDeleteFileAndDirectory() { ASSERT_EQ(PP_OK, callback.result()); pp::FileRef dir_ref(file_system, "/dir_delete"); - callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(dir_ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -442,7 +461,8 @@ std::string TestFileRef::TestDeleteFileAndDirectory() { pp::FileRef nested_dir_ref(file_system, "/dir_delete_1/dir_delete_2"); callback.WaitForResult( - nested_dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback())); + nested_dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS, + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -496,7 +516,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() { ASSERT_EQ(PP_OK, callback.result()); pp::FileRef dir_ref(file_system, "/dir_rename"); - callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(dir_ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -508,7 +529,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() { pp::FileRef nested_dir_ref(file_system, "/dir_rename_1/dir_rename_2"); callback.WaitForResult( - nested_dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback())); + nested_dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS, + callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -615,7 +637,8 @@ std::string TestFileRef::TestFileNameEscaping() { std::string test_dir_path = "/dir_for_escaping_test"; // Create a directory in which to test. pp::FileRef test_dir_ref(file_system, test_dir_path.c_str()); - callback.WaitForResult(test_dir_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(test_dir_ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -663,7 +686,8 @@ std::string TestFileRef::TestReadDirectoryEntries() { int32_t rv = DeleteDirectoryRecursively(&test_dir); ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND); - callback.WaitForResult(test_dir.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(test_dir.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); @@ -690,7 +714,8 @@ std::string TestFileRef::TestReadDirectoryEntries() { buffer << test_dir_name << '/' << dir_prefix << i; pp::FileRef file_ref(file_system, buffer.str().c_str()); - callback.WaitForResult(file_ref.MakeDirectory(callback.GetCallback())); + callback.WaitForResult(file_ref.MakeDirectory( + PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback); ASSERT_EQ(PP_OK, callback.result()); diff --git a/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/ppapi/thunk/interfaces_ppb_public_dev_channel.h index 1f5861d..2d2519e 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev_channel.h +++ b/ppapi/thunk/interfaces_ppb_public_dev_channel.h @@ -8,6 +8,7 @@ #include "ppapi/thunk/interfaces_preamble.h" // Interfaces go here. +PROXIED_IFACE(PPB_FILEREF_INTERFACE_1_2, PPB_FileRef_1_2) PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1, PPB_MediaStreamVideoTrack_0_1) PROXIED_IFACE(PPB_VIDEOFRAME_INTERFACE_0_1, PPB_VideoFrame_0_1) diff --git a/ppapi/thunk/ppb_file_ref_api.h b/ppapi/thunk/ppb_file_ref_api.h index b473ae2..2a27af5e8 100644 --- a/ppapi/thunk/ppb_file_ref_api.h +++ b/ppapi/thunk/ppb_file_ref_api.h @@ -28,7 +28,7 @@ class PPAPI_THUNK_EXPORT PPB_FileRef_API { virtual PP_Var GetName() const = 0; virtual PP_Var GetPath() const = 0; virtual PP_Resource GetParent() = 0; - virtual int32_t MakeDirectory(PP_Bool make_ancestors, + virtual int32_t MakeDirectory(int32_t make_directory_flags, scoped_refptr<TrackedCallback> callback) = 0; virtual int32_t Touch(PP_Time last_access_time, PP_Time last_modified_time, diff --git a/ppapi/thunk/ppb_file_ref_thunk.cc b/ppapi/thunk/ppb_file_ref_thunk.cc index 64c90b5..ef31e922 100644 --- a/ppapi/thunk/ppb_file_ref_thunk.cc +++ b/ppapi/thunk/ppb_file_ref_thunk.cc @@ -87,8 +87,21 @@ int32_t MakeDirectory(PP_Resource directory_ref, EnterFileRef enter(directory_ref, callback, true); if (enter.failed()) return enter.retval(); - return enter.SetResult(enter.object()->MakeDirectory(make_ancestors, - enter.callback())); + int32_t flag = make_ancestors ? PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS + : PP_MAKEDIRECTORYFLAG_NONE; + return enter.SetResult(enter.object()->MakeDirectory( + flag, enter.callback())); +} + +int32_t MakeDirectory_1_2(PP_Resource directory_ref, + int32_t make_directory_flags, + PP_CompletionCallback callback) { + VLOG(4) << "PPB_FileRef::MakeDirectory()"; + EnterFileRef enter(directory_ref, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->MakeDirectory( + make_directory_flags, enter.callback())); } int32_t Touch(PP_Resource file_ref, @@ -180,6 +193,21 @@ const PPB_FileRef_1_1 g_ppb_file_ref_thunk_1_1 = { &ReadDirectoryEntries }; +const PPB_FileRef_1_2 g_ppb_file_ref_thunk_1_2 = { + &Create, + &IsFileRef, + &GetFileSystemType, + &GetName, + &GetPath, + &GetParent, + &MakeDirectory_1_2, + &Touch, + &Delete, + &Rename, + &Query, + &ReadDirectoryEntries +}; + const PPB_FileRefPrivate g_ppb_file_ref_private_thunk = { &GetAbsolutePath }; @@ -194,6 +222,10 @@ const PPB_FileRef_1_1* GetPPB_FileRef_1_1_Thunk() { return &g_ppb_file_ref_thunk_1_1; } +const PPB_FileRef_1_2* GetPPB_FileRef_1_2_Thunk() { + return &g_ppb_file_ref_thunk_1_2; +} + const PPB_FileRefPrivate_0_1* GetPPB_FileRefPrivate_0_1_Thunk() { return &g_ppb_file_ref_private_thunk; } diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index 86a328f..a85ce77 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -25,6 +25,7 @@ #include "ppapi/thunk/interfaces_ppb_private_flash.h" #include "ppapi/thunk/interfaces_ppb_public_stable.h" #include "ppapi/thunk/interfaces_ppb_public_dev.h" +#include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" #undef UNPROXIED_IFACE #undef PROXIED_IFACE |