Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: webkit/plugins/ppapi/file_callbacks.h

Issue 14784002: Move DirectoryReader::ReadEntries to FileRef::ReadDirectoryEntries (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address comments by dmichael and raymes Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/file_callbacks.h
diff --git a/webkit/plugins/ppapi/file_callbacks.h b/webkit/plugins/ppapi/file_callbacks.h
index c45932ab885a44532ab692201798f4b27544bbac..2727f164a7822dff209c40765cefa3bb6e8cb689 100644
--- a/webkit/plugins/ppapi/file_callbacks.h
+++ b/webkit/plugins/ppapi/file_callbacks.h
@@ -8,10 +8,12 @@
#include <string>
#include <vector>
+#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "googleurl/src/gurl.h"
+#include "ppapi/c/pp_array_output.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_resource.h"
@@ -26,21 +28,66 @@ class FilePath;
namespace ppapi {
class Resource;
class TrackedCallback;
+struct PPB_FileRef_CreateInfo;
}
namespace webkit {
namespace ppapi {
+class PPB_FileRef_Impl;
+
+// A wrapper class which encapsulates the difference between
+// linked_ptr and a raw pointer. For in-process mode, the caller must
+// maintain the lifetime of heap objects so we use a raw pointer.
+// Renderers in out-of-process mode will use a linked_ptr because
+// it's renderers' responsibility to manage the lifetime of the heap
+// objects properly.
+template <class T> class maybe_linked_ptr {
+ public:
+ maybe_linked_ptr()
+ : raw_(NULL) {
+ }
+ explicit maybe_linked_ptr(T* p)
+ : raw_(p) {
+ }
+ explicit maybe_linked_ptr(linked_ptr<T> p)
+ : raw_(NULL), linked_(p) {
+ }
+
+ T* get() const {
+ return raw_ ? raw_ : linked_.get();
+ }
+ T* operator->() const {
+ return get();
+ }
+
+ private:
+ T* raw_;
+ linked_ptr<T> linked_;
+};
+
// Instances of this class are deleted by FileSystemDispatcher.
class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
+ typedef std::vector< ::ppapi::PPB_FileRef_CreateInfo> CreateInfos;
+ typedef std::vector<PP_FileType> FileTypes;
+
public:
+ // Doesn't take the ownership of members.
+ struct ReadDirectoryEntriesParams {
+ PPB_FileRef_Impl* dir_ref;
+ linked_ptr<CreateInfos> files;
+ linked_ptr<FileTypes> file_types;
+ };
+
FileCallbacks(::ppapi::Resource* resource,
- scoped_refptr< ::ppapi::TrackedCallback> callback,
- PP_FileInfo* info);
+ scoped_refptr< ::ppapi::TrackedCallback> callback);
FileCallbacks(::ppapi::Resource* resource,
scoped_refptr< ::ppapi::TrackedCallback> callback,
- PP_FileInfo* info,
+ maybe_linked_ptr<PP_FileInfo> info,
PP_FileSystemType file_system_type);
+ FileCallbacks(::ppapi::Resource* resource,
+ scoped_refptr< ::ppapi::TrackedCallback> callback,
+ const ReadDirectoryEntriesParams& params);
virtual ~FileCallbacks();
// FileSystemCallbackDispatcher implementation.
@@ -64,8 +111,11 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
void RunCallback(base::PlatformFileError error_code);
scoped_refptr< ::ppapi::TrackedCallback> callback_;
- PP_FileInfo* info_;
+ maybe_linked_ptr<PP_FileInfo> info_;
PP_FileSystemType file_system_type_;
+ PPB_FileRef_Impl* read_entries_dir_ref_;
+ linked_ptr<CreateInfos> read_entries_files_;
+ linked_ptr<FileTypes> read_entries_file_types_;
};
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698