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

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

Issue 14784002: Move DirectoryReader::ReadEntries to FileRef::ReadDirectoryEntries (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased 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
« no previous file with comments | « webkit/plugins/ppapi/file_callbacks.h ('k') | webkit/plugins/ppapi/mock_plugin_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/file_callbacks.cc
diff --git a/webkit/plugins/ppapi/file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc
index fedf583dc9b572e94f7afd95fba8fba6c3df0fe3..d75def959d3989c5780c33dc6a7ecdc3a361ce4a 100644
--- a/webkit/plugins/ppapi/file_callbacks.cc
+++ b/webkit/plugins/ppapi/file_callbacks.cc
@@ -5,14 +5,18 @@
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_file_system.h"
#include "ppapi/shared_impl/file_type_conversion.h"
+#include "ppapi/shared_impl/ppb_file_ref_shared.h"
#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "webkit/fileapi/file_system_types.h"
+#include "webkit/fileapi/file_system_util.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
using ppapi::Resource;
using ppapi::TimeToPPTime;
@@ -23,21 +27,32 @@ namespace ppapi {
FileCallbacks::FileCallbacks(
Resource* resource,
- scoped_refptr<TrackedCallback> callback,
- PP_FileInfo* info)
+ scoped_refptr<TrackedCallback> callback)
: callback_(callback),
- info_(info),
- file_system_type_(PP_FILESYSTEMTYPE_INVALID) {
+ file_system_type_(PP_FILESYSTEMTYPE_INVALID),
+ read_entries_dir_ref_(NULL) {
}
FileCallbacks::FileCallbacks(
Resource* resource,
scoped_refptr<TrackedCallback> callback,
- PP_FileInfo* info,
+ linked_ptr<PP_FileInfo> info,
PP_FileSystemType file_system_type)
: callback_(callback),
info_(info),
- file_system_type_(file_system_type) {
+ file_system_type_(file_system_type),
+ read_entries_dir_ref_(NULL) {
+}
+
+FileCallbacks::FileCallbacks(
+ ::ppapi::Resource* resource,
+ scoped_refptr< ::ppapi::TrackedCallback> callback,
+ const ReadDirectoryEntriesParams& params)
+ : callback_(callback),
+ file_system_type_(PP_FILESYSTEMTYPE_INVALID),
+ read_entries_dir_ref_(params.dir_ref),
+ read_entries_files_(params.files),
+ read_entries_file_types_(params.file_types) {
}
FileCallbacks::~FileCallbacks() {}
@@ -55,7 +70,7 @@ void FileCallbacks::DidReadMetadata(
if (callback_->completed())
return;
- DCHECK(info_);
+ DCHECK(info_.get());
info_->size = file_info.size;
info_->creation_time = TimeToPPTime(file_info.creation_time);
info_->last_access_time = TimeToPPTime(file_info.last_accessed);
@@ -77,7 +92,35 @@ void FileCallbacks::DidCreateSnapshotFile(
void FileCallbacks::DidReadDirectory(
const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
- NOTREACHED();
+ if (callback_->completed())
+ return;
+
+ // The current filesystem backend always returns false.
+ DCHECK(!has_more);
+
+ DCHECK(read_entries_dir_ref_);
+ DCHECK(read_entries_files_.get());
+ DCHECK(read_entries_file_types_.get());
+
+ std::string dir_path = read_entries_dir_ref_->GetCreateInfo().path;
+ if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/')
+ dir_path += '/';
+
+ for (size_t i = 0; i < entries.size(); ++i) {
+ const base::FileUtilProxy::Entry& entry = entries[i];
+ scoped_refptr<PPB_FileRef_Impl> file_ref(PPB_FileRef_Impl::CreateInternal(
+ read_entries_dir_ref_->pp_instance(),
+ read_entries_dir_ref_->file_system_resource(),
+ dir_path + fileapi::FilePathToString(base::FilePath(entry.name))));
+ read_entries_files_->push_back(file_ref->GetCreateInfo());
+ read_entries_file_types_->push_back(
+ entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
+ // Add a ref count on behalf of the plugin side.
+ file_ref->GetReference();
+ }
+ CHECK_EQ(read_entries_files_->size(), read_entries_file_types_->size());
+
+ callback_->Run(PP_OK);
}
void FileCallbacks::DidOpenFileSystem(const std::string&,
« no previous file with comments | « webkit/plugins/ppapi/file_callbacks.h ('k') | webkit/plugins/ppapi/mock_plugin_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698