summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 11:41:40 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 11:41:40 +0000
commit7d0c1d8224d6a1ae41ffa6195cdf13d70f4bd437 (patch)
tree9abeed53de0f24f31400904b5adbd9ff52f065bc /webkit
parent015e37054a505efcdff6823c31fceca470416270 (diff)
downloadchromium_src-7d0c1d8224d6a1ae41ffa6195cdf13d70f4bd437.zip
chromium_src-7d0c1d8224d6a1ae41ffa6195cdf13d70f4bd437.tar.gz
chromium_src-7d0c1d8224d6a1ae41ffa6195cdf13d70f4bd437.tar.bz2
Implement Pepper proxy for PPB_DirectoryReader
This patch includes: - Adding proxy implementation (DircetoryReaderResource and PepperDirectoryReaderHost) - Merging PPB_DirectoryReader_impl into PepperDirectoryReaderHost BUG=106129 TEST=browser_tests --gtest_filter=\*DirectoryReader\* Review URL: https://chromiumcodereview.appspot.com/11958033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/file_callbacks.cc15
-rw-r--r--webkit/plugins/ppapi/file_callbacks.h4
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc1
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc156
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.h55
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc9
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc3
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc4
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h3
10 files changed, 13 insertions, 239 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 34b6960..d1ff407 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -209,8 +209,6 @@
'../plugins/ppapi/ppb_broker_impl.h',
'../plugins/ppapi/ppb_buffer_impl.cc',
'../plugins/ppapi/ppb_buffer_impl.h',
- '../plugins/ppapi/ppb_directory_reader_impl.cc',
- '../plugins/ppapi/ppb_directory_reader_impl.h',
'../plugins/ppapi/ppb_file_ref_impl.cc',
'../plugins/ppapi/ppb_file_ref_impl.h',
'../plugins/ppapi/ppb_file_system_impl.cc',
diff --git a/webkit/plugins/ppapi/file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc
index dd8906d..5582d39 100644
--- a/webkit/plugins/ppapi/file_callbacks.cc
+++ b/webkit/plugins/ppapi/file_callbacks.cc
@@ -13,7 +13,6 @@
#include "ppapi/shared_impl/tracked_callback.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/plugins/ppapi/plugin_module.h"
-#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
using ppapi::Resource;
@@ -27,12 +26,10 @@ FileCallbacks::FileCallbacks(
Resource* resource,
scoped_refptr<TrackedCallback> callback,
PP_FileInfo* info,
- scoped_refptr<PPB_FileSystem_Impl> file_system,
- scoped_refptr<PPB_DirectoryReader_Impl> directory_reader)
+ scoped_refptr<PPB_FileSystem_Impl> file_system)
: callback_(callback),
info_(info),
- file_system_(file_system),
- directory_reader_(directory_reader) {
+ file_system_(file_system) {
}
FileCallbacks::~FileCallbacks() {}
@@ -67,13 +64,7 @@ void FileCallbacks::DidReadMetadata(
void FileCallbacks::DidReadDirectory(
const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
- if (callback_->completed())
- return;
-
- DCHECK(directory_reader_);
- directory_reader_->AddNewEntries(entries, has_more);
-
- callback_->Run(PP_OK);
+ NOTREACHED();
}
void FileCallbacks::DidOpenFileSystem(const std::string&,
diff --git a/webkit/plugins/ppapi/file_callbacks.h b/webkit/plugins/ppapi/file_callbacks.h
index 2e31e2f..bfa10d5 100644
--- a/webkit/plugins/ppapi/file_callbacks.h
+++ b/webkit/plugins/ppapi/file_callbacks.h
@@ -38,8 +38,7 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
FileCallbacks(::ppapi::Resource* resource,
scoped_refptr< ::ppapi::TrackedCallback> callback,
PP_FileInfo* info,
- scoped_refptr<PPB_FileSystem_Impl> file_system,
- scoped_refptr<PPB_DirectoryReader_Impl> directory_reader);
+ scoped_refptr<PPB_FileSystem_Impl> file_system);
virtual ~FileCallbacks();
// FileSystemCallbackDispatcher implementation.
@@ -62,7 +61,6 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
scoped_refptr< ::ppapi::TrackedCallback> callback_;
PP_FileInfo* info_;
scoped_refptr<PPB_FileSystem_Impl> file_system_;
- scoped_refptr<PPB_DirectoryReader_Impl> directory_reader_;
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index d021864..af3d88e 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -110,7 +110,6 @@
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/ppapi_interface_factory.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
deleted file mode 100644
index 7cd8d5d..0000000
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ /dev/null
@@ -1,156 +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 "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
-
-#include "base/logging.h"
-#include "base/utf_string_conversions.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/dev/ppb_directory_reader_dev.h"
-#include "ppapi/shared_impl/ppapi_globals.h"
-#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_file_ref_api.h"
-#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/file_callbacks.h"
-#include "webkit/plugins/ppapi/plugin_delegate.h"
-#include "webkit/plugins/ppapi/plugin_module.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
-#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
-#include "webkit/plugins/ppapi/resource_helper.h"
-
-using ::ppapi::PpapiGlobals;
-using ::ppapi::TrackedCallback;
-using ::ppapi::thunk::EnterResourceNoLock;
-using ::ppapi::thunk::PPB_DirectoryReader_API;
-using ::ppapi::thunk::PPB_FileRef_API;
-
-namespace webkit {
-namespace ppapi {
-
-namespace {
-
-std::string FilePathStringToUTF8String(const base::FilePath::StringType& str) {
-#if defined(OS_WIN)
- return WideToUTF8(str);
-#elif defined(OS_POSIX)
- return str;
-#else
-#error "Unsupported platform."
-#endif
-}
-
-base::FilePath::StringType UTF8StringToFilePathString(const std::string& str) {
-#if defined(OS_WIN)
- return UTF8ToWide(str);
-#elif defined(OS_POSIX)
- return str;
-#else
-#error "Unsupported platform."
-#endif
-}
-
-} // namespace
-
-PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
- PPB_FileRef_Impl* directory_ref)
- : Resource(::ppapi::OBJECT_IS_IMPL, directory_ref->pp_instance()),
- directory_ref_(directory_ref),
- has_more_(true),
- entry_(NULL) {
-}
-
-PPB_DirectoryReader_Impl::~PPB_DirectoryReader_Impl() {
-}
-
-// static
-PP_Resource PPB_DirectoryReader_Impl::Create(PP_Resource directory_ref) {
- EnterResourceNoLock<PPB_FileRef_API> enter(directory_ref, true);
- if (enter.failed())
- return 0;
- return (new PPB_DirectoryReader_Impl(
- static_cast<PPB_FileRef_Impl*>(enter.object())))->GetReference();
-}
-
-PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
- return this;
-}
-
-int32_t PPB_DirectoryReader_Impl::GetNextEntry(
- PP_DirectoryEntry_Dev* entry,
- scoped_refptr<TrackedCallback> callback) {
- if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
- return PP_ERROR_FAILED;
-
- entry_ = entry;
- if (FillUpEntry()) {
- entry_ = NULL;
- return PP_OK;
- }
- PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
- if (!plugin_instance)
- return PP_ERROR_FAILED;
-
- if (!plugin_instance->delegate()->ReadDirectory(
- directory_ref_->GetFileSystemURL(),
- new FileCallbacks(this, callback, NULL, NULL, this)))
- return PP_ERROR_FAILED;
-
- return PP_OK_COMPLETIONPENDING;
-}
-
-void PPB_DirectoryReader_Impl::AddNewEntries(
- const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
- DCHECK(!entries.empty() || !has_more);
- has_more_ = has_more;
-
- std::string dir_path = directory_ref_->GetCreateInfo().path;
- if (dir_path[dir_path.size() - 1] != '/')
- dir_path += '/';
- base::FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path);
- for (std::vector<base::FileUtilProxy::Entry>::const_iterator it =
- entries.begin(); it != entries.end(); it++) {
- base::FileUtilProxy::Entry entry;
- entry.name = dir_file_path + it->name;
- entry.is_directory = it->is_directory;
- entries_.push(entry);
- }
-
- FillUpEntry();
- entry_ = NULL;
-}
-
-bool PPB_DirectoryReader_Impl::FillUpEntry() {
- DCHECK(entry_);
- if (!entries_.empty()) {
- base::FileUtilProxy::Entry dir_entry = entries_.front();
- entries_.pop();
- if (entry_->file_ref) {
- PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
- entry_->file_ref);
- }
-
- PPB_FileRef_Impl* file_ref = PPB_FileRef_Impl::CreateInternal(
- directory_ref_->file_system()->pp_resource(),
- FilePathStringToUTF8String(dir_entry.name));
- if (!file_ref)
- return false;
- entry_->file_ref = file_ref->GetReference();
- entry_->file_type =
- (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
- return true;
- }
-
- if (!has_more_) {
- entry_->file_ref = 0;
- return true;
- }
-
- return false;
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
deleted file mode 100644
index 9e563c5..0000000
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.h
+++ /dev/null
@@ -1,55 +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 WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_
-
-#include <queue>
-#include <vector>
-
-#include "base/files/file_util_proxy.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/thunk/ppb_directory_reader_api.h"
-
-struct PP_DirectoryEntry_Dev;
-
-namespace webkit {
-namespace ppapi {
-
-class PPB_FileRef_Impl;
-
-class PPB_DirectoryReader_Impl
- : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_DirectoryReader_API {
- public:
- explicit PPB_DirectoryReader_Impl(PPB_FileRef_Impl* directory_ref);
- virtual ~PPB_DirectoryReader_Impl();
-
- static PP_Resource Create(PP_Resource directory_ref);
-
- // Resource overrides.
- virtual ::ppapi::thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API()
- OVERRIDE;
-
- // PPB_DirectoryReader_API implementation.
- virtual int32_t GetNextEntry(
- PP_DirectoryEntry_Dev* entry,
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
-
- void AddNewEntries(const std::vector<base::FileUtilProxy::Entry>& entries,
- bool has_more);
-
- private:
- bool FillUpEntry();
-
- scoped_refptr<PPB_FileRef_Impl> directory_ref_;
- std::queue<base::FileUtilProxy::Entry> entries_;
- bool has_more_;
- PP_DirectoryEntry_Dev* entry_;
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index ec785e4..ed0ba92 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -18,7 +18,6 @@
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
@@ -178,7 +177,7 @@ int32_t PPB_FileRef_Impl::MakeDirectory(
return PP_ERROR_FAILED;
if (!plugin_instance->delegate()->MakeDirectory(
GetFileSystemURL(), PP_ToBool(make_ancestors),
- new FileCallbacks(this, callback, NULL, NULL, NULL)))
+ new FileCallbacks(this, callback, NULL, NULL)))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
@@ -196,7 +195,7 @@ int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
GetFileSystemURL(),
PPTimeToTime(last_access_time),
PPTimeToTime(last_modified_time),
- new FileCallbacks(this, callback, NULL, NULL, NULL)))
+ new FileCallbacks(this, callback, NULL, NULL)))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
@@ -210,7 +209,7 @@ int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) {
return PP_ERROR_FAILED;
if (!plugin_instance->delegate()->Delete(
GetFileSystemURL(),
- new FileCallbacks(this, callback, NULL, NULL, NULL)))
+ new FileCallbacks(this, callback, NULL, NULL)))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
@@ -234,7 +233,7 @@ int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
return PP_ERROR_FAILED;
if (!plugin_instance->delegate()->Rename(
GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
- new FileCallbacks(this, callback, NULL, NULL, NULL)))
+ new FileCallbacks(this, callback, NULL, NULL)))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index 441a942..f08e0e0 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -17,7 +17,6 @@
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::thunk::PPB_FileSystem_API;
@@ -83,7 +82,7 @@ int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
GetOrigin(),
file_system_type, expected_size,
new FileCallbacks(this, callback, NULL,
- scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
+ scoped_refptr<PPB_FileSystem_Impl>(this))))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 2fc7385..d7be266 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -13,7 +13,6 @@
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "webkit/plugins/ppapi/ppb_broker_impl.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
-#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/ppb_flash_message_loop_impl.h"
@@ -78,8 +77,9 @@ PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
}
PP_Resource ResourceCreationImpl::CreateDirectoryReader(
+ PP_Instance instance,
PP_Resource directory_ref) {
- return PPB_DirectoryReader_Impl::Create(directory_ref);
+ return 0; // Not supported in-process.
}
PP_Resource ResourceCreationImpl::CreateFileRef(PP_Resource file_system,
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 27a69f4..414df16 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -34,7 +34,8 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl
virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateBuffer(PP_Instance instance,
uint32_t size) OVERRIDE;
- virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) OVERRIDE;
+ virtual PP_Resource CreateDirectoryReader(PP_Instance instance,
+ PP_Resource directory_ref) OVERRIDE;
virtual PP_Resource CreateFileRef(PP_Resource file_system,
const char* path) OVERRIDE;
virtual PP_Resource CreateFileSystem(PP_Instance instance,