summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/dev/ppb_directory_reader_dev.idl46
-rw-r--r--ppapi/api/pp_directory_entry.idl14
-rw-r--r--ppapi/api/ppb_file_ref.idl19
-rw-r--r--ppapi/c/dev/ppb_directory_reader_dev.h78
-rw-r--r--ppapi/c/pp_directory_entry.h37
-rw-r--r--ppapi/c/ppb_file_ref.h20
-rw-r--r--ppapi/cpp/dev/directory_entry_dev.h89
-rw-r--r--ppapi/cpp/dev/directory_reader_dev.cc44
-rw-r--r--ppapi/cpp/dev/directory_reader_dev.h56
-rw-r--r--ppapi/cpp/dev/file_chooser_dev.h2
-rw-r--r--ppapi/cpp/directory_entry.cc (renamed from ppapi/cpp/dev/directory_entry_dev.cc)24
-rw-r--r--ppapi/cpp/directory_entry.h127
-rw-r--r--ppapi/cpp/file_ref.cc10
-rw-r--r--ppapi/cpp/file_ref.h26
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c42
-rw-r--r--ppapi/ppapi_proxy.gypi2
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/ppapi_sources.gypi9
-rw-r--r--ppapi/proxy/directory_reader_resource.cc108
-rw-r--r--ppapi/proxy/directory_reader_resource.h58
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h20
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.cc177
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.h27
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc8
-rw-r--r--ppapi/proxy/resource_creation_proxy.h2
-rw-r--r--ppapi/shared_impl/resource.h1
-rw-r--r--ppapi/tests/all_c_includes.h1
-rw-r--r--ppapi/tests/all_cpp_includes.h3
-rw-r--r--ppapi/tests/test_directory_reader.cc182
-rw-r--r--ppapi/tests/test_directory_reader.h31
-rw-r--r--ppapi/tests/test_file_ref.cc160
-rw-r--r--ppapi/tests/test_file_ref.h3
-rw-r--r--ppapi/tests/test_file_system.cc2
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
-rw-r--r--ppapi/thunk/ppb_directory_reader_api.h28
-rw-r--r--ppapi/thunk/ppb_directory_reader_thunk.cc61
-rw-r--r--ppapi/thunk/ppb_file_ref_api.h21
-rw-r--r--ppapi/thunk/ppb_file_ref_thunk.cc13
-rw-r--r--ppapi/thunk/resource_creation_api.h2
40 files changed, 659 insertions, 899 deletions
diff --git a/ppapi/api/dev/ppb_directory_reader_dev.idl b/ppapi/api/dev/ppb_directory_reader_dev.idl
deleted file mode 100644
index 5ba6065..0000000
--- a/ppapi/api/dev/ppb_directory_reader_dev.idl
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * This file defines the <code>PPB_DirectoryReader_Dev</code> interface.
- */
-
-label Chrome {
- M27 = 0.6
-};
-
-[assert_size(8)]
-struct PP_DirectoryEntry_Dev {
- PP_Resource file_ref;
- PP_FileType file_type;
-};
-
-interface PPB_DirectoryReader_Dev {
- // Creates a DirectoryReader for the given directory. Upon success, the
- // corresponding directory is classified as "in use" by the resulting
- // DirectoryReader object until such time as the DirectoryReader object is
- // destroyed.
- PP_Resource Create([in] PP_Resource directory_ref);
-
- // Returns PP_TRUE if the given resource is a DirectoryReader. Returns
- // PP_FALSE if the resource is invalid or some type other than a
- // DirectoryReader.
- PP_Bool IsDirectoryReader([in] PP_Resource resource);
-
- // Reads all entries in the directory.
- //
- // @param[in] directory_reader A <code>PP_Resource</code>
- // corresponding to a directory reader resource.
- // @param[in] output An output array which will receive
- // <code>PP_DirectoryEntry_Dev</code> objects on success.
- // @param[in] callback A <code>PP_CompletionCallback</code> to run on
- // completion.
- //
- // @return An error code from <code>pp_errors.h</code>.
- //
- int32_t ReadEntries([in] PP_Resource directory_reader,
- [in] PP_ArrayOutput output,
- [in] PP_CompletionCallback callback);
-};
diff --git a/ppapi/api/pp_directory_entry.idl b/ppapi/api/pp_directory_entry.idl
new file mode 100644
index 0000000..4b12c34
--- /dev/null
+++ b/ppapi/api/pp_directory_entry.idl
@@ -0,0 +1,14 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * This file defines the <code>PP_DirectoryEntry</code> struct.
+ */
+
+[assert_size(8)]
+struct PP_DirectoryEntry {
+ PP_Resource file_ref;
+ PP_FileType file_type;
+};
diff --git a/ppapi/api/ppb_file_ref.idl b/ppapi/api/ppb_file_ref.idl
index cc08f8e..e783027 100644
--- a/ppapi/api/ppb_file_ref.idl
+++ b/ppapi/api/ppb_file_ref.idl
@@ -168,7 +168,7 @@ interface PPB_FileRef {
[in] PP_Resource new_file_ref,
[in] PP_CompletionCallback callback);
- /*
+ /**
* Query() queries info about a file or directory. You must have access to
* read this file or directory if it exists in the external filesystem.
*
@@ -185,5 +185,22 @@ interface PPB_FileRef {
int32_t Query([in] PP_Resource file_ref,
[out] PP_FileInfo info,
[in] PP_CompletionCallback callback);
+
+ /**
+ * ReadDirectoryEntries() reads all entries in a directory.
+ *
+ * @param[in] file_ref A <code>PP_Resource</code> corresponding to a directory
+ * reference.
+ * @param[in] output An output array which will receive
+ * <code>PP_DirectoryEntry</code> objects on success.
+ * @param[in] callback A <code>PP_CompletionCallback</code> to run on
+ * completion.
+ *
+ * @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ */
+ [version=1.1]
+ int32_t ReadDirectoryEntries([in] PP_Resource file_ref,
+ [in] PP_ArrayOutput output,
+ [in] PP_CompletionCallback callback);
};
diff --git a/ppapi/c/dev/ppb_directory_reader_dev.h b/ppapi/c/dev/ppb_directory_reader_dev.h
deleted file mode 100644
index 060e489..0000000
--- a/ppapi/c/dev/ppb_directory_reader_dev.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* From dev/ppb_directory_reader_dev.idl modified Fri Feb 15 16:46:46 2013. */
-
-#ifndef PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_
-#define PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_
-
-#include "ppapi/c/pp_array_output.h"
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_file_info.h"
-#include "ppapi/c/pp_macros.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/pp_stdint.h"
-
-#define PPB_DIRECTORYREADER_DEV_INTERFACE_0_6 "PPB_DirectoryReader(Dev);0.6"
-#define PPB_DIRECTORYREADER_DEV_INTERFACE PPB_DIRECTORYREADER_DEV_INTERFACE_0_6
-
-/**
- * @file
- *
- * This file defines the <code>PPB_DirectoryReader_Dev</code> interface.
- */
-
-
-/**
- * @addtogroup Structs
- * @{
- */
-struct PP_DirectoryEntry_Dev {
- PP_Resource file_ref;
- PP_FileType file_type;
-};
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DirectoryEntry_Dev, 8);
-/**
- * @}
- */
-
-/**
- * @addtogroup Interfaces
- * @{
- */
-struct PPB_DirectoryReader_Dev_0_6 {
- /* Creates a DirectoryReader for the given directory. Upon success, the
- * corresponding directory is classified as "in use" by the resulting
- * DirectoryReader object until such time as the DirectoryReader object is
- * destroyed. */
- PP_Resource (*Create)(PP_Resource directory_ref);
- /* Returns PP_TRUE if the given resource is a DirectoryReader. Returns
- * PP_FALSE if the resource is invalid or some type other than a
- * DirectoryReader. */
- PP_Bool (*IsDirectoryReader)(PP_Resource resource);
- /* Reads all entries in the directory.
- *
- * @param[in] directory_reader A <code>PP_Resource</code>
- * corresponding to a directory reader resource.
- * @param[in] output An output array which will receive
- * <code>PP_DirectoryEntry_Dev</code> objects on success.
- * @param[in] callback A <code>PP_CompletionCallback</code> to run on
- * completion.
- *
- * @return An error code from <code>pp_errors.h</code>.
- */
- int32_t (*ReadEntries)(PP_Resource directory_reader,
- struct PP_ArrayOutput output,
- struct PP_CompletionCallback callback);
-};
-
-typedef struct PPB_DirectoryReader_Dev_0_6 PPB_DirectoryReader_Dev;
-/**
- * @}
- */
-
-#endif /* PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ */
-
diff --git a/ppapi/c/pp_directory_entry.h b/ppapi/c/pp_directory_entry.h
new file mode 100644
index 0000000..4bf6fb3
--- /dev/null
+++ b/ppapi/c/pp_directory_entry.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* From pp_directory_entry.idl modified Tue Apr 30 05:44:50 2013. */
+
+#ifndef PPAPI_C_PP_DIRECTORY_ENTRY_H_
+#define PPAPI_C_PP_DIRECTORY_ENTRY_H_
+
+#include "ppapi/c/pp_file_info.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+
+/**
+ * @file
+ *
+ * This file defines the <code>PP_DirectoryEntry</code> struct.
+ */
+
+
+/**
+ * @addtogroup Structs
+ * @{
+ */
+struct PP_DirectoryEntry {
+ PP_Resource file_ref;
+ PP_FileType file_type;
+};
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DirectoryEntry, 8);
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_PP_DIRECTORY_ENTRY_H_ */
+
diff --git a/ppapi/c/ppb_file_ref.h b/ppapi/c/ppb_file_ref.h
index 910fd80..951c30d 100644
--- a/ppapi/c/ppb_file_ref.h
+++ b/ppapi/c/ppb_file_ref.h
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-/* From ppb_file_ref.idl modified Thu Mar 7 12:02:53 2013. */
+/* From ppb_file_ref.idl modified Thu May 2 16:22:57 2013. */
#ifndef PPAPI_C_PPB_FILE_REF_H_
#define PPAPI_C_PPB_FILE_REF_H_
+#include "ppapi/c/pp_array_output.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_file_info.h"
@@ -178,7 +179,7 @@ struct PPB_FileRef_1_1 {
int32_t (*Rename)(PP_Resource file_ref,
PP_Resource new_file_ref,
struct PP_CompletionCallback callback);
- /*
+ /**
* Query() queries info about a file or directory. You must have access to
* read this file or directory if it exists in the external filesystem.
*
@@ -194,6 +195,21 @@ struct PPB_FileRef_1_1 {
int32_t (*Query)(PP_Resource file_ref,
struct PP_FileInfo* info,
struct PP_CompletionCallback callback);
+ /**
+ * ReadDirectoryEntries() reads all entries in a directory.
+ *
+ * @param[in] file_ref A <code>PP_Resource</code> corresponding to a directory
+ * reference.
+ * @param[in] output An output array which will receive
+ * <code>PP_DirectoryEntry</code> objects on success.
+ * @param[in] callback A <code>PP_CompletionCallback</code> to run on
+ * completion.
+ *
+ * @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ */
+ 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/dev/directory_entry_dev.h b/ppapi/cpp/dev/directory_entry_dev.h
deleted file mode 100644
index f24fd38..0000000
--- a/ppapi/cpp/dev/directory_entry_dev.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_
-#define PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_
-
-#include <vector>
-
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
-#include "ppapi/c/pp_array_output.h"
-#include "ppapi/cpp/array_output.h"
-#include "ppapi/cpp/file_ref.h"
-#include "ppapi/cpp/pass_ref.h"
-#include "ppapi/cpp/output_traits.h"
-
-namespace pp {
-
-class DirectoryEntry_Dev {
- public:
- DirectoryEntry_Dev();
- DirectoryEntry_Dev(PassRef, const PP_DirectoryEntry_Dev& data);
- DirectoryEntry_Dev(const DirectoryEntry_Dev& other);
-
- ~DirectoryEntry_Dev();
-
- DirectoryEntry_Dev& operator=(const DirectoryEntry_Dev& other);
-
- // Returns true if the DirectoryEntry is invalid or uninitialized.
- bool is_null() const { return !data_.file_ref; }
-
- // Returns the FileRef held by this DirectoryEntry.
- FileRef file_ref() const { return FileRef(data_.file_ref); }
-
- // Returns the type of the file referenced by this DirectoryEntry.
- PP_FileType file_type() const { return data_.file_type; }
-
- private:
- PP_DirectoryEntry_Dev data_;
-};
-
-namespace internal {
-
-class DirectoryEntryArrayOutputAdapterWithStorage
- : public ArrayOutputAdapter<PP_DirectoryEntry_Dev> {
- public:
- DirectoryEntryArrayOutputAdapterWithStorage();
- virtual ~DirectoryEntryArrayOutputAdapterWithStorage();
-
- // Returns the final array of resource objects, converting the
- // PP_DirectoryEntry_Dev written by the browser to pp::DirectoryEntry_Dev
- // objects.
- //
- // This function should only be called once or we would end up converting
- // the array more than once, which would mess up the refcounting.
- std::vector<DirectoryEntry_Dev>& output();
-
- private:
- // The browser will write the PP_DirectoryEntry_Devs into this array.
- std::vector<PP_DirectoryEntry_Dev> temp_storage_;
-
- // When asked for the output, the PP_DirectoryEntry_Devs above will be
- // converted to the pp::DirectoryEntry_Devs in this array for passing to the
- // calling code.
- std::vector<DirectoryEntry_Dev> output_storage_;
-};
-
-// A specialization of CallbackOutputTraits to provide the callback system the
-// information on how to handle vectors of pp::DirectoryEntry_Dev. This converts
-// PP_DirectoryEntry_Dev to pp::DirectoryEntry_Dev when passing to the plugin.
-template <>
-struct CallbackOutputTraits< std::vector<DirectoryEntry_Dev> > {
- typedef PP_ArrayOutput APIArgType;
- typedef DirectoryEntryArrayOutputAdapterWithStorage StorageType;
-
- static inline APIArgType StorageToAPIArg(StorageType& t) {
- return t.pp_array_output();
- }
-
- static inline std::vector<DirectoryEntry_Dev>& StorageToPluginArg(
- StorageType& t) {
- return t.output();
- }
-};
-
-} // namespace internal
-} // namespace pp
-
-#endif // PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_
diff --git a/ppapi/cpp/dev/directory_reader_dev.cc b/ppapi/cpp/dev/directory_reader_dev.cc
deleted file mode 100644
index aebdca5..0000000
--- a/ppapi/cpp/dev/directory_reader_dev.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/cpp/dev/directory_reader_dev.h"
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/cpp/completion_callback.h"
-#include "ppapi/cpp/dev/directory_entry_dev.h"
-#include "ppapi/cpp/file_ref.h"
-#include "ppapi/cpp/module.h"
-#include "ppapi/cpp/module_impl.h"
-
-namespace pp {
-
-namespace {
-
-template <> const char* interface_name<PPB_DirectoryReader_Dev_0_6>() {
- return PPB_DIRECTORYREADER_DEV_INTERFACE_0_6;
-}
-
-} // namespace
-
-DirectoryReader_Dev::DirectoryReader_Dev(const FileRef& directory_ref) {
- if (!has_interface<PPB_DirectoryReader_Dev_0_6>())
- return;
- PassRefFromConstructor(get_interface<PPB_DirectoryReader_Dev_0_6>()->Create(
- directory_ref.pp_resource()));
-}
-
-DirectoryReader_Dev::DirectoryReader_Dev(const DirectoryReader_Dev& other)
- : Resource(other) {
-}
-
-int32_t DirectoryReader_Dev::ReadEntries(
- const CompletionCallbackWithOutput< std::vector<DirectoryEntry_Dev> >&
- callback) {
- if (!has_interface<PPB_DirectoryReader_Dev_0_6>())
- return callback.MayForce(PP_ERROR_NOINTERFACE);
- return get_interface<PPB_DirectoryReader_Dev_0_6>()->ReadEntries(
- pp_resource(), callback.output(), callback.pp_completion_callback());
-}
-
-} // namespace pp
diff --git a/ppapi/cpp/dev/directory_reader_dev.h b/ppapi/cpp/dev/directory_reader_dev.h
deleted file mode 100644
index cd2ce78..0000000
--- a/ppapi/cpp/dev/directory_reader_dev.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_CPP_DEV_DIRECTORY_READER_DEV_H_
-#define PPAPI_CPP_DEV_DIRECTORY_READER_DEV_H_
-
-#include <vector>
-
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
-#include "ppapi/cpp/resource.h"
-
-namespace pp {
-
-class DirectoryEntry_Dev;
-class FileRef;
-template<typename T> class CompletionCallbackWithOutput;
-
-class DirectoryReader_Dev : public Resource {
- public:
- /// A constructor that creates a DirectoryReader resource for the given
- /// directory.
- ///
- /// @param[in] directory_ref A <code>PP_Resource</code> corresponding to the
- /// directory reference to be read.
- explicit DirectoryReader_Dev(const FileRef& directory_ref);
-
- DirectoryReader_Dev(const DirectoryReader_Dev& other);
-
- /// ReadEntries() Reads all entries in the directory.
- ///
- /// @param[in] cc A <code>CompletionCallbackWithOutput</code> to be called
- /// upon completion of ReadEntries(). On success, the directory entries will
- /// be passed to the given function.
- ///
- /// Normally you would use a CompletionCallbackFactory to allow callbacks to
- /// be bound to your class. See completion_callback_factory.h for more
- /// discussion on how to use this. Your callback will generally look like:
- ///
- /// @code
- /// void OnReadEntries(int32_t result,
- /// const std::vector<DirectoryEntry_Dev>& entries) {
- /// if (result == PP_OK)
- /// // use entries...
- /// }
- /// @endcode
- ///
- /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
- int32_t ReadEntries(
- const CompletionCallbackWithOutput< std::vector<DirectoryEntry_Dev> >&
- callback);
-};
-
-} // namespace pp
-
-#endif // PPAPI_CPP_DIRECTORY_READER_H_
diff --git a/ppapi/cpp/dev/file_chooser_dev.h b/ppapi/cpp/dev/file_chooser_dev.h
index 10b0ba0..3d5ee00 100644
--- a/ppapi/cpp/dev/file_chooser_dev.h
+++ b/ppapi/cpp/dev/file_chooser_dev.h
@@ -34,7 +34,7 @@ class FileChooser_Dev : public Resource {
/// (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file">
/// tag, a PPB_FileChooser_Dev instance cannot be used to select a directory.
/// In order to get the list of files in a directory, the
- /// PPB_DirectoryReader_Dev interface must be used.
+ /// PPB_FileRef::ReadDirectoryEntries interface must be used.
///
/// @param accept_types A comma-separated list of MIME types and file
/// extensions such as "audio/ *,text/plain,.html" (note there should be
diff --git a/ppapi/cpp/dev/directory_entry_dev.cc b/ppapi/cpp/directory_entry.cc
index 7d53890..c8e2b9d 100644
--- a/ppapi/cpp/dev/directory_entry_dev.cc
+++ b/ppapi/cpp/directory_entry.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ppapi/cpp/dev/directory_entry_dev.h"
+#include "ppapi/cpp/directory_entry.h"
#include <string.h>
@@ -11,30 +11,30 @@
namespace pp {
-DirectoryEntry_Dev::DirectoryEntry_Dev() {
+DirectoryEntry::DirectoryEntry() {
memset(&data_, 0, sizeof(data_));
}
-DirectoryEntry_Dev::DirectoryEntry_Dev(
- PassRef, const PP_DirectoryEntry_Dev& data) {
+DirectoryEntry::DirectoryEntry(
+ PassRef, const PP_DirectoryEntry& data) {
data_.file_ref = data.file_ref;
data_.file_type = data.file_type;
}
-DirectoryEntry_Dev::DirectoryEntry_Dev(const DirectoryEntry_Dev& other) {
+DirectoryEntry::DirectoryEntry(const DirectoryEntry& other) {
data_.file_ref = other.data_.file_ref;
data_.file_type = other.data_.file_type;
if (data_.file_ref)
Module::Get()->core()->AddRefResource(data_.file_ref);
}
-DirectoryEntry_Dev::~DirectoryEntry_Dev() {
+DirectoryEntry::~DirectoryEntry() {
if (data_.file_ref)
Module::Get()->core()->ReleaseResource(data_.file_ref);
}
-DirectoryEntry_Dev& DirectoryEntry_Dev::operator=(
- const DirectoryEntry_Dev& other) {
+DirectoryEntry& DirectoryEntry::operator=(
+ const DirectoryEntry& other) {
if (data_.file_ref)
Module::Get()->core()->ReleaseResource(data_.file_ref);
data_ = other.data_;
@@ -54,19 +54,19 @@ DirectoryEntryArrayOutputAdapterWithStorage::
~DirectoryEntryArrayOutputAdapterWithStorage() {
if (!temp_storage_.empty()) {
// An easy way to release the resource references held by |temp_storage_|.
- // A destructor for PP_DirectoryEntry_Dev will release them.
+ // A destructor for PP_DirectoryEntry will release them.
output();
}
}
-std::vector<DirectoryEntry_Dev>&
+std::vector<DirectoryEntry>&
DirectoryEntryArrayOutputAdapterWithStorage::output() {
PP_DCHECK(output_storage_.empty());
- typedef std::vector<PP_DirectoryEntry_Dev> Entries;
+ typedef std::vector<PP_DirectoryEntry> Entries;
for (Entries::iterator it = temp_storage_.begin();
it != temp_storage_.end();
++it) {
- output_storage_.push_back(DirectoryEntry_Dev(PASS_REF, *it));
+ output_storage_.push_back(DirectoryEntry(PASS_REF, *it));
}
temp_storage_.clear();
return output_storage_;
diff --git a/ppapi/cpp/directory_entry.h b/ppapi/cpp/directory_entry.h
new file mode 100644
index 0000000..81be79e
--- /dev/null
+++ b/ppapi/cpp/directory_entry.h
@@ -0,0 +1,127 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DIRECTORY_ENTRY_H_
+#define PPAPI_CPP_DIRECTORY_ENTRY_H_
+
+#include <vector>
+
+#include "ppapi/c/pp_array_output.h"
+#include "ppapi/c/pp_directory_entry.h"
+#include "ppapi/cpp/array_output.h"
+#include "ppapi/cpp/file_ref.h"
+#include "ppapi/cpp/output_traits.h"
+#include "ppapi/cpp/pass_ref.h"
+
+/// @file
+/// This file defines the API used to handle a directory entry.
+
+namespace pp {
+
+/// The <code>DirectoryEntry</code> class represents information about
+/// a directory entry.
+class DirectoryEntry {
+ public:
+ /// Default constructor for creating an is_null() <code>DirectoryEntry</code>
+ /// object.
+ DirectoryEntry();
+
+ /// A constructor used when you have a <code>PP_DirectoryEntry</code> which
+ /// contains a <code>FileRef</code> that has already been reference counted
+ /// as a return value.
+ ///
+ /// @param[in] data A <code>PP_DirectoryEntry</code> to be copied.
+ DirectoryEntry(PassRef, const PP_DirectoryEntry& data);
+
+ /// A copy constructor for <code>DirectoryEntry</code>. This constructor
+ /// increments a reference count of the <code>FileRef</code> held by this
+ /// DirectoryEntry.
+ ///
+ /// @param[in] other A pointer to a <code>DirectoryEntry</code>.
+ DirectoryEntry(const DirectoryEntry& other);
+
+ /// A destructor that decrements a reference count of the <code>FileRef</code>
+ /// held by this <code>DirectoryEntry</code>.
+ ~DirectoryEntry();
+
+ /// This function assigns one <code>DirectoryEntry</code> object to this
+ /// <code>DirectoryEntry</code> object. This function increases the reference
+ /// count of the <code>FileRef</code> of the other DirectoryEntry while
+ /// decrementing the reference count of the FileRef of this DirectoryEntry.
+ ///
+ /// @param[in] other A pointer to a <code>DirectoryEntry</code>.
+ ///
+ /// @return A new <code>DirectoryEntry</code> object.
+ DirectoryEntry& operator=(const DirectoryEntry& other);
+
+ /// This function determines if this <code>DirectoryEntry</code> is a null
+ /// value.
+ ///
+ /// @return true if this <code>DirectoryEntry</code> is null, otherwise false.
+ bool is_null() const { return !data_.file_ref; }
+
+ /// This function returns the <code>FileRef</code> held by this
+ /// <code>DirectoryEntry</code>.
+ ///
+ /// @return A <code>FileRef</code> of the file.
+ FileRef file_ref() const { return FileRef(data_.file_ref); }
+
+ /// This function returns the <code>PP_FileType</code> of the file referenced
+ /// by this <code>DirectoryEntry</code>.
+ ///
+ /// @return A <code>PP_FileType</code> of the file.
+ PP_FileType file_type() const { return data_.file_type; }
+
+ private:
+ PP_DirectoryEntry data_;
+};
+
+namespace internal {
+
+class DirectoryEntryArrayOutputAdapterWithStorage
+ : public ArrayOutputAdapter<PP_DirectoryEntry> {
+ public:
+ DirectoryEntryArrayOutputAdapterWithStorage();
+ virtual ~DirectoryEntryArrayOutputAdapterWithStorage();
+
+ // Returns the final array of resource objects, converting the
+ // PP_DirectoryEntry written by the browser to pp::DirectoryEntry
+ // objects.
+ //
+ // This function should only be called once or we would end up converting
+ // the array more than once, which would mess up the refcounting.
+ std::vector<DirectoryEntry>& output();
+
+ private:
+ // The browser will write the PP_DirectoryEntrys into this array.
+ std::vector<PP_DirectoryEntry> temp_storage_;
+
+ // When asked for the output, the PP_DirectoryEntrys above will be
+ // converted to the pp::DirectoryEntrys in this array for passing to the
+ // calling code.
+ std::vector<DirectoryEntry> output_storage_;
+};
+
+// A specialization of CallbackOutputTraits to provide the callback system the
+// information on how to handle vectors of pp::DirectoryEntry. This converts
+// PP_DirectoryEntry to pp::DirectoryEntry when passing to the plugin.
+template <>
+struct CallbackOutputTraits< std::vector<DirectoryEntry> > {
+ typedef PP_ArrayOutput APIArgType;
+ typedef DirectoryEntryArrayOutputAdapterWithStorage StorageType;
+
+ static inline APIArgType StorageToAPIArg(StorageType& t) {
+ return t.pp_array_output();
+ }
+
+ static inline std::vector<DirectoryEntry>& StorageToPluginArg(
+ StorageType& t) {
+ return t.output();
+ }
+};
+
+} // namespace internal
+} // namespace pp
+
+#endif // PPAPI_CPP_DIRECTORY_ENTRY_H_
diff --git a/ppapi/cpp/file_ref.cc b/ppapi/cpp/file_ref.cc
index 377fbbb..0bc9487 100644
--- a/ppapi/cpp/file_ref.cc
+++ b/ppapi/cpp/file_ref.cc
@@ -6,10 +6,10 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/directory_entry.h"
#include "ppapi/cpp/file_system.h"
#include "ppapi/cpp/module_impl.h"
-
namespace pp {
namespace {
@@ -170,5 +170,13 @@ int32_t FileRef::Query(const CompletionCallbackWithOutput<PP_FileInfo>& cc) {
pp_resource(), cc.output(), cc.pp_completion_callback());
}
+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());
+}
} // namespace pp
diff --git a/ppapi/cpp/file_ref.h b/ppapi/cpp/file_ref.h
index 49a4b98..b7e5e65 100644
--- a/ppapi/cpp/file_ref.h
+++ b/ppapi/cpp/file_ref.h
@@ -17,6 +17,7 @@
namespace pp {
+class DirectoryEntry;
class FileSystem;
class CompletionCallback;
template <typename T> class CompletionCallbackWithOutput;
@@ -146,7 +147,6 @@ class FileRef : public Resource {
/// @return An int32_t containing an error code from <code>pp_errors.h</code>.
int32_t Rename(const FileRef& new_file_ref, const CompletionCallback& cc);
- ///
/// Query() queries info about a file or directory. You must have access to
/// read this file or directory if it exists in the external filesystem.
///
@@ -155,6 +155,30 @@ class FileRef : public Resource {
///
/// @return An int32_t containing an error code from <code>pp_errors.h</code>.
int32_t Query(const CompletionCallbackWithOutput<PP_FileInfo>& callback);
+
+ /// ReadDirectoryEntries() Reads all entries in the directory.
+ ///
+ /// @param[in] cc A <code>CompletionCallbackWithOutput</code> to be called
+ /// upon completion of ReadDirectoryEntries(). On success, the
+ /// directory entries will be passed to the given function.
+ ///
+ /// Normally you would use a CompletionCallbackFactory to allow callbacks to
+ /// be bound to your class. See completion_callback_factory.h for more
+ /// discussion on how to use this. Your callback will generally look like:
+ ///
+ /// @code
+ /// void OnReadDirectoryEntries(
+ /// int32_t result,
+ /// const std::vector<DirectoryEntry>& entries) {
+ /// if (result == PP_OK)
+ /// // use entries...
+ /// }
+ /// @endcode
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ int32_t ReadDirectoryEntries(
+ const CompletionCallbackWithOutput< std::vector<DirectoryEntry> >&
+ callback);
};
} // namespace pp
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 8b582a0..d14866b 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
@@ -12,7 +12,6 @@
#include "ppapi/c/dev/ppb_crypto_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_device_ref_dev.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
@@ -191,7 +190,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Buffer_Dev_0_4;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Crypto_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CursorControl_Dev_0_4;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DeviceRef_Dev_0_1;
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_5;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Find_Dev_0_3;
@@ -560,6 +558,11 @@ static int32_t Pnacl_M28_PPB_FileRef_Query(PP_Resource file_ref, struct PP_FileI
return iface->Query(file_ref, info, *callback);
}
+static int32_t Pnacl_M28_PPB_FileRef_ReadDirectoryEntries(PP_Resource file_ref, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
+ const struct PPB_FileRef_1_1 *iface = Pnacl_WrapperInfo_PPB_FileRef_1_1.real_iface;
+ return iface->ReadDirectoryEntries(file_ref, *output, *callback);
+}
+
/* End wrapper methods for PPB_FileRef_1_1 */
/* Begin wrapper methods for PPB_FileSystem_1_0 */
@@ -1570,25 +1573,6 @@ static void Pnacl_M18_PPB_DeviceRef_Dev_GetName(struct PP_Var* _struct_result, P
/* End wrapper methods for PPB_DeviceRef_Dev_0_1 */
-/* Begin wrapper methods for PPB_DirectoryReader_Dev_0_6 */
-
-static PP_Resource Pnacl_M27_PPB_DirectoryReader_Dev_Create(PP_Resource directory_ref) {
- const struct PPB_DirectoryReader_Dev_0_6 *iface = Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6.real_iface;
- return iface->Create(directory_ref);
-}
-
-static PP_Bool Pnacl_M27_PPB_DirectoryReader_Dev_IsDirectoryReader(PP_Resource resource) {
- const struct PPB_DirectoryReader_Dev_0_6 *iface = Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6.real_iface;
- return iface->IsDirectoryReader(resource);
-}
-
-static int32_t Pnacl_M27_PPB_DirectoryReader_Dev_ReadEntries(PP_Resource directory_reader, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
- const struct PPB_DirectoryReader_Dev_0_6 *iface = Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6.real_iface;
- return iface->ReadEntries(directory_reader, *output, *callback);
-}
-
-/* End wrapper methods for PPB_DirectoryReader_Dev_0_6 */
-
/* Begin wrapper methods for PPB_FileChooser_Dev_0_5 */
static PP_Resource Pnacl_M16_PPB_FileChooser_Dev_Create(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var* accept_types) {
@@ -3694,7 +3678,8 @@ struct PPB_FileRef_1_1 Pnacl_Wrappers_PPB_FileRef_1_1 = {
.Touch = (int32_t (*)(PP_Resource file_ref, PP_Time last_access_time, PP_Time last_modified_time, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_Touch,
.Delete = (int32_t (*)(PP_Resource file_ref, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_Delete,
.Rename = (int32_t (*)(PP_Resource file_ref, PP_Resource new_file_ref, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_Rename,
- .Query = (int32_t (*)(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_Query
+ .Query = (int32_t (*)(PP_Resource file_ref, struct PP_FileInfo* info, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_Query,
+ .ReadDirectoryEntries = (int32_t (*)(PP_Resource file_ref, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M28_PPB_FileRef_ReadDirectoryEntries
};
struct PPB_FileSystem_1_0 Pnacl_Wrappers_PPB_FileSystem_1_0 = {
@@ -3999,12 +3984,6 @@ struct PPB_DeviceRef_Dev_0_1 Pnacl_Wrappers_PPB_DeviceRef_Dev_0_1 = {
.GetName = (struct PP_Var (*)(PP_Resource device_ref))&Pnacl_M18_PPB_DeviceRef_Dev_GetName
};
-struct PPB_DirectoryReader_Dev_0_6 Pnacl_Wrappers_PPB_DirectoryReader_Dev_0_6 = {
- .Create = (PP_Resource (*)(PP_Resource directory_ref))&Pnacl_M27_PPB_DirectoryReader_Dev_Create,
- .IsDirectoryReader = (PP_Bool (*)(PP_Resource resource))&Pnacl_M27_PPB_DirectoryReader_Dev_IsDirectoryReader,
- .ReadEntries = (int32_t (*)(PP_Resource directory_reader, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M27_PPB_DirectoryReader_Dev_ReadEntries
-};
-
struct PPB_FileChooser_Dev_0_5 Pnacl_Wrappers_PPB_FileChooser_Dev_0_5 = {
.Create = (PP_Resource (*)(PP_Instance instance, PP_FileChooserMode_Dev mode, struct PP_Var accept_types))&Pnacl_M16_PPB_FileChooser_Dev_Create,
.IsFileChooser = (PP_Bool (*)(PP_Resource resource))&Pnacl_M16_PPB_FileChooser_Dev_IsFileChooser,
@@ -4938,12 +4917,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DeviceRef_Dev_0_1 = {
.real_iface = NULL
};
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6 = {
- .iface_macro = PPB_DIRECTORYREADER_DEV_INTERFACE_0_6,
- .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_DirectoryReader_Dev_0_6,
- .real_iface = NULL
-};
-
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_5 = {
.iface_macro = PPB_FILECHOOSER_DEV_INTERFACE_0_5,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_FileChooser_Dev_0_5,
@@ -5527,7 +5500,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Crypto_Dev_0_1,
&Pnacl_WrapperInfo_PPB_CursorControl_Dev_0_4,
&Pnacl_WrapperInfo_PPB_DeviceRef_Dev_0_1,
- &Pnacl_WrapperInfo_PPB_DirectoryReader_Dev_0_6,
&Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_5,
&Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6,
&Pnacl_WrapperInfo_PPB_Find_Dev_0_3,
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 7cfbc73..011b867 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -32,8 +32,6 @@
'proxy/connection.h',
'proxy/device_enumeration_resource_helper.cc',
'proxy/device_enumeration_resource_helper.h',
- 'proxy/directory_reader_resource.cc',
- 'proxy/directory_reader_resource.h',
'proxy/dispatcher.cc',
'proxy/dispatcher.h',
'proxy/enter_proxy.h',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index c95db94..101bd94 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -155,8 +155,6 @@
'thunk/ppb_cursor_control_thunk.cc',
'thunk/ppb_device_ref_api.h',
'thunk/ppb_device_ref_dev_thunk.cc',
- 'thunk/ppb_directory_reader_api.h',
- 'thunk/ppb_directory_reader_thunk.cc',
'thunk/ppb_ext_alarms_thunk.cc',
'thunk/ppb_ext_socket_thunk.cc',
'thunk/ppb_file_chooser_api.h',
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 97821a4..07a5b5c 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -64,7 +64,6 @@
'c/dev/ppb_char_set_dev.h',
'c/dev/ppb_cursor_control_dev.h',
'c/dev/ppb_device_ref_dev.h',
- 'c/dev/ppb_directory_reader_dev.h',
'c/dev/ppb_file_chooser_dev.h',
'c/dev/ppb_find_dev.h',
'c/dev/ppb_font_dev.h',
@@ -153,6 +152,8 @@
'cpp/completion_callback.h',
'cpp/core.cc',
'cpp/core.h',
+ 'cpp/directory_entry.cc',
+ 'cpp/directory_entry.h',
'cpp/file_io.cc',
'cpp/file_io.h',
'cpp/file_ref.cc',
@@ -219,10 +220,6 @@
'cpp/dev/cursor_control_dev.h',
'cpp/dev/device_ref_dev.cc',
'cpp/dev/device_ref_dev.h',
- 'cpp/dev/directory_entry_dev.cc',
- 'cpp/dev/directory_entry_dev.h',
- 'cpp/dev/directory_reader_dev.cc',
- 'cpp/dev/directory_reader_dev.h',
'cpp/dev/file_chooser_dev.cc',
'cpp/dev/file_chooser_dev.h',
'cpp/dev/find_dev.cc',
@@ -392,8 +389,6 @@
'tests/test_core.h',
'tests/test_cursor_control.cc',
'tests/test_cursor_control.h',
- 'tests/test_directory_reader.cc',
- 'tests/test_directory_reader.h',
'tests/test_empty.cc',
'tests/test_empty.h',
'tests/test_file_io.cc',
diff --git a/ppapi/proxy/directory_reader_resource.cc b/ppapi/proxy/directory_reader_resource.cc
deleted file mode 100644
index 17826d03..0000000
--- a/ppapi/proxy/directory_reader_resource.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/proxy/directory_reader_resource.h"
-
-#include "base/bind.h"
-#include "ipc/ipc_message.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/proxy/dispatch_reply_message.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppb_file_ref_proxy.h"
-#include "ppapi/shared_impl/ppapi_globals.h"
-#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracked_callback.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_file_ref_api.h"
-
-using ppapi::proxy::PPB_FileRef_Proxy;
-
-namespace ppapi {
-namespace proxy {
-
-namespace {
-
-void ReleaseEntries(const std::vector<PP_DirectoryEntry_Dev>& entries) {
- ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker();
- for (std::vector<PP_DirectoryEntry_Dev>::const_iterator it = entries.begin();
- it != entries.end(); ++it)
- tracker->ReleaseResource(it->file_ref);
-}
-
-} // namespace
-
-DirectoryReaderResource::DirectoryReaderResource(
- Connection connection,
- PP_Instance instance,
- PP_Resource directory_ref)
- : PluginResource(connection, instance) {
- directory_resource_ =
- PpapiGlobals::Get()->GetResourceTracker()->GetResource(directory_ref);
-}
-
-DirectoryReaderResource::~DirectoryReaderResource() {
-}
-
-thunk::PPB_DirectoryReader_API*
-DirectoryReaderResource::AsPPB_DirectoryReader_API() {
- return this;
-}
-
-int32_t DirectoryReaderResource::ReadEntries(
- const PP_ArrayOutput& output,
- scoped_refptr<TrackedCallback> callback) {
- if (TrackedCallback::IsPending(callback_))
- return PP_ERROR_INPROGRESS;
-
- callback_ = callback;
-
- if (!sent_create_to_renderer())
- SendCreate(RENDERER, PpapiHostMsg_DirectoryReader_Create());
-
- PpapiHostMsg_DirectoryReader_GetEntries msg(
- directory_resource_->host_resource());
- Call<PpapiPluginMsg_DirectoryReader_GetEntriesReply>(
- RENDERER, msg,
- base::Bind(&DirectoryReaderResource::OnPluginMsgGetEntriesReply,
- this, output));
- return PP_OK_COMPLETIONPENDING;
-}
-
-void DirectoryReaderResource::OnPluginMsgGetEntriesReply(
- const PP_ArrayOutput& output,
- const ResourceMessageReplyParams& params,
- const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
- const std::vector<PP_FileType>& file_types) {
- CHECK_EQ(infos.size(), file_types.size());
-
- std::vector<PP_DirectoryEntry_Dev> entries;
- for (std::vector<ppapi::PPB_FileRef_CreateInfo>::size_type i = 0;
- i < infos.size(); ++i) {
- PP_DirectoryEntry_Dev entry;
- entry.file_ref = PPB_FileRef_Proxy::DeserializeFileRef(infos[i]);
- entry.file_type = file_types[i];
- entries.push_back(entry);
- }
-
- if (!TrackedCallback::IsPending(callback_)) {
- ReleaseEntries(entries);
- entries.clear();
- return;
- }
-
- ArrayWriter writer(output);
- if (!writer.is_valid()) {
- ReleaseEntries(entries);
- entries.clear();
- callback_->Run(PP_ERROR_FAILED);
- return;
- }
-
- writer.StoreVector(entries);
- entries.clear();
- callback_->Run(params.result());
-}
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/directory_reader_resource.h b/ppapi/proxy/directory_reader_resource.h
deleted file mode 100644
index e532414..0000000
--- a/ppapi/proxy/directory_reader_resource.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_
-#define PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "ppapi/proxy/plugin_resource.h"
-#include "ppapi/proxy/ppapi_proxy_export.h"
-#include "ppapi/shared_impl/array_writer.h"
-#include "ppapi/shared_impl/ppb_file_ref_shared.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/thunk/ppb_directory_reader_api.h"
-
-namespace ppapi {
-
-class TrackedCallback;
-
-namespace proxy {
-
-class PPAPI_PROXY_EXPORT DirectoryReaderResource
- : public PluginResource,
- public NON_EXPORTED_BASE(thunk::PPB_DirectoryReader_API) {
- public:
- DirectoryReaderResource(Connection connection,
- PP_Instance instance,
- PP_Resource directory_ref);
- virtual ~DirectoryReaderResource();
-
- // Resource overrides.
- virtual thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API() OVERRIDE;
-
- // PPB_DirectoryReader_API.
- virtual int32_t ReadEntries(
- const PP_ArrayOutput& output,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
-
- private:
- void OnPluginMsgGetEntriesReply(
- const PP_ArrayOutput& output,
- const ResourceMessageReplyParams& params,
- const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
- const std::vector<PP_FileType>& file_types);
-
- scoped_refptr<Resource> directory_resource_;
- scoped_refptr<TrackedCallback> callback_;
-
- DISALLOW_COPY_AND_ASSIGN(DirectoryReaderResource);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_DIRECTORY_READER_RESOURCE_H_
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index ba4aafa..e5195d5 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -12,7 +12,6 @@
#include "ppapi/c/dev/ppb_crypto_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_device_ref_dev.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 581d3f0..0e00d52 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -21,7 +21,6 @@
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/dev/pp_video_capture_dev.h"
#include "ppapi/c/dev/pp_video_dev.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
@@ -474,6 +473,14 @@ IPC_MESSAGE_ROUTED4(
uint32_t /* callback_id */,
int32_t /* result */)
+IPC_MESSAGE_ROUTED5(
+ PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete,
+ ppapi::HostResource /* resource */,
+ std::vector<ppapi::PPB_FileRef_CreateInfo> /* files */,
+ std::vector<PP_FileType> /* file_types */,
+ uint32_t /* callback_id */,
+ int32_t /* result */)
+
// PPB_FileSystem.
IPC_MESSAGE_ROUTED2(
PpapiMsg_PPBFileSystem_OpenComplete,
@@ -834,6 +841,9 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileRef_Query,
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFileRef_GetAbsolutePath,
ppapi::HostResource /* file_ref */,
ppapi::proxy::SerializedVar /* result */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileRef_ReadDirectoryEntries,
+ ppapi::HostResource /* file_ref */,
+ uint32_t /* callback_id */)
// PPB_Graphics3D.
IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics3D_Create,
@@ -1330,14 +1340,6 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_Create)
// ResourceMessageReplyParams in the reply message.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_IsAllowed)
-// Directory reader.
-IPC_MESSAGE_CONTROL0(PpapiHostMsg_DirectoryReader_Create)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_DirectoryReader_GetEntries,
- ppapi::HostResource /* file_ref_resource */)
-IPC_MESSAGE_CONTROL2(PpapiPluginMsg_DirectoryReader_GetEntriesReply,
- std::vector<ppapi::PPB_FileRef_CreateInfo> /* files */,
- std::vector<PP_FileType> /* file_types */)
-
// Extensions common -----------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_ExtensionsCommon_Create)
diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc
index da62159..62c55da 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.cc
+++ b/ppapi/proxy/ppb_file_ref_proxy.cc
@@ -7,6 +7,7 @@
#include <map>
#include "base/bind.h"
+#include "ppapi/c/pp_directory_entry.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_file_ref.h"
#include "ppapi/c/private/ppb_file_ref_private.h"
@@ -16,6 +17,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
+#include "ppapi/shared_impl/array_writer.h"
#include "ppapi/shared_impl/ppb_file_ref_shared.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/shared_impl/tracked_callback.h"
@@ -29,6 +31,17 @@ using ppapi::thunk::ResourceCreationAPI;
namespace ppapi {
namespace proxy {
+namespace {
+
+void ReleaseEntries(const std::vector<PP_DirectoryEntry>& entries) {
+ ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker();
+ for (std::vector<PP_DirectoryEntry>::const_iterator it = entries.begin();
+ it != entries.end(); ++it)
+ tracker->ReleaseResource(it->file_ref);
+}
+
+} // namespace
+
class FileRef : public PPB_FileRef_Shared {
public:
explicit FileRef(const PPB_FileRef_CreateInfo& info);
@@ -50,11 +63,25 @@ class FileRef : public PPB_FileRef_Shared {
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t Query(PP_FileInfo* info,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t ReadDirectoryEntries(
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t QueryInHost(
+ linked_ptr<PP_FileInfo> info,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t ReadDirectoryEntriesInHost(
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
+ linked_ptr<std::vector<PP_FileType> > file_types,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual PP_Var GetAbsolutePath() OVERRIDE;
// Executes the pending callback with the given ID. See pending_callbacks_.
void ExecuteCallback(uint32_t callback_id, int32_t result);
- void SetFileInfo(uint32_t callback_id, const PP_FileInfo& info);
+ int32_t SetFileInfo(uint32_t callback_id, const PP_FileInfo& info);
+ int32_t SetReadDirectoryEntriesOutput(
+ uint32_t callback_id,
+ const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
+ const std::vector<PP_FileType>& file_types);
private:
PluginDispatcher* GetDispatcher() const {
@@ -82,6 +109,13 @@ class FileRef : public PPB_FileRef_Shared {
typedef std::map<uint32_t, PP_FileInfo*> PendingFileInfoMap;
PendingFileInfoMap pending_file_infos_;
+ // Used to keep PP_ArrayOutput instances that are written before callbacks
+ // are invoked. The id of a pending array output will match that of the
+ // corresponding callback.
+ typedef std::map<uint32_t, PP_ArrayOutput>
+ PendingReadDirectoryEntriesOutputMap;
+ PendingReadDirectoryEntriesOutputMap pending_read_entries_outputs_;
+
// Holds a reference on plugin side when running out of process, so that
// FileSystem won't die before FileRef. See PPB_FileRef_Impl for
// corresponding code for in-process mode. Note that this workaround will
@@ -101,12 +135,14 @@ FileRef::~FileRef() {
// The callbacks map should have been cleared by LastPluginRefWasDeleted.
DCHECK(pending_callbacks_.empty());
DCHECK(pending_file_infos_.empty());
+ DCHECK(pending_read_entries_outputs_.empty());
}
void FileRef::LastPluginRefWasDeleted() {
// The callback tracker will abort our callbacks for us.
pending_callbacks_.clear();
pending_file_infos_.clear();
+ pending_read_entries_outputs_.clear();
}
PP_Resource FileRef::GetParent() {
@@ -156,13 +192,39 @@ int32_t FileRef::Rename(PP_Resource new_file_ref,
int32_t FileRef::Query(PP_FileInfo* info,
scoped_refptr<TrackedCallback> callback) {
// Store the pending file info id.
- int id = SendCallback(callback);
+ uint32_t id = SendCallback(callback);
pending_file_infos_[id] = info;
GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Query(
API_ID_PPB_FILE_REF, host_resource(), id));
return PP_OK_COMPLETIONPENDING;
}
+int32_t FileRef::ReadDirectoryEntries(
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) {
+ // Store the pending read entries output id.
+ uint32_t id = SendCallback(callback);
+ pending_read_entries_outputs_[id] = output;
+ GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_ReadDirectoryEntries(
+ API_ID_PPB_FILE_REF, host_resource(), id));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t FileRef::QueryInHost(
+ linked_ptr<PP_FileInfo> info,
+ scoped_refptr<TrackedCallback> callback) {
+ NOTREACHED();
+ return PP_ERROR_FAILED;
+}
+
+int32_t FileRef::ReadDirectoryEntriesInHost(
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
+ linked_ptr<std::vector<PP_FileType> > file_types,
+ scoped_refptr<TrackedCallback> callback) {
+ NOTREACHED();
+ return PP_ERROR_FAILED;
+}
+
PP_Var FileRef::GetAbsolutePath() {
ReceiveSerializedVarReturnValue result;
GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_GetAbsolutePath(
@@ -185,13 +247,44 @@ void FileRef::ExecuteCallback(uint32_t callback_id, int32_t result) {
callback->Run(result);
}
-void FileRef::SetFileInfo(uint32_t callback_id, const PP_FileInfo& info) {
+int32_t FileRef::SetFileInfo(uint32_t callback_id, const PP_FileInfo& info) {
PendingFileInfoMap::iterator found = pending_file_infos_.find(callback_id);
if (found == pending_file_infos_.end())
- return;
+ return PP_ERROR_FAILED;
PP_FileInfo* target_info = found->second;
*target_info = info;
pending_file_infos_.erase(found);
+ return PP_OK;
+}
+
+int32_t FileRef::SetReadDirectoryEntriesOutput(
+ uint32_t callback_id,
+ const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
+ const std::vector<PP_FileType>& file_types) {
+ PendingReadDirectoryEntriesOutputMap::iterator found =
+ pending_read_entries_outputs_.find(callback_id);
+ if (found == pending_read_entries_outputs_.end())
+ return PP_ERROR_FAILED;
+
+ PP_ArrayOutput output = found->second;
+ pending_read_entries_outputs_.erase(found);
+
+ std::vector<PP_DirectoryEntry> entries;
+ for (size_t i = 0; i < infos.size(); ++i) {
+ PP_DirectoryEntry entry;
+ entry.file_ref = PPB_FileRef_Proxy::DeserializeFileRef(infos[i]);
+ entry.file_type = file_types[i];
+ entries.push_back(entry);
+ }
+
+ ArrayWriter writer(output);
+ if (!writer.is_valid()) {
+ ReleaseEntries(entries);
+ return PP_ERROR_BADARGUMENT;
+ }
+
+ writer.StoreVector(entries);
+ return PP_OK;
}
uint32_t FileRef::SendCallback(scoped_refptr<TrackedCallback> callback) {
@@ -234,6 +327,8 @@ bool PPB_FileRef_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Delete, OnMsgDelete)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Rename, OnMsgRename)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Query, OnMsgQuery)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_ReadDirectoryEntries,
+ OnMsgReadDirectoryEntries)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_GetAbsolutePath,
OnMsgGetAbsolutePath)
#endif // !defined(OS_NACL)
@@ -242,6 +337,9 @@ bool PPB_FileRef_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgCallbackComplete)
IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileRef_QueryCallbackComplete,
OnMsgQueryCallbackComplete)
+ IPC_MESSAGE_HANDLER(
+ PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete,
+ OnMsgReadDirectoryEntriesCallbackComplete)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -334,13 +432,13 @@ void PPB_FileRef_Proxy::OnMsgRename(const HostResource& file_ref,
void PPB_FileRef_Proxy::OnMsgQuery(const HostResource& file_ref,
uint32_t callback_id) {
- PP_FileInfo* info = new PP_FileInfo();
+ linked_ptr<PP_FileInfo> info(new PP_FileInfo());
EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter(
file_ref, callback_factory_,
&PPB_FileRef_Proxy::OnQueryCallbackCompleteInHost, file_ref,
- base::Owned(info), callback_id);
+ info, callback_id);
if (enter.succeeded())
- enter.SetResult(enter.object()->Query(info, enter.callback()));
+ enter.SetResult(enter.object()->QueryInHost(info, enter.callback()));
}
void PPB_FileRef_Proxy::OnMsgGetAbsolutePath(const HostResource& host_resource,
@@ -349,6 +447,24 @@ void PPB_FileRef_Proxy::OnMsgGetAbsolutePath(const HostResource& host_resource,
if (enter.succeeded())
result.Return(dispatcher(), enter.object()->GetAbsolutePath());
}
+
+void PPB_FileRef_Proxy::OnMsgReadDirectoryEntries(const HostResource& file_ref,
+ uint32_t callback_id) {
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files(
+ new std::vector<ppapi::PPB_FileRef_CreateInfo>());
+ linked_ptr<std::vector<PP_FileType> > file_types(
+ new std::vector<PP_FileType>());
+ HostCallbackParams params(file_ref, callback_id);
+ EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter(
+ file_ref, callback_factory_,
+ &PPB_FileRef_Proxy::OnReadDirectoryEntriesCallbackCompleteInHost,
+ params, files, file_types);
+ if (enter.succeeded()) {
+ enter.SetResult(enter.object()->ReadDirectoryEntriesInHost(
+ files, file_types, enter.callback()));
+ }
+}
+
#endif // !defined(OS_NACL)
void PPB_FileRef_Proxy::OnMsgCallbackComplete(
@@ -367,11 +483,35 @@ void PPB_FileRef_Proxy::OnMsgQueryCallbackComplete(
uint32_t callback_id,
int32_t result) {
EnterPluginFromHostResource<PPB_FileRef_API> enter(host_resource);
- if (enter.succeeded()) {
- // Set the FileInfo output parameter.
- static_cast<FileRef*>(enter.object())->SetFileInfo(callback_id, info);
- static_cast<FileRef*>(enter.object())->ExecuteCallback(callback_id, result);
+ if (!enter.succeeded())
+ return;
+
+ if (result == PP_OK) {
+ result = static_cast<FileRef*>(enter.object())->SetFileInfo(
+ callback_id, info);
+ }
+ static_cast<FileRef*>(enter.object())->ExecuteCallback(callback_id, result);
+}
+
+void PPB_FileRef_Proxy::OnMsgReadDirectoryEntriesCallbackComplete(
+ const HostResource& host_resource,
+ const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
+ const std::vector<PP_FileType>& file_types,
+ uint32_t callback_id,
+ int32_t result) {
+ CHECK_EQ(infos.size(), file_types.size());
+
+ EnterPluginFromHostResource<PPB_FileRef_API> enter(host_resource);
+ if (!enter.succeeded())
+ return;
+
+ if (result == PP_OK) {
+ result =
+ static_cast<FileRef*>(enter.object())->SetReadDirectoryEntriesOutput(
+ callback_id, infos, file_types);
}
+ static_cast<FileRef*>(enter.object())->ExecuteCallback(
+ callback_id, result);
}
#if !defined(OS_NACL)
@@ -387,11 +527,22 @@ void PPB_FileRef_Proxy::OnCallbackCompleteInHost(
void PPB_FileRef_Proxy::OnQueryCallbackCompleteInHost(
int32_t result,
const HostResource& host_resource,
- base::internal::OwnedWrapper<PP_FileInfo> info,
+ linked_ptr<PP_FileInfo> info,
uint32_t callback_id) {
Send(new PpapiMsg_PPBFileRef_QueryCallbackComplete(
- API_ID_PPB_FILE_REF, host_resource, *info.get(), callback_id, result));
+ API_ID_PPB_FILE_REF, host_resource, *info, callback_id, result));
+}
+
+void PPB_FileRef_Proxy::OnReadDirectoryEntriesCallbackCompleteInHost(
+ int32_t result,
+ HostCallbackParams params,
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
+ linked_ptr<std::vector<PP_FileType> > file_types) {
+ Send(new PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete(
+ API_ID_PPB_FILE_REF, params.host_resource,
+ *files, *file_types, params.callback_id, result));
}
+
#endif // !defined(OS_NACL)
} // namespace proxy
diff --git a/ppapi/proxy/ppb_file_ref_proxy.h b/ppapi/proxy/ppb_file_ref_proxy.h
index 2743847..cbfadb5 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.h
+++ b/ppapi/proxy/ppb_file_ref_proxy.h
@@ -8,7 +8,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/bind_helpers.h"
+#include "base/memory/linked_ptr.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
@@ -16,11 +16,11 @@
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
+#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/utility/completion_callback_factory.h"
namespace ppapi {
-class HostResource;
struct PPB_FileRef_CreateInfo;
namespace proxy {
@@ -87,6 +87,8 @@ class PPAPI_PROXY_EXPORT PPB_FileRef_Proxy
uint32_t callback_id);
void OnMsgGetAbsolutePath(const HostResource& host_resource,
SerializedVarReturnValue result);
+ void OnMsgReadDirectoryEntries(const HostResource& file_ref,
+ uint32_t callback_id);
// Host -> Plugin message handlers.
void OnMsgCallbackComplete(const HostResource& host_resource,
@@ -96,6 +98,20 @@ class PPAPI_PROXY_EXPORT PPB_FileRef_Proxy
const PP_FileInfo& info,
uint32_t callback_id,
int32_t result);
+ void OnMsgReadDirectoryEntriesCallbackComplete(
+ const HostResource& host_resource,
+ const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos,
+ const std::vector<PP_FileType>& file_types,
+ uint32_t callback_id,
+ int32_t result);
+
+ struct HostCallbackParams {
+ HostCallbackParams(const HostResource& host_res, uint32_t cb_id)
+ : host_resource(host_res), callback_id(cb_id) {
+ }
+ HostResource host_resource;
+ uint32_t callback_id;
+ };
void OnCallbackCompleteInHost(int32_t result,
const HostResource& host_resource,
@@ -103,8 +119,13 @@ class PPAPI_PROXY_EXPORT PPB_FileRef_Proxy
void OnQueryCallbackCompleteInHost(
int32_t result,
const HostResource& host_resource,
- base::internal::OwnedWrapper<PP_FileInfo> info,
+ linked_ptr<PP_FileInfo> info,
uint32_t callback_id);
+ void OnReadDirectoryEntriesCallbackCompleteInHost(
+ int32_t result,
+ HostCallbackParams params,
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
+ linked_ptr<std::vector<PP_FileType> > file_types);
ProxyCompletionCallbackFactory<PPB_FileRef_Proxy> callback_factory_;
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 3cb25fa..4fe204d 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -10,7 +10,6 @@
#include "ppapi/proxy/audio_input_resource.h"
#include "ppapi/proxy/browser_font_resource_trusted.h"
#include "ppapi/proxy/connection.h"
-#include "ppapi/proxy/directory_reader_resource.h"
#include "ppapi/proxy/file_chooser_resource.h"
#include "ppapi/proxy/file_io_resource.h"
#include "ppapi/proxy/file_system_resource.h"
@@ -70,13 +69,6 @@ InterfaceProxy* ResourceCreationProxy::Create(Dispatcher* dispatcher) {
return new ResourceCreationProxy(dispatcher);
}
-PP_Resource ResourceCreationProxy::CreateDirectoryReader(
- PP_Instance instance,
- PP_Resource directory_ref) {
- return (new DirectoryReaderResource(
- GetConnection(), instance, directory_ref))->GetReference();
-}
-
PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) {
return (new FileIOResource(GetConnection(), instance))->GetReference();
}
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h
index f120ed6..2654651 100644
--- a/ppapi/proxy/resource_creation_proxy.h
+++ b/ppapi/proxy/resource_creation_proxy.h
@@ -37,8 +37,6 @@ class ResourceCreationProxy : public InterfaceProxy,
static InterfaceProxy* Create(Dispatcher* dispatcher);
// ResourceCreationAPI (called in plugin).
- virtual PP_Resource CreateDirectoryReader(PP_Instance instance,
- PP_Resource directory_ref) OVERRIDE;
virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateFileRef(PP_Instance instance,
PP_Resource file_system,
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 7fffd4a..4e7ff88 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -30,7 +30,6 @@
F(PPB_BrowserFont_Trusted_API) \
F(PPB_Buffer_API) \
F(PPB_DeviceRef_API) \
- F(PPB_DirectoryReader_API) \
F(PPB_FileChooser_API) \
F(PPB_FileIO_API) \
F(PPB_FileRef_API) \
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 5cf7f40..ff5ee00 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -16,7 +16,6 @@
#include "ppapi/c/dev/ppb_crypto_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_device_ref_dev.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index 4e3ced4..72aedc8 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -14,8 +14,6 @@
#include "ppapi/cpp/core.h"
#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/dev/device_ref_dev.h"
-#include "ppapi/cpp/dev/directory_entry_dev.h"
-#include "ppapi/cpp/dev/directory_reader_dev.h"
#include "ppapi/cpp/dev/file_chooser_dev.h"
#include "ppapi/cpp/dev/find_dev.h"
#include "ppapi/cpp/dev/font_dev.h"
@@ -36,6 +34,7 @@
#include "ppapi/cpp/dev/widget_client_dev.h"
#include "ppapi/cpp/dev/widget_dev.h"
#include "ppapi/cpp/dev/zoom_dev.h"
+#include "ppapi/cpp/directory_entry.h"
#include "ppapi/cpp/extensions/dev/alarms_dev.h"
#include "ppapi/cpp/extensions/dev/socket_dev.h"
#include "ppapi/cpp/file_io.h"
diff --git a/ppapi/tests/test_directory_reader.cc b/ppapi/tests/test_directory_reader.cc
deleted file mode 100644
index c0a65d0..0000000
--- a/ppapi/tests/test_directory_reader.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/tests/test_directory_reader.h"
-
-#include <stdio.h>
-#include <set>
-#include <vector>
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/cpp/dev/directory_entry_dev.h"
-#include "ppapi/cpp/dev/directory_reader_dev.h"
-#include "ppapi/cpp/file_io.h"
-#include "ppapi/cpp/file_ref.h"
-#include "ppapi/cpp/file_system.h"
-#include "ppapi/cpp/instance.h"
-#include "ppapi/tests/test_utils.h"
-#include "ppapi/tests/testing_instance.h"
-
-REGISTER_TEST_CASE(DirectoryReader);
-
-namespace {
-
-typedef std::vector<pp::DirectoryEntry_Dev> Entries;
-
-std::string IntegerToString(int value) {
- char result[12];
- sprintf(result, "%d", value);
- return result;
-}
-
-} // namespace
-
-bool TestDirectoryReader::Init() {
- return CheckTestingInterface() && EnsureRunningOverHTTP();
-}
-
-void TestDirectoryReader::RunTests(const std::string& filter) {
- RUN_CALLBACK_TEST(TestDirectoryReader, ReadEntries, filter);
-}
-
-int32_t TestDirectoryReader::DeleteDirectoryRecursively(pp::FileRef* dir) {
- if (!dir)
- return PP_ERROR_BADARGUMENT;
-
- TestCompletionCallback callback(instance_->pp_instance(), callback_type());
- TestCompletionCallbackWithOutput<Entries> output_callback(
- instance_->pp_instance(), callback_type());
-
- pp::DirectoryReader_Dev directory_reader(*dir);
- output_callback.WaitForResult(
- directory_reader.ReadEntries(output_callback.GetCallback()));
- int32_t rv = output_callback.result();
- if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
- return rv;
-
- Entries entries = output_callback.output();
- for (Entries::const_iterator it = entries.begin();
- it != entries.end(); ++it) {
- pp::FileRef file_ref = it->file_ref();
- if (it->file_type() == PP_FILETYPE_DIRECTORY) {
- rv = DeleteDirectoryRecursively(&file_ref);
- if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
- return rv;
- } else {
- callback.WaitForResult(file_ref.Delete(callback.GetCallback()));
- rv = callback.result();
- if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
- return rv;
- }
- }
- callback.WaitForResult(dir->Delete(callback.GetCallback()));
- return callback.result();
-}
-
-std::string TestDirectoryReader::TestReadEntries() {
- TestCompletionCallback callback(instance_->pp_instance(), callback_type());
- pp::FileSystem file_system(
- instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- callback.WaitForResult(file_system.Open(1024, callback.GetCallback()));
- CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_EQ(PP_OK, callback.result());
-
- // Setup testing directories and files.
- const char* test_dir_name = "/test_get_next_file";
- const char* file_prefix = "file_";
- const char* dir_prefix = "dir_";
-
- pp::FileRef test_dir(file_system, test_dir_name);
- int32_t rv = DeleteDirectoryRecursively(&test_dir);
- if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
- return ReportError("DeleteDirectoryRecursively", rv);
-
- callback.WaitForResult(test_dir.MakeDirectory(callback.GetCallback()));
- CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_EQ(PP_OK, callback.result());
-
- std::set<std::string> expected_file_names;
- for (int i = 1; i < 4; ++i) {
- char buffer[40];
- sprintf(buffer, "%s/%s%d", test_dir_name, file_prefix, i);
- pp::FileRef file_ref(file_system, buffer);
-
- pp::FileIO file_io(instance_);
- callback.WaitForResult(
- file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback.GetCallback()));
- CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_EQ(PP_OK, callback.result());
-
- expected_file_names.insert(buffer);
- }
-
- std::set<std::string> expected_dir_names;
- for (int i = 1; i < 4; ++i) {
- char buffer[40];
- sprintf(buffer, "%s/%s%d", test_dir_name, dir_prefix, i);
- pp::FileRef file_ref(file_system, buffer);
-
- callback.WaitForResult(file_ref.MakeDirectory(callback.GetCallback()));
- CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_EQ(PP_OK, callback.result());
-
- expected_dir_names.insert(buffer);
- }
-
- // Test that |ReadEntries()| is able to fetch all directories and files that
- // we created.
- {
- TestCompletionCallbackWithOutput<Entries> output_callback(
- instance_->pp_instance(), callback_type());
-
- pp::DirectoryReader_Dev directory_reader(test_dir);
- output_callback.WaitForResult(
- directory_reader.ReadEntries(output_callback.GetCallback()));
- CHECK_CALLBACK_BEHAVIOR(output_callback);
- ASSERT_EQ(PP_OK, output_callback.result());
-
- Entries entries = output_callback.output();
- size_t sum = expected_file_names.size() + expected_dir_names.size();
- if (entries.size() != sum)
- return "Expected " + IntegerToString(sum) + " entries, got " +
- IntegerToString(entries.size());
-
- for (Entries::const_iterator it = entries.begin();
- it != entries.end(); ++it) {
- pp::FileRef file_ref = it->file_ref();
- std::string file_path = file_ref.GetPath().AsString();
- std::set<std::string>::iterator found =
- expected_file_names.find(file_path);
- if (found != expected_file_names.end()) {
- if (it->file_type() != PP_FILETYPE_REGULAR)
- return file_path + " should have been a regular file.";
- expected_file_names.erase(found);
- } else {
- found = expected_dir_names.find(file_path);
- if (found == expected_dir_names.end())
- return "Unexpected file path: " + file_path;
- if (it->file_type() != PP_FILETYPE_DIRECTORY)
- return file_path + " should have been a directory.";
- expected_dir_names.erase(found);
- }
- }
- if (!expected_file_names.empty() || !expected_dir_names.empty())
- return "Expected more file paths.";
- }
-
- // Test cancellation of asynchronous |ReadEntries()|.
- TestCompletionCallbackWithOutput<Entries> output_callback(
- instance_->pp_instance(), callback_type());
- {
-
- // Note that the directory reader will be deleted immediately.
- rv = pp::DirectoryReader_Dev(test_dir).ReadEntries(
- output_callback.GetCallback());
- }
- output_callback.WaitForAbortResult(rv);
- CHECK_CALLBACK_BEHAVIOR(output_callback);
-
- PASS();
-}
diff --git a/ppapi/tests/test_directory_reader.h b/ppapi/tests/test_directory_reader.h
deleted file mode 100644
index ee446c5..0000000
--- a/ppapi/tests/test_directory_reader.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PAPPI_TESTS_TEST_DIRECTORY_READER_H_
-#define PAPPI_TESTS_TEST_DIRECTORY_READER_H_
-
-#include <string>
-
-#include "ppapi/tests/test_case.h"
-
-namespace pp {
-class FileRef;
-}
-
-class TestDirectoryReader : public TestCase {
- public:
- explicit TestDirectoryReader(TestingInstance* instance)
- : TestCase(instance) {}
-
- // TestCase implementation.
- virtual bool Init();
- virtual void RunTests(const std::string& filter);
-
- private:
- int32_t DeleteDirectoryRecursively(pp::FileRef*);
-
- std::string TestReadEntries();
-};
-
-#endif // PAPPI_TESTS_TEST_DIRECTORY_READER_H_
diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc
index 4aab3d6..04e8ce1 100644
--- a/ppapi/tests/test_file_ref.cc
+++ b/ppapi/tests/test_file_ref.cc
@@ -5,13 +5,14 @@
#include "ppapi/tests/test_file_ref.h"
#include <stdio.h>
+
+#include <sstream>
#include <vector>
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_file_io.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
-#include "ppapi/cpp/dev/directory_entry_dev.h"
-#include "ppapi/cpp/dev/directory_reader_dev.h"
+#include "ppapi/cpp/directory_entry.h"
#include "ppapi/cpp/file_io.h"
#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/file_system.h"
@@ -34,6 +35,8 @@ const char* kPersFilePath = "/foo/bar/persistent";
const char* kTempFilePath = "/foo/bar/temporary";
const char* kTerribleName = "!@#$%^&*()-_=+{}[] ;:'\"|`~\t\n\r\b?";
+typedef std::vector<pp::DirectoryEntry> DirEntries;
+
std::string ReportMismatch(const std::string& method_name,
const std::string& returned_result,
const std::string& expected_result) {
@@ -68,6 +71,40 @@ std::string TestFileRef::MakeExternalFileRef(pp::FileRef* file_ref_ext) {
PASS();
}
+int32_t TestFileRef::DeleteDirectoryRecursively(pp::FileRef* dir) {
+ if (!dir)
+ return PP_ERROR_BADARGUMENT;
+
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ TestCompletionCallbackWithOutput<DirEntries> output_callback(
+ instance_->pp_instance(), callback_type());
+
+ output_callback.WaitForResult(
+ dir->ReadDirectoryEntries(output_callback.GetCallback()));
+ int32_t rv = output_callback.result();
+ if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
+ return rv;
+
+ DirEntries entries = output_callback.output();
+ for (DirEntries::const_iterator it = entries.begin();
+ it != entries.end();
+ ++it) {
+ pp::FileRef file_ref = it->file_ref();
+ if (it->file_type() == PP_FILETYPE_DIRECTORY) {
+ rv = DeleteDirectoryRecursively(&file_ref);
+ if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
+ return rv;
+ } else {
+ callback.WaitForResult(file_ref.Delete(callback.GetCallback()));
+ rv = callback.result();
+ if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
+ return rv;
+ }
+ }
+ callback.WaitForResult(dir->Delete(callback.GetCallback()));
+ return callback.result();
+}
+
void TestFileRef::RunTests(const std::string& filter) {
RUN_CALLBACK_TEST(TestFileRef, Create, filter);
RUN_CALLBACK_TEST(TestFileRef, GetFileSystemType, filter);
@@ -78,8 +115,13 @@ void TestFileRef::RunTests(const std::string& filter) {
RUN_CALLBACK_TEST(TestFileRef, QueryAndTouchFile, filter);
RUN_CALLBACK_TEST(TestFileRef, DeleteFileAndDirectory, filter);
RUN_CALLBACK_TEST(TestFileRef, RenameFileAndDirectory, filter);
- RUN_CALLBACK_TEST(TestFileRef, Query, filter);
+ // FileRef::Query is out-of-process only.
+ if (testing_interface_->IsOutOfProcess())
+ RUN_CALLBACK_TEST(TestFileRef, Query, filter);
RUN_CALLBACK_TEST(TestFileRef, FileNameEscaping, filter);
+ // FileRef::ReadDirectoryEntries is out-of-process only.
+ if (testing_interface_->IsOutOfProcess())
+ RUN_CALLBACK_TEST(TestFileRef, ReadDirectoryEntries, filter);
}
std::string TestFileRef::TestCreate() {
@@ -588,21 +630,123 @@ std::string TestFileRef::TestFileNameEscaping() {
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
- // DirectoryReader only works out-of-process.
+ // FileRef::ReadDirectoryEntries only works out-of-process.
if (testing_interface_->IsOutOfProcess()) {
- TestCompletionCallbackWithOutput< std::vector<pp::DirectoryEntry_Dev> >
+ TestCompletionCallbackWithOutput<DirEntries>
output_callback(instance_->pp_instance(), callback_type());
- pp::DirectoryReader_Dev directory_reader(test_dir_ref);
output_callback.WaitForResult(
- directory_reader.ReadEntries(output_callback.GetCallback()));
+ test_dir_ref.ReadDirectoryEntries(output_callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(output_callback);
ASSERT_EQ(PP_OK, output_callback.result());
- std::vector<pp::DirectoryEntry_Dev> entries = output_callback.output();
+ DirEntries entries = output_callback.output();
ASSERT_EQ(1, entries.size());
ASSERT_EQ(kTerribleName, entries.front().file_ref().GetName().AsString());
}
PASS();
}
+
+std::string TestFileRef::TestReadDirectoryEntries() {
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ pp::FileSystem file_system(
+ instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
+ callback.WaitForResult(file_system.Open(1024, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ // Setup testing directories and files.
+ const char* test_dir_name = "/test_get_next_file";
+ const char* file_prefix = "file_";
+ const char* dir_prefix = "dir_";
+
+ pp::FileRef test_dir(file_system, test_dir_name);
+ int32_t rv = DeleteDirectoryRecursively(&test_dir);
+ ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND);
+
+ callback.WaitForResult(test_dir.MakeDirectory(callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ static const int kNumFiles = 3;
+ std::set<std::string> expected_file_names;
+ for (int i = 1; i <= kNumFiles; ++i) {
+ std::ostringstream buffer;
+ buffer << test_dir_name << '/' << file_prefix << i;
+ pp::FileRef file_ref(file_system, buffer.str().c_str());
+
+ pp::FileIO file_io(instance_);
+ callback.WaitForResult(
+ file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ expected_file_names.insert(buffer.str());
+ }
+
+ static const int kNumDirectories = 3;
+ std::set<std::string> expected_dir_names;
+ for (int i = 1; i <= kNumDirectories; ++i) {
+ std::ostringstream buffer;
+ buffer << test_dir_name << '/' << dir_prefix << i;
+ pp::FileRef file_ref(file_system, buffer.str().c_str());
+
+ callback.WaitForResult(file_ref.MakeDirectory(callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ expected_dir_names.insert(buffer.str());
+ }
+
+ // Test that |ReadDirectoryEntries()| is able to fetch all
+ // directories and files that we created.
+ {
+ TestCompletionCallbackWithOutput<DirEntries> output_callback(
+ instance_->pp_instance(), callback_type());
+
+ output_callback.WaitForResult(
+ test_dir.ReadDirectoryEntries(output_callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(output_callback);
+ ASSERT_EQ(PP_OK, output_callback.result());
+
+ DirEntries entries = output_callback.output();
+ size_t sum = expected_file_names.size() + expected_dir_names.size();
+ ASSERT_EQ(sum, entries.size());
+
+ for (DirEntries::const_iterator it = entries.begin();
+ it != entries.end(); ++it) {
+ pp::FileRef file_ref = it->file_ref();
+ std::string file_path = file_ref.GetPath().AsString();
+ std::set<std::string>::iterator found =
+ expected_file_names.find(file_path);
+ if (found != expected_file_names.end()) {
+ if (it->file_type() != PP_FILETYPE_REGULAR)
+ return file_path + " should have been a regular file.";
+ expected_file_names.erase(found);
+ } else {
+ found = expected_dir_names.find(file_path);
+ if (found == expected_dir_names.end())
+ return "Unexpected file path: " + file_path;
+ if (it->file_type() != PP_FILETYPE_DIRECTORY)
+ return file_path + " should have been a directory.";
+ expected_dir_names.erase(found);
+ }
+ }
+ ASSERT_TRUE(expected_file_names.empty());
+ ASSERT_TRUE(expected_dir_names.empty());
+ }
+
+ // Test cancellation of asynchronous |ReadDirectoryEntries()|.
+ TestCompletionCallbackWithOutput<DirEntries> output_callback(
+ instance_->pp_instance(), callback_type());
+ {
+ rv = pp::FileRef(file_system, test_dir_name)
+ .ReadDirectoryEntries(output_callback.GetCallback());
+ }
+ output_callback.WaitForAbortResult(rv);
+ CHECK_CALLBACK_BEHAVIOR(output_callback);
+
+
+ PASS();
+}
diff --git a/ppapi/tests/test_file_ref.h b/ppapi/tests/test_file_ref.h
index 97feaf1..ff91215 100644
--- a/ppapi/tests/test_file_ref.h
+++ b/ppapi/tests/test_file_ref.h
@@ -26,6 +26,8 @@ class TestFileRef : public TestCase {
// Returns "" on success, a different string otherwise.
std::string MakeExternalFileRef(pp::FileRef* file_ref_ext);
+ int32_t DeleteDirectoryRecursively(pp::FileRef* dir);
+
std::string TestCreate();
std::string TestGetFileSystemType();
std::string TestGetName();
@@ -37,6 +39,7 @@ class TestFileRef : public TestCase {
std::string TestRenameFileAndDirectory();
std::string TestQuery();
std::string TestFileNameEscaping();
+ std::string TestReadDirectoryEntries();
};
#endif // PAPPI_TESTS_TEST_FILE_REF_H_
diff --git a/ppapi/tests/test_file_system.cc b/ppapi/tests/test_file_system.cc
index 9a2d712..7badabb 100644
--- a/ppapi/tests/test_file_system.cc
+++ b/ppapi/tests/test_file_system.cc
@@ -31,7 +31,7 @@ std::string TestFileSystem::TestOpen() {
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
- // Open aborted (see the DirectoryReader test for comments).
+ // Open aborted.
int32_t rv = 0;
{
pp::FileSystem fs(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index c8f1ae7..707e0e5 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -12,8 +12,6 @@
PROXIED_IFACE(PPB_Instance, "PPB_Console(Dev);0.1", PPB_Console_1_0)
PROXIED_IFACE(NoAPIName, PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4,
PPB_CursorControl_Dev_0_4)
-PROXIED_IFACE(NoAPIName, PPB_DIRECTORYREADER_DEV_INTERFACE_0_6,
- PPB_DirectoryReader_Dev_0_6)
PROXIED_IFACE(NoAPIName, PPB_EXT_ALARMS_DEV_INTERFACE_0_1,
PPB_Ext_Alarms_Dev_0_1)
PROXIED_IFACE(NoAPIName, PPB_EXT_SOCKET_DEV_INTERFACE_0_1,
diff --git a/ppapi/thunk/ppb_directory_reader_api.h b/ppapi/thunk/ppb_directory_reader_api.h
deleted file mode 100644
index cf71ddf..0000000
--- a/ppapi/thunk/ppb_directory_reader_api.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_THUNK_DIRECTORY_READER_API_H_
-#define PPAPI_THUNK_DIRECTORY_READER_API_H_
-
-#include "base/memory/ref_counted.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
-
-namespace ppapi {
-
-class TrackedCallback;
-
-namespace thunk {
-
-class PPB_DirectoryReader_API {
- public:
- virtual ~PPB_DirectoryReader_API() {}
-
- virtual int32_t ReadEntries(const PP_ArrayOutput& output,
- scoped_refptr<TrackedCallback> callback) = 0;
-};
-
-} // namespace thunk
-} // namespace ppapi
-
-#endif // PPAPI_THUNK_DIRECTORY_READER_API_H_
diff --git a/ppapi/thunk/ppb_directory_reader_thunk.cc b/ppapi/thunk/ppb_directory_reader_thunk.cc
deleted file mode 100644
index aaee6f7..0000000
--- a/ppapi/thunk/ppb_directory_reader_thunk.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/shared_impl/proxy_lock.h"
-#include "ppapi/shared_impl/tracked_callback.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/thunk.h"
-#include "ppapi/thunk/ppb_directory_reader_api.h"
-#include "ppapi/thunk/resource_creation_api.h"
-
-namespace ppapi {
-namespace thunk {
-
-namespace {
-
-PP_Resource Create(PP_Resource directory_ref) {
- ppapi::ProxyAutoLock lock;
- Resource* object =
- PpapiGlobals::Get()->GetResourceTracker()->GetResource(directory_ref);
- if (!object)
- return 0;
- EnterResourceCreationNoLock enter(object->pp_instance());
- if (enter.failed())
- return 0;
- return enter.functions()->CreateDirectoryReader(
- object->pp_instance(), directory_ref);
-}
-
-PP_Bool IsDirectoryReader(PP_Resource resource) {
- EnterResource<PPB_DirectoryReader_API> enter(resource, false);
- return PP_FromBool(enter.succeeded());
-}
-
-int32_t ReadEntries(PP_Resource directory_reader,
- PP_ArrayOutput output,
- PP_CompletionCallback callback) {
- EnterResource<PPB_DirectoryReader_API> enter(
- directory_reader, callback, true);
- if (enter.failed())
- return enter.retval();
- return enter.SetResult(enter.object()->ReadEntries(output, enter.callback()));
-}
-
-const PPB_DirectoryReader_Dev g_ppb_directory_reader_thunk = {
- &Create,
- &IsDirectoryReader,
- &ReadEntries
-};
-
-} // namespace
-
-const PPB_DirectoryReader_Dev_0_6* GetPPB_DirectoryReader_Dev_0_6_Thunk() {
- return &g_ppb_directory_reader_thunk;
-}
-
-} // namespace thunk
-} // namespace ppapi
diff --git a/ppapi/thunk/ppb_file_ref_api.h b/ppapi/thunk/ppb_file_ref_api.h
index 4ec5314..ba92b63 100644
--- a/ppapi/thunk/ppb_file_ref_api.h
+++ b/ppapi/thunk/ppb_file_ref_api.h
@@ -5,6 +5,9 @@
#ifndef PPAPI_THUNK_PPB_FILE_REF_API_H_
#define PPAPI_THUNK_PPB_FILE_REF_API_H_
+#include <vector>
+
+#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "ppapi/c/ppb_file_ref.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
@@ -34,6 +37,24 @@ class PPAPI_THUNK_EXPORT PPB_FileRef_API {
scoped_refptr<TrackedCallback> callback) = 0;
virtual int32_t Query(PP_FileInfo* info,
scoped_refptr<TrackedCallback> callback) = 0;
+ virtual int32_t ReadDirectoryEntries(
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) = 0;
+ // We define variants of Query and ReadDirectoryEntries because
+ // 1. we need to take linked_ptr instead of raw pointers to avoid
+ // use-after-free, and 2. we don't use PP_ArrayOutput for the
+ // communication between renderers and the browser in
+ // ReadDirectoryEntries. The *InHost functions must not be called in
+ // plugins, and Query and ReadDirectoryEntries must not be called in
+ // renderers.
+ // TODO(hamaji): These functions must be removed when we move
+ // FileRef to the new resource design. http://crbug.com/225441
+ virtual int32_t QueryInHost(linked_ptr<PP_FileInfo> info,
+ scoped_refptr<TrackedCallback> callback) = 0;
+ virtual int32_t ReadDirectoryEntriesInHost(
+ linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
+ linked_ptr<std::vector<PP_FileType> > file_types,
+ scoped_refptr<TrackedCallback> callback) = 0;
// Internal function for use in proxying. Returns the internal CreateInfo
// (the contained resource does not carry a ref on behalf of the caller).
diff --git a/ppapi/thunk/ppb_file_ref_thunk.cc b/ppapi/thunk/ppb_file_ref_thunk.cc
index 6a78c76..beb0e41 100644
--- a/ppapi/thunk/ppb_file_ref_thunk.cc
+++ b/ppapi/thunk/ppb_file_ref_thunk.cc
@@ -127,6 +127,16 @@ int32_t Query(PP_Resource file_ref,
enter.callback()));
}
+int32_t ReadDirectoryEntries(PP_Resource file_ref,
+ PP_ArrayOutput output,
+ PP_CompletionCallback callback) {
+ EnterFileRef enter(file_ref, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->ReadDirectoryEntries(
+ output, enter.callback()));
+}
+
PP_Var GetAbsolutePath(PP_Resource file_ref) {
VLOG(4) << "PPB_FileRef::GetAbsolutePath";
EnterFileRef enter(file_ref, true);
@@ -159,7 +169,8 @@ const PPB_FileRef_1_1 g_ppb_file_ref_thunk_1_1 = {
&Touch,
&Delete,
&Rename,
- &Query
+ &Query,
+ &ReadDirectoryEntries
};
const PPB_FileRefPrivate g_ppb_file_ref_private_thunk = {
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 0581239..0eb4f83 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -43,8 +43,6 @@ class ResourceCreationAPI {
public:
virtual ~ResourceCreationAPI() {}
- virtual PP_Resource CreateDirectoryReader(PP_Instance instance,
- PP_Resource directory_ref) = 0;
virtual PP_Resource CreateFileIO(PP_Instance instance) = 0;
virtual PP_Resource CreateFileRef(PP_Instance instance,
PP_Resource file_system,