Index: webkit/plugins/ppapi/ppb_file_ref_impl.cc |
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc |
index dfaa56919bbc8003d38a26d87a0f8b2f04b4b9da..104a304735ba2277eddb568af9a075a12361fffc 100644 |
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc |
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc |
@@ -20,7 +20,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_file_system_impl.h" |
#include "webkit/plugins/ppapi/resource_helper.h" |
using ppapi::HostResource; |
@@ -149,7 +148,7 @@ void QueryCallback(scoped_refptr<base::TaskRunner> task_runner, |
} // namespace |
PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, |
- PPB_FileSystem_Impl* file_system) |
+ PP_Resource file_system) |
: PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info), |
file_system_(file_system), |
external_file_system_path_() { |
@@ -166,25 +165,25 @@ PPB_FileRef_Impl::~PPB_FileRef_Impl() { |
} |
// static |
-PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Resource pp_file_system, |
+PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, |
+ PP_Resource pp_file_system, |
const std::string& path) { |
- EnterResourceNoLock<PPB_FileSystem_API> enter(pp_file_system, true); |
- if (enter.failed()) |
- return 0; |
- |
- PPB_FileSystem_Impl* file_system = |
- static_cast<PPB_FileSystem_Impl*>(enter.object()); |
- if (!file_system->pp_instance()) |
+ PluginInstance* plugin_instance = |
+ ResourceHelper::PPInstanceToPluginInstance(instance); |
+ if (!plugin_instance || !plugin_instance->delegate()) |
return 0; |
- if (file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
- file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
- file_system->type() != PP_FILESYSTEMTYPE_EXTERNAL) |
+ PP_FileSystemType type = |
+ plugin_instance->delegate()->GetFileSystemType(instance, pp_file_system); |
+ if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
+ type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
+ type != PP_FILESYSTEMTYPE_EXTERNAL) |
return 0; |
PPB_FileRef_CreateInfo info; |
- info.resource = HostResource::MakeInstanceOnly(file_system->pp_instance()); |
- info.file_system_type = file_system->type(); |
+ info.resource = HostResource::MakeInstanceOnly(instance); |
+ info.file_system_plugin_resource = pp_file_system; |
+ info.file_system_type = type; |
// Validate the path. |
info.path = path; |
@@ -194,7 +193,10 @@ PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Resource pp_file_system, |
info.name = GetNameForVirtualFilePath(info.path); |
- return new PPB_FileRef_Impl(info, file_system); |
+ PPB_FileRef_Impl* file_ref = new PPB_FileRef_Impl(info, pp_file_system); |
+ if (plugin_instance->delegate()->IsRunningInProcess(instance)) |
+ file_ref->AddFileSystemRefCount(); |
+ return file_ref; |
} |
// static |
@@ -204,6 +206,7 @@ PPB_FileRef_Impl* PPB_FileRef_Impl::CreateExternal( |
const std::string& display_name) { |
PPB_FileRef_CreateInfo info; |
info.resource = HostResource::MakeInstanceOnly(instance); |
+ info.file_system_plugin_resource = 0; |
info.file_system_type = PP_FILESYSTEMTYPE_EXTERNAL; |
if (display_name.empty()) |
info.name = GetNameForExternalFilePath(external_file_path); |
@@ -229,7 +232,7 @@ PP_Resource PPB_FileRef_Impl::GetParent() { |
std::string parent_path = virtual_path.substr(0, pos); |
scoped_refptr<PPB_FileRef_Impl> parent_ref( |
- CreateInternal(file_system_->pp_resource(), parent_path)); |
+ CreateInternal(pp_instance(), file_system_, parent_path)); |
if (!parent_ref.get()) |
return 0; |
return parent_ref->GetReference(); |
@@ -246,7 +249,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))) |
+ new FileCallbacks(this, callback, NULL))) |
return PP_ERROR_FAILED; |
return PP_OK_COMPLETIONPENDING; |
} |
@@ -264,7 +267,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))) |
+ new FileCallbacks(this, callback, NULL))) |
return PP_ERROR_FAILED; |
return PP_OK_COMPLETIONPENDING; |
} |
@@ -278,7 +281,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))) |
+ new FileCallbacks(this, callback, NULL))) |
return PP_ERROR_FAILED; |
return PP_OK_COMPLETIONPENDING; |
} |
@@ -292,7 +295,7 @@ int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref, |
static_cast<PPB_FileRef_Impl*>(enter.object()); |
if (!IsValidNonExternalFileSystem() || |
- file_system_.get() != new_file_ref->file_system_.get()) |
+ file_system_ != new_file_ref->file_system_) |
return PP_ERROR_NOACCESS; |
// TODO(viettrungluu): Also cancel when the new file ref is destroyed? |
@@ -302,7 +305,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))) |
+ new FileCallbacks(this, callback, NULL))) |
return PP_ERROR_FAILED; |
return PP_OK_COMPLETIONPENDING; |
} |
@@ -340,17 +343,30 @@ GURL PPB_FileRef_Impl::GetFileSystemURL() const { |
// We need to trim off the '/' before calling Resolve, as FileSystem URLs |
// start with a storage type identifier that looks like a path segment. |
- return file_system_->root_url().Resolve( |
- net::EscapePath(virtual_path.substr(1))); |
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
+ PluginDelegate* delegate = |
+ plugin_instance ? plugin_instance->delegate() : NULL; |
+ if (!delegate) |
+ return GURL(); |
+ return GURL(delegate->GetFileSystemRootUrl(pp_instance(), file_system_)) |
+ .Resolve(net::EscapePath(virtual_path.substr(1))); |
} |
-bool PPB_FileRef_Impl::HasValidFileSystem() const { |
- return file_system_ && file_system_->opened(); |
+bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { |
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
+ PluginDelegate* delegate = |
+ plugin_instance ? plugin_instance->delegate() : NULL; |
+ return delegate && |
+ delegate->IsFileSystemOpened(pp_instance(), file_system_) && |
+ delegate->GetFileSystemType(pp_instance(), file_system_) != |
+ PP_FILESYSTEMTYPE_EXTERNAL; |
} |
-bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { |
- return file_system_ && file_system_->opened() && |
- file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; |
+bool PPB_FileRef_Impl::HasValidFileSystem() const { |
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
+ PluginDelegate* delegate = |
+ plugin_instance ? plugin_instance->delegate() : NULL; |
+ return delegate && delegate->IsFileSystemOpened(pp_instance(), file_system_); |
} |
int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, |
@@ -377,9 +393,17 @@ int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, |
if (!HasValidFileSystem()) |
return PP_ERROR_NOACCESS; |
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
+ PluginDelegate* delegate = |
+ plugin_instance ? plugin_instance->delegate() : NULL; |
+ if (!delegate) |
+ return PP_ERROR_FAILED; |
+ |
if (!plugin_instance->delegate()->Query( |
GetFileSystemURL(), |
- new FileCallbacks(this, callback, info, file_system_))) |
+ new FileCallbacks(this, callback, info, |
+ delegate->GetFileSystemType(pp_instance(), |
+ file_system_)))) |
return PP_ERROR_FAILED; |
} |