summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc37
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc23
4 files changed, 44 insertions, 28 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index b074596..1460b27 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -86,24 +86,25 @@ int32_t PPB_FileIO_Impl::Open(PP_Resource pp_file_ref,
return false;
file_system_type_ = file_ref->GetFileSystemType();
- switch (file_system_type_) {
- case PP_FILESYSTEMTYPE_EXTERNAL:
- if (!plugin_delegate->AsyncOpenFile(
- file_ref->GetSystemPath(), flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
- return PP_ERROR_FAILED;
- break;
- case PP_FILESYSTEMTYPE_LOCALPERSISTENT:
- case PP_FILESYSTEMTYPE_LOCALTEMPORARY:
- file_system_url_ = file_ref->GetFileSystemURL();
- if (!plugin_delegate->AsyncOpenFileSystemURL(
- file_system_url_, flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
- return PP_ERROR_FAILED;
- break;
- default:
+ if (file_system_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
+ file_system_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
+ return PP_ERROR_FAILED;
+
+ if (file_ref->HasValidFileSystem()) {
+ file_system_url_ = file_ref->GetFileSystemURL();
+ if (!plugin_delegate->AsyncOpenFileSystemURL(
+ file_system_url_, flags,
+ callback_factory_.NewCallback(
+ &PPB_FileIO_Impl::AsyncOpenFileCallback)))
+ return PP_ERROR_FAILED;
+ } else {
+ if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
+ return PP_ERROR_FAILED;
+ if (!plugin_delegate->AsyncOpenFile(
+ file_ref->GetSystemPath(), flags,
+ callback_factory_.NewCallback(
+ &PPB_FileIO_Impl::AsyncOpenFileCallback)))
return PP_ERROR_FAILED;
}
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index 7c43ba4..673ec01 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -108,7 +108,8 @@ PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Resource pp_file_system,
return 0;
if (file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
+ file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ file_system->type() != PP_FILESYSTEMTYPE_EXTERNAL)
return 0;
PPB_FileRef_CreateInfo info;
@@ -253,7 +254,8 @@ FilePath PPB_FileRef_Impl::GetSystemPath() const {
GURL PPB_FileRef_Impl::GetFileSystemURL() const {
if (GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY) {
+ GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) {
NOTREACHED();
return GURL();
}
@@ -269,6 +271,10 @@ GURL PPB_FileRef_Impl::GetFileSystemURL() const {
return GURL(file_system_->root_url().spec() + virtual_path.substr(1));
}
+bool PPB_FileRef_Impl::HasValidFileSystem() const {
+ return file_system_ && file_system_->opened();
+}
+
bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
return file_system_ && file_system_->opened() &&
file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL;
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
index de1649d..64926de 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -53,6 +53,8 @@ class PPB_FileRef_Impl : public ::ppapi::FileRefImpl {
// Returns the FileSystem API URL corresponding to this file.
GURL GetFileSystemURL() const;
+ // Checks if file ref has file system instance and if the instance is opened.
+ bool HasValidFileSystem() const;
private:
// Many mutation functions are allow only to non-external filesystems, This
// function returns true if the filesystem is opened and isn't external as an
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index a63e954..b7576bc 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -61,18 +61,25 @@ int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
return PP_ERROR_INPROGRESS;
called_open_ = true;
- if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
- return PP_ERROR_FAILED;
+ fileapi::FileSystemType file_system_type;
+ switch (type_) {
+ case PP_FILESYSTEMTYPE_LOCALTEMPORARY:
+ file_system_type = fileapi::kFileSystemTypeTemporary;
+ break;
+ case PP_FILESYSTEMTYPE_LOCALPERSISTENT:
+ file_system_type = fileapi::kFileSystemTypePersistent;
+ break;
+ case PP_FILESYSTEMTYPE_EXTERNAL:
+ file_system_type = fileapi::kFileSystemTypeExternal;
+ break;
+ default:
+ return PP_ERROR_FAILED;
+ }
- PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
- fileapi::FileSystemType file_system_type =
- (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
- fileapi::kFileSystemTypeTemporary :
- fileapi::kFileSystemTypePersistent);
if (!plugin_instance->delegate()->OpenFileSystem(
plugin_instance->container()->element().document().url(),
file_system_type, expected_size,