summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_file_system_impl.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
commitbbf076f18dbb27fba74de06f4994aa1480690ea3 (patch)
tree6dcabc6d408c997b18f8762fee0fac8470770fb4 /webkit/plugins/ppapi/ppb_file_system_impl.cc
parent081c03452bb7d97b138bed3ccc7cbe0903eae05c (diff)
downloadchromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.zip
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.gz
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.bz2
Remove webkit::ppapi::Resource.
This makes all resource _impl's derive directly from ppapi::Resource so we can share code better. This means removing PluginInstances and converting them to PP_Instances. This adds a new ResourceHelper static class to help in the conversion of resources to PluginInstances for the _impl classes. Overall the new code is in general slightly worse than the old because using the ResourceHelper is more annoying than just calling instance() on the old webkit::ppapi::Resource object. However, I'm hoping that, because this will allow us to move more code into shared_impl and reduce duplicate logic, it will eventually have a net positive effect. This also adds a ScopedPPResource class that works just like a scoped_refptr. We need this in a few places. Most of the places that used the old ScopedResourceId class could be removed now since resources have PP_Resource IDs generated even when there's no plugin reference (this didn't use to be the case) so we can pass resources as input params to the plugin even when there's no plugin ref, as long as there's a scoped_refptr to the Resource. Review URL: http://codereview.chromium.org/7669055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_file_system_impl.cc')
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index 2a4bb05..ac9f900 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -18,18 +18,16 @@
#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.h"
-#include "webkit/plugins/ppapi/resource_tracker.h"
+#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::thunk::PPB_FileSystem_API;
namespace webkit {
namespace ppapi {
-PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
+PPB_FileSystem_Impl::PPB_FileSystem_Impl(PP_Instance instance,
PP_FileSystemType type)
: Resource(instance),
- instance_(instance),
type_(type),
opened_(false),
called_open_(false) {
@@ -40,7 +38,7 @@ PPB_FileSystem_Impl::~PPB_FileSystem_Impl() {
}
// static
-PP_Resource PPB_FileSystem_Impl::Create(PluginInstance* instance,
+PP_Resource PPB_FileSystem_Impl::Create(PP_Instance instance,
PP_FileSystemType type) {
if (type != PP_FILESYSTEMTYPE_EXTERNAL &&
type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
@@ -64,14 +62,18 @@ int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
return PP_ERROR_FAILED;
+ 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 (!instance()->delegate()->OpenFileSystem(
- instance()->container()->element().document().url(),
+ if (!plugin_instance->delegate()->OpenFileSystem(
+ plugin_instance->container()->element().document().url(),
file_system_type, expected_size,
- new FileCallbacks(instance()->module()->AsWeakPtr(),
+ new FileCallbacks(plugin_instance->module()->AsWeakPtr(),
pp_resource(), callback, NULL,
scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
return PP_ERROR_FAILED;