summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 05:51:27 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 05:51:27 +0000
commit4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5 (patch)
tree4b27e9a2b6f932059c57c20aed2f4841f5a15d0a /webkit
parent2f89b6045896d8e8efc3984da72c3bf4c63d6e0f (diff)
downloadchromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.zip
chromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.tar.gz
chromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.tar.bz2
Revert 87415 - Convert more interfaces to the new thunk system. This goes up to and including
the ones starting with "F". Since this adds a lot more interfaces, I added the macro stuff we used for the old system to generate the various template specializations. This involded a lot of renaming since the As* needs to match the name (I was previously leaving off the "PPB_" part). I did other misc cleanup to the infrastructure. Review URL: http://codereview.chromium.org/7082036 TBR=brettw@chromium.org Review URL: http://codereview.chromium.org/7006022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc14
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc33
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h2
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc7
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.h6
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc59
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.h21
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc75
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.h18
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc182
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.h76
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc335
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h44
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc92
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.h23
-rw-r--r--webkit/plugins/ppapi/ppb_find_impl.cc41
-rw-r--r--webkit/plugins/ppapi/ppb_find_impl.h46
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h2
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc33
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h11
-rw-r--r--webkit/plugins/ppapi/resource_tracker.cc7
-rw-r--r--webkit/plugins/ppapi/resource_tracker.h5
36 files changed, 670 insertions, 491 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 0ee2ac0..73dae78 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -258,8 +258,6 @@
'../plugins/ppapi/ppb_file_ref_impl.h',
'../plugins/ppapi/ppb_file_system_impl.cc',
'../plugins/ppapi/ppb_file_system_impl.h',
- '../plugins/ppapi/ppb_find_impl.cc',
- '../plugins/ppapi/ppb_find_impl.h',
'../plugins/ppapi/ppb_flash_clipboard_impl.cc',
'../plugins/ppapi/ppb_flash_clipboard_impl.h',
'../plugins/ppapi/ppb_flash_file_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 0f16cc1..7d5bb74 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -270,21 +270,21 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_CursorControl_Thunk();
if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_DirectoryReader_Thunk();
+ return PPB_DirectoryReader_Impl::GetInterface();
if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_FileChooser_Thunk();
+ return PPB_FileChooser_Impl::GetInterface();
if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_FileIO_Thunk();
+ return PPB_FileIO_Impl::GetInterface();
if (strcmp(name, PPB_NACL_PRIVATE_INTERFACE) == 0)
return PPB_NaCl_Private_Impl::GetInterface();
if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_FileIOTrusted_Thunk();
+ return PPB_FileIO_Impl::GetTrustedInterface();
if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_FileRef_Thunk();
+ return PPB_FileRef_Impl::GetInterface();
if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_FileSystem_Thunk();
+ return PPB_FileSystem_Impl::GetInterface();
if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_Find_Thunk();
+ return PluginInstance::GetFindInterface();
if (strcmp(name, PPB_FLASH_INTERFACE) == 0)
return PPB_Flash_Impl::GetInterface();
if (strcmp(name, PPB_FLASH_CLIPBOARD_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index e73cf09..fbbc69e 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -233,6 +233,34 @@ const PPB_Instance_Private ppb_instance_private = {
&ExecuteScript
};
+void NumberOfFindResultsChanged(PP_Instance instance_id,
+ int32_t total,
+ PP_Bool final_result) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return;
+
+ DCHECK_NE(instance->find_identifier(), -1);
+ instance->delegate()->NumberOfFindResultsChanged(
+ instance->find_identifier(), total, PPBoolToBool(final_result));
+}
+
+void SelectedFindResultChanged(PP_Instance instance_id,
+ int32_t index) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return;
+
+ DCHECK_NE(instance->find_identifier(), -1);
+ instance->delegate()->SelectedFindResultChanged(
+ instance->find_identifier(), index);
+}
+
+const PPB_Find_Dev ppb_find = {
+ &NumberOfFindResultsChanged,
+ &SelectedFindResultChanged,
+};
+
PP_Bool IsFullscreen(PP_Instance instance_id) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
@@ -382,6 +410,11 @@ const void* PluginInstance::GetInterface(const char* if_name) {
}
// static
+const PPB_Find_Dev* PluginInstance::GetFindInterface() {
+ return &ppb_find;
+}
+
+// static
const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() {
return &ppb_fullscreen;
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 6c60edc..87d86ed 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -34,6 +34,7 @@ typedef struct NPObject NPObject;
struct PP_Var;
struct PPB_Instance;
struct PPB_Instance_Private;
+struct PPB_Find_Dev;
struct PPB_Fullscreen_Dev;
struct PPB_Messaging;
struct PPB_Zoom_Dev;
@@ -96,6 +97,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// Returns a pointer to the interface implementing PPB_Find that is
// exposed to the plugin.
+ static const PPB_Find_Dev* GetFindInterface();
static const PPB_Fullscreen_Dev* GetFullscreenInterface();
static const PPB_Messaging* GetMessagingInterface();
static const PPB_Zoom_Dev* GetZoomInterface();
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index b592649..1709b83 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -26,8 +26,7 @@ PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(PluginInstance* instance)
PPB_AudioConfig_Impl::~PPB_AudioConfig_Impl() {
}
-::ppapi::thunk::PPB_AudioConfig_API*
-PPB_AudioConfig_Impl::AsPPB_AudioConfig_API() {
+::ppapi::thunk::PPB_AudioConfig_API* PPB_AudioConfig_Impl::AsAudioConfig_API() {
return this;
}
@@ -63,11 +62,11 @@ PPB_Audio_Impl::~PPB_Audio_Impl() {
}
}
-::ppapi::thunk::PPB_Audio_API* PPB_Audio_Impl::AsPPB_Audio_API() {
+::ppapi::thunk::PPB_Audio_API* PPB_Audio_Impl::AsAudio_API() {
return this;
}
-::ppapi::thunk::PPB_AudioTrusted_API* PPB_Audio_Impl::AsPPB_AudioTrusted_API() {
+::ppapi::thunk::PPB_AudioTrusted_API* PPB_Audio_Impl::AsAudioTrusted_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h
index 4909903..060b8bf 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.h
+++ b/webkit/plugins/ppapi/ppb_audio_impl.h
@@ -34,7 +34,7 @@ class PPB_AudioConfig_Impl : public Resource,
virtual ~PPB_AudioConfig_Impl();
// ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE;
+ virtual ::ppapi::thunk::PPB_AudioConfig_API* AsAudioConfig_API() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Impl);
@@ -57,8 +57,8 @@ class PPB_Audio_Impl : public Resource,
PPB_Audio_Callback user_callback, void* user_data);
// ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API();
- virtual ::ppapi::thunk::PPB_AudioTrusted_API* AsPPB_AudioTrusted_API();
+ virtual ::ppapi::thunk::PPB_Audio_API* AsAudio_API();
+ virtual ::ppapi::thunk::PPB_AudioTrusted_API* AsAudioTrusted_API();
// PPB_Audio_API implementation.
virtual PP_Resource GetCurrentConfig() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 7d2aec0..2da35d6 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -61,7 +61,7 @@ PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() {
return this;
}
-PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() {
+PPB_Broker_API* PPB_Broker_Impl::AsBroker_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h
index 9ae920e..c569c1c 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.h
+++ b/webkit/plugins/ppapi/ppb_broker_impl.h
@@ -32,7 +32,7 @@ class PPB_Broker_Impl : public Resource,
virtual PPB_Broker_Impl* AsPPB_Broker_Impl() OVERRIDE;
// ResourceObjectBase override.
- virtual ::ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
+ virtual ::ppapi::thunk::PPB_Broker_API* AsBroker_API() OVERRIDE;
// PPB_BrokerTrusted implementation.
virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.cc b/webkit/plugins/ppapi/ppb_buffer_impl.cc
index 39d3191..182738f 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.cc
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.cc
@@ -41,7 +41,7 @@ PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() {
return this;
}
-PPB_Buffer_API* PPB_Buffer_Impl::AsPPB_Buffer_API() {
+PPB_Buffer_API* PPB_Buffer_Impl::AsBuffer_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.h b/webkit/plugins/ppapi/ppb_buffer_impl.h
index 2a2743d..f68c825 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.h
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.h
@@ -31,7 +31,7 @@ class PPB_Buffer_Impl : public Resource,
uint32_t size() const { return size_; }
// ResourceObjectBase overries.
- virtual ::ppapi::thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE;
+ virtual ::ppapi::thunk::PPB_Buffer_API* AsBuffer_API() OVERRIDE;
// PPB_Buffer_API implementation.
virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_char_set_impl.cc b/webkit/plugins/ppapi/ppb_char_set_impl.cc
index 496e339..fcabf2f 100644
--- a/webkit/plugins/ppapi/ppb_char_set_impl.cc
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.cc
@@ -24,7 +24,7 @@ PPB_CharSet_Impl::PPB_CharSet_Impl(PluginInstance* instance)
PPB_CharSet_Impl::~PPB_CharSet_Impl() {
}
-PPB_CharSet_FunctionAPI* PPB_CharSet_Impl::AsPPB_CharSet_FunctionAPI() {
+PPB_CharSet_FunctionAPI* PPB_CharSet_Impl::AsCharSet_FunctionAPI() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_char_set_impl.h b/webkit/plugins/ppapi/ppb_char_set_impl.h
index 768ab8c..6036dec 100644
--- a/webkit/plugins/ppapi/ppb_char_set_impl.h
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.h
@@ -22,7 +22,7 @@ class PPB_CharSet_Impl : public ::ppapi::FunctionGroupBase,
virtual ~PPB_CharSet_Impl();
// FunctionGroupBase overrides.
- virtual ::ppapi::thunk::PPB_CharSet_FunctionAPI* AsPPB_CharSet_FunctionAPI();
+ virtual ::ppapi::thunk::PPB_CharSet_FunctionAPI* AsCharSet_FunctionAPI();
// PPB_CharSet_FunctionAPI implementation.
virtual char* UTF16ToCharSet(PP_Instance instance,
diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
index 3968dd4..4bfb081 100644
--- a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
@@ -28,7 +28,7 @@ PPB_CursorControl_Impl::~PPB_CursorControl_Impl() {
}
PPB_CursorControl_FunctionAPI*
-PPB_CursorControl_Impl::AsPPB_CursorControl_FunctionAPI() {
+PPB_CursorControl_Impl::AsCursorControl_FunctionAPI() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.h b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
index 6b1242e..f3b8a7e 100644
--- a/webkit/plugins/ppapi/ppb_cursor_control_impl.h
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
@@ -24,7 +24,7 @@ class PPB_CursorControl_Impl
// FunctionGroupBase overrides.
virtual ::ppapi::thunk::PPB_CursorControl_FunctionAPI*
- AsPPB_CursorControl_FunctionAPI() OVERRIDE;
+ AsCursorControl_FunctionAPI() OVERRIDE;
// PPB_CursorControl_FunctionAPI implementation.
virtual PP_Bool SetCursor(PP_Instance instance,
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index cba21d5..33ca825 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -9,8 +9,6 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/dev/ppb_directory_reader_dev.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"
@@ -20,10 +18,6 @@
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-using ::ppapi::thunk::EnterResourceNoLock;
-using ::ppapi::thunk::PPB_DirectoryReader_API;
-using ::ppapi::thunk::PPB_FileRef_API;
-
namespace webkit {
namespace ppapi {
@@ -49,6 +43,38 @@ FilePath::StringType UTF8StringToFilePathString(const std::string& str) {
#endif
}
+PP_Resource Create(PP_Resource directory_ref_id) {
+ scoped_refptr<PPB_FileRef_Impl> directory_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
+ if (!directory_ref)
+ return 0;
+
+ PPB_DirectoryReader_Impl* reader =
+ new PPB_DirectoryReader_Impl(directory_ref);
+ return reader->GetReference();
+}
+
+PP_Bool IsDirectoryReader(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_DirectoryReader_Impl>(resource));
+}
+
+int32_t GetNextEntry(PP_Resource reader_id,
+ PP_DirectoryEntry_Dev* entry,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_DirectoryReader_Impl> reader(
+ Resource::GetAs<PPB_DirectoryReader_Impl>(reader_id));
+ if (!reader)
+ return PP_ERROR_BADRESOURCE;
+
+ return reader->GetNextEntry(entry, callback);
+}
+
+const PPB_DirectoryReader_Dev ppb_directoryreader = {
+ &Create,
+ &IsDirectoryReader,
+ &GetNextEntry
+};
+
} // namespace
PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
@@ -62,15 +88,8 @@ PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
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;
-
- PPB_DirectoryReader_Impl* reader = new PPB_DirectoryReader_Impl(
- static_cast<PPB_FileRef_Impl*>(enter.object()));
- return reader->GetReference();
+const PPB_DirectoryReader_Dev* PPB_DirectoryReader_Impl::GetInterface() {
+ return &ppb_directoryreader;
}
PPB_DirectoryReader_Impl*
@@ -78,10 +97,6 @@ PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_Impl() {
return this;
}
-PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
- return this;
-}
-
int32_t PPB_DirectoryReader_Impl::GetNextEntry(
PP_DirectoryEntry_Dev* entry,
PP_CompletionCallback callback) {
@@ -94,7 +109,7 @@ int32_t PPB_DirectoryReader_Impl::GetNextEntry(
return PP_OK;
}
- PluginInstance* instance = directory_ref_->instance();
+ PluginInstance* instance = directory_ref_->GetFileSystem()->instance();
PP_Resource resource_id = GetReferenceNoAddRef();
DCHECK(resource_id != 0);
if (!instance->delegate()->ReadDirectory(
@@ -111,7 +126,7 @@ 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_->virtual_path();
+ std::string dir_path = directory_ref_->GetPath();
if (dir_path[dir_path.size() - 1] != '/')
dir_path += '/';
FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path);
@@ -135,7 +150,7 @@ bool PPB_DirectoryReader_Impl::FillUpEntry() {
if (entry_->file_ref)
ResourceTracker::Get()->UnrefResource(entry_->file_ref);
PPB_FileRef_Impl* file_ref =
- new PPB_FileRef_Impl(instance(), directory_ref_->file_system(),
+ new PPB_FileRef_Impl(instance(), directory_ref_->GetFileSystem(),
FilePathStringToUTF8String(dir_entry.name));
entry_->file_ref = file_ref->GetReference();
entry_->file_type =
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
index 67be4a5..6e6dfdf 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.h
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
@@ -8,7 +8,6 @@
#include <queue>
#include "base/file_util_proxy.h"
-#include "ppapi/thunk/ppb_directory_reader_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_CompletionCallback;
@@ -20,25 +19,21 @@ namespace ppapi {
class PPB_FileRef_Impl;
-class PPB_DirectoryReader_Impl
- : public Resource,
- public ::ppapi::thunk::PPB_DirectoryReader_API {
+class PPB_DirectoryReader_Impl : public Resource {
public:
explicit PPB_DirectoryReader_Impl(PPB_FileRef_Impl* directory_ref);
virtual ~PPB_DirectoryReader_Impl();
- static PP_Resource Create(PP_Resource directory_ref);
+ // Returns a pointer to the interface implementing PPB_DirectoryReader that
+ // is exposed to the plugin.
+ static const PPB_DirectoryReader_Dev* GetInterface();
// Resource overrides.
- virtual PPB_DirectoryReader_Impl* AsPPB_DirectoryReader_Impl() OVERRIDE;
+ virtual PPB_DirectoryReader_Impl* AsPPB_DirectoryReader_Impl();
- // ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API()
- OVERRIDE;
-
- // PPB_DirectoryReader_API implementation.
- virtual int32_t GetNextEntry(PP_DirectoryEntry_Dev* entry,
- PP_CompletionCallback callback) OVERRIDE;
+ // PPB_DirectoryReader implementation.
+ int32_t GetNextEntry(PP_DirectoryEntry_Dev* entry,
+ PP_CompletionCallback callback);
void AddNewEntries(const std::vector<base::FileUtilProxy::Entry>& entries,
bool has_more);
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index 3ce1489..817dcd5 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -25,7 +25,6 @@
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/glue/webkit_glue.h"
-using ppapi::thunk::PPB_FileChooser_API;
using WebKit::WebCString;
using WebKit::WebFileChooserCompletion;
using WebKit::WebFileChooserParams;
@@ -37,6 +36,53 @@ namespace ppapi {
namespace {
+PP_Resource Create(PP_Instance instance_id,
+ const PP_FileChooserOptions_Dev* options) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ if ((options->mode != PP_FILECHOOSERMODE_OPEN) &&
+ (options->mode != PP_FILECHOOSERMODE_OPENMULTIPLE))
+ return 0;
+
+ PPB_FileChooser_Impl* chooser = new PPB_FileChooser_Impl(instance, options);
+ return chooser->GetReference();
+}
+
+PP_Bool IsFileChooser(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_FileChooser_Impl>(resource));
+}
+
+int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileChooser_Impl> chooser(
+ Resource::GetAs<PPB_FileChooser_Impl>(chooser_id));
+ if (!chooser)
+ return PP_ERROR_BADRESOURCE;
+
+ return chooser->Show(callback);
+}
+
+PP_Resource GetNextChosenFile(PP_Resource chooser_id) {
+ scoped_refptr<PPB_FileChooser_Impl> chooser(
+ Resource::GetAs<PPB_FileChooser_Impl>(chooser_id));
+ if (!chooser)
+ return 0;
+
+ scoped_refptr<PPB_FileRef_Impl> file_ref(chooser->GetNextChosenFile());
+ if (!file_ref)
+ return 0;
+
+ return file_ref->GetReference();
+}
+
+const PPB_FileChooser_Dev ppb_filechooser = {
+ &Create,
+ &IsFileChooser,
+ &Show,
+ &GetNextChosenFile
+};
+
class FileChooserCompletionImpl : public WebFileChooserCompletion {
public:
FileChooserCompletionImpl(PPB_FileChooser_Impl* file_chooser)
@@ -74,29 +120,14 @@ PPB_FileChooser_Impl::~PPB_FileChooser_Impl() {
}
// static
-PP_Resource PPB_FileChooser_Impl::Create(
- PP_Instance pp_instance,
- const PP_FileChooserOptions_Dev* options) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
- if (!instance)
- return 0;
-
- if ((options->mode != PP_FILECHOOSERMODE_OPEN) &&
- (options->mode != PP_FILECHOOSERMODE_OPENMULTIPLE))
- return 0;
-
- PPB_FileChooser_Impl* chooser = new PPB_FileChooser_Impl(instance, options);
- return chooser->GetReference();
+const PPB_FileChooser_Dev* PPB_FileChooser_Impl::GetInterface() {
+ return &ppb_filechooser;
}
PPB_FileChooser_Impl* PPB_FileChooser_Impl::AsPPB_FileChooser_Impl() {
return this;
}
-PPB_FileChooser_API* PPB_FileChooser_Impl::AsPPB_FileChooser_API() {
- return this;
-}
-
void PPB_FileChooser_Impl::StoreChosenFiles(
const std::vector<std::string>& files) {
chosen_files_.clear();
@@ -145,7 +176,7 @@ void PPB_FileChooser_Impl::RunCallback(int32_t result) {
callback->Run(result); // Will complete abortively if necessary.
}
-int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) {
+int32_t PPB_FileChooser_Impl::Show(const PP_CompletionCallback& callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -166,11 +197,11 @@ int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) {
return PP_OK_COMPLETIONPENDING;
}
-PP_Resource PPB_FileChooser_Impl::GetNextChosenFile() {
+scoped_refptr<PPB_FileRef_Impl> PPB_FileChooser_Impl::GetNextChosenFile() {
if (next_chosen_file_index_ >= chosen_files_.size())
- return 0;
+ return NULL;
- return chosen_files_[next_chosen_file_index_++]->GetReference();
+ return chosen_files_[next_chosen_file_index_++];
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.h b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
index 024970f..57d1d32 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
@@ -10,7 +10,6 @@
#include "base/memory/ref_counted.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
-#include "ppapi/thunk/ppb_file_chooser_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_CompletionCallback;
@@ -22,22 +21,19 @@ class PluginInstance;
class PPB_FileRef_Impl;
class TrackedCompletionCallback;
-class PPB_FileChooser_Impl : public Resource,
- public ::ppapi::thunk::PPB_FileChooser_API {
+class PPB_FileChooser_Impl : public Resource {
public:
PPB_FileChooser_Impl(PluginInstance* instance,
const PP_FileChooserOptions_Dev* options);
virtual ~PPB_FileChooser_Impl();
- static PP_Resource Create(PP_Instance instance,
- const PP_FileChooserOptions_Dev* options);
+ // Returns a pointer to the interface implementing PPB_FileChooser that is
+ // exposed to the plugin.
+ static const PPB_FileChooser_Dev* GetInterface();
// Resource overrides.
virtual PPB_FileChooser_Impl* AsPPB_FileChooser_Impl();
- // ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() OVERRIDE;
-
// Stores the list of selected files.
void StoreChosenFiles(const std::vector<std::string>& files);
@@ -52,9 +48,9 @@ class PPB_FileChooser_Impl : public Resource,
void RunCallback(int32_t result);
- // PPB_FileChooser_API implementation.
- virtual int32_t Show(PP_CompletionCallback callback) OVERRIDE;
- virtual PP_Resource GetNextChosenFile() OVERRIDE;
+ // PPB_FileChooser implementation.
+ int32_t Show(const PP_CompletionCallback& callback);
+ scoped_refptr<PPB_FileRef_Impl> GetNextChosenFile();
private:
PP_FileChooserMode_Dev mode_;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index b68da1b..0989f1e 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -15,8 +15,6 @@
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.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_type_conversions.h"
#include "webkit/plugins/ppapi/plugin_module.h"
@@ -24,13 +22,163 @@
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_FileIO_API;
-using ppapi::thunk::PPB_FileRef_API;
-
namespace webkit {
namespace ppapi {
+namespace {
+
+PP_Resource Create(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(instance);
+ return file_io->GetReference();
+}
+
+PP_Bool IsFileIO(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_FileIO_Impl>(resource));
+}
+
+int32_t Open(PP_Resource file_io_id,
+ PP_Resource file_ref_id,
+ int32_t open_flags,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ return file_io->Open(file_ref, open_flags, callback);
+}
+
+int32_t Query(PP_Resource file_io_id,
+ PP_FileInfo_Dev* info,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->Query(info, callback);
+}
+
+int32_t Touch(PP_Resource file_io_id,
+ PP_Time last_access_time,
+ PP_Time last_modified_time,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->Touch(last_access_time, last_modified_time, callback);
+}
+
+int32_t Read(PP_Resource file_io_id,
+ int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->Read(offset, buffer, bytes_to_read, callback);
+}
+
+int32_t Write(PP_Resource file_io_id,
+ int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->Write(offset, buffer, bytes_to_write, callback);
+}
+
+int32_t SetLength(PP_Resource file_io_id,
+ int64_t length,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->SetLength(length, callback);
+}
+
+int32_t Flush(PP_Resource file_io_id,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->Flush(callback);
+}
+
+void Close(PP_Resource file_io_id) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return;
+ file_io->Close();
+}
+
+const PPB_FileIO_Dev ppb_fileio = {
+ &Create,
+ &IsFileIO,
+ &Open,
+ &Query,
+ &Touch,
+ &Read,
+ &Write,
+ &SetLength,
+ &Flush,
+ &Close
+};
+
+int32_t GetOSFileDescriptor(PP_Resource file_io_id) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->GetOSFileDescriptor();
+}
+
+int32_t WillWrite(PP_Resource file_io_id,
+ int64_t offset,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->WillWrite(offset, bytes_to_write, callback);
+}
+
+int32_t WillSetLength(PP_Resource file_io_id,
+ int64_t length,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileIO_Impl>
+ file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
+ if (!file_io)
+ return PP_ERROR_BADRESOURCE;
+ return file_io->WillSetLength(length, callback);
+}
+
+const PPB_FileIOTrusted_Dev ppb_fileiotrusted = {
+ &GetOSFileDescriptor,
+ &WillWrite,
+ &WillSetLength
+};
+
+} // namespace
+
PPB_FileIO_Impl::PPB_FileIO_Impl(PluginInstance* instance)
: Resource(instance),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
@@ -45,26 +193,22 @@ PPB_FileIO_Impl::~PPB_FileIO_Impl() {
}
// static
-PP_Resource PPB_FileIO_Impl::Create(PP_Instance pp_instance) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
- if (!instance)
- return 0;
- PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(instance);
- return file_io->GetReference();
+const PPB_FileIO_Dev* PPB_FileIO_Impl::GetInterface() {
+ return &ppb_fileio;
}
-PPB_FileIO_API* PPB_FileIO_Impl::AsPPB_FileIO_API() {
+// static
+const PPB_FileIOTrusted_Dev* PPB_FileIO_Impl::GetTrustedInterface() {
+ return &ppb_fileiotrusted;
+}
+
+PPB_FileIO_Impl* PPB_FileIO_Impl::AsPPB_FileIO_Impl() {
return this;
}
-int32_t PPB_FileIO_Impl::Open(PP_Resource pp_file_ref,
+int32_t PPB_FileIO_Impl::Open(PPB_FileRef_Impl* file_ref,
int32_t open_flags,
PP_CompletionCallback callback) {
- EnterResourceNoLock<PPB_FileRef_API> enter(pp_file_ref, true);
- if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object());
-
int32_t rv = CommonCallValidation(false, callback);
if (rv != PP_OK)
return rv;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 0fc05c5..621aa1e 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -13,7 +13,6 @@
#include "base/platform_file.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_time.h"
-#include "ppapi/thunk/ppb_file_io_api.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
@@ -28,44 +27,51 @@ namespace ppapi {
class PluginModule;
class PPB_FileRef_Impl;
-class PPB_FileIO_Impl : public Resource,
- public ::ppapi::thunk::PPB_FileIO_API {
+class PPB_FileIO_Impl : public Resource {
public:
explicit PPB_FileIO_Impl(PluginInstance* instance);
virtual ~PPB_FileIO_Impl();
- static PP_Resource Create(PP_Instance instance);
-
- // ResourceObjectBase overrides.
- ::ppapi::thunk::PPB_FileIO_API* AsPPB_FileIO_API();
-
- // PPB_FileIO_API implementation.
- virtual int32_t Open(PP_Resource file_ref,
- int32_t open_flags,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Query(PP_FileInfo_Dev* info,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Read(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Write(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t SetLength(int64_t length,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE;
- virtual void Close() OVERRIDE;
- virtual int32_t GetOSFileDescriptor() OVERRIDE;
- virtual int32_t WillWrite(int64_t offset,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t WillSetLength(int64_t length,
- PP_CompletionCallback callback) OVERRIDE;
+ // Returns a pointer to the interface implementing PPB_FileIO that is exposed
+ // to the plugin.
+ static const PPB_FileIO_Dev* GetInterface();
+
+ // Returns a pointer to the interface implementing PPB_FileIOTrusted that is
+ // exposed to the plugin.
+ static const PPB_FileIOTrusted_Dev* GetTrustedInterface();
+
+ // Resource overrides.
+ virtual PPB_FileIO_Impl* AsPPB_FileIO_Impl();
+
+ // PPB_FileIO implementation.
+ int32_t Open(PPB_FileRef_Impl* file_ref,
+ int32_t open_flags,
+ PP_CompletionCallback callback);
+ int32_t Query(PP_FileInfo_Dev* info,
+ PP_CompletionCallback callback);
+ int32_t Touch(PP_Time last_access_time,
+ PP_Time last_modified_time,
+ PP_CompletionCallback callback);
+ int32_t Read(int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ PP_CompletionCallback callback);
+ int32_t Write(int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback);
+ int32_t SetLength(int64_t length,
+ PP_CompletionCallback callback);
+ int32_t Flush(PP_CompletionCallback callback);
+ void Close();
+
+ // PPB_FileIOTrusted implementation.
+ int32_t GetOSFileDescriptor();
+ int32_t WillWrite(int64_t offset,
+ int32_t bytes_to_write,
+ PP_CompletionCallback callback);
+ int32_t WillSetLength(int64_t length,
+ PP_CompletionCallback callback);
private:
// Verifies:
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index de31bfb..8ab57e7 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -8,8 +8,6 @@
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_file_system_api.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
@@ -19,10 +17,6 @@
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/var.h"
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_FileRef_API;
-using ppapi::thunk::PPB_FileSystem_API;
-
namespace webkit {
namespace ppapi {
@@ -47,6 +41,192 @@ void TrimTrailingSlash(std::string* path) {
path->erase(path->size() - 1, 1);
}
+PP_Resource Create(PP_Resource file_system_id, const char* path) {
+ scoped_refptr<PPB_FileSystem_Impl> file_system(
+ Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
+ if (!file_system)
+ return 0;
+
+ if (!file_system->instance())
+ return 0;
+
+ std::string validated_path(path);
+ if (!IsValidLocalPath(validated_path))
+ return 0;
+ TrimTrailingSlash(&validated_path);
+
+ PPB_FileRef_Impl* file_ref =
+ new PPB_FileRef_Impl(file_system->instance(),
+ file_system, validated_path);
+ return file_ref->GetReference();
+}
+
+PP_Bool IsFileRef(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_FileRef_Impl>(resource));
+}
+
+PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_FILESYSTEMTYPE_INVALID;
+ return file_ref->GetFileSystemType();
+}
+
+PP_Var GetName(PP_Resource file_ref_id) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_MakeUndefined();
+ return StringVar::StringToPPVar(file_ref->instance()->module(),
+ file_ref->GetName());
+}
+
+PP_Var GetPath(PP_Resource file_ref_id) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_MakeUndefined();
+
+ if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
+ return PP_MakeUndefined();
+
+ return StringVar::StringToPPVar(file_ref->instance()->module(),
+ file_ref->GetPath());
+}
+
+PP_Resource GetParent(PP_Resource file_ref_id) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return 0;
+
+ if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
+ return 0;
+
+ scoped_refptr<PPB_FileRef_Impl> parent_ref(file_ref->GetParent());
+ if (!parent_ref)
+ return 0;
+
+ return parent_ref->GetReference();
+}
+
+int32_t MakeDirectory(PP_Resource directory_ref_id,
+ PP_Bool make_ancestors,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileRef_Impl> directory_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
+ if (!directory_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileSystem_Impl> file_system =
+ directory_ref->GetFileSystem();
+ if (!file_system || !file_system->opened() ||
+ (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
+ return PP_ERROR_NOACCESS;
+
+ PluginInstance* instance = file_system->instance();
+ if (!instance->delegate()->MakeDirectory(
+ directory_ref->GetFileSystemURL(), PPBoolToBool(make_ancestors),
+ new FileCallbacks(instance->module()->AsWeakPtr(), directory_ref_id,
+ callback, NULL, NULL, NULL)))
+ return PP_ERROR_FAILED;
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t Touch(PP_Resource file_ref_id,
+ PP_Time last_access_time,
+ PP_Time last_modified_time,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
+ if (!file_system || !file_system->opened() ||
+ (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
+ return PP_ERROR_NOACCESS;
+
+ PluginInstance* instance = file_system->instance();
+ if (!instance->delegate()->Touch(
+ file_ref->GetFileSystemURL(),
+ base::Time::FromDoubleT(last_access_time),
+ base::Time::FromDoubleT(last_modified_time),
+ new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id,
+ callback, NULL, NULL, NULL)))
+ return PP_ERROR_FAILED;
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t Delete(PP_Resource file_ref_id,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
+ if (!file_system || !file_system->opened() ||
+ (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
+ return PP_ERROR_NOACCESS;
+
+ PluginInstance* instance = file_system->instance();
+ if (!instance->delegate()->Delete(
+ file_ref->GetFileSystemURL(),
+ new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id,
+ callback, NULL, NULL, NULL)))
+ return PP_ERROR_FAILED;
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t Rename(PP_Resource file_ref_id,
+ PP_Resource new_file_ref_id,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileRef_Impl> file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileRef_Impl> new_file_ref(
+ Resource::GetAs<PPB_FileRef_Impl>(new_file_ref_id));
+ if (!new_file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
+ if (!file_system || !file_system->opened() ||
+ (file_system != new_file_ref->GetFileSystem()) ||
+ (file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
+ return PP_ERROR_NOACCESS;
+
+ // TODO(viettrungluu): Also cancel when the new file ref is destroyed?
+ // http://crbug.com/67624
+ PluginInstance* instance = file_system->instance();
+ if (!instance->delegate()->Rename(
+ file_ref->GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
+ new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id,
+ callback, NULL, NULL, NULL)))
+ return PP_ERROR_FAILED;
+
+ return PP_OK_COMPLETIONPENDING;
+}
+
+const PPB_FileRef_Dev ppb_fileref = {
+ &Create,
+ &IsFileRef,
+ &GetFileSystemType,
+ &GetName,
+ &GetPath,
+ &GetParent,
+ &MakeDirectory,
+ &Touch,
+ &Delete,
+ &Rename
+};
+
} // namespace
PPB_FileRef_Impl::PPB_FileRef_Impl()
@@ -74,78 +254,41 @@ PPB_FileRef_Impl::~PPB_FileRef_Impl() {
}
// static
-PP_Resource PPB_FileRef_Impl::Create(PP_Resource pp_file_system,
- const char* 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->instance())
- return 0;
-
- std::string validated_path(path);
- if (!IsValidLocalPath(validated_path))
- return 0;
- TrimTrailingSlash(&validated_path);
-
- PPB_FileRef_Impl* file_ref =
- new PPB_FileRef_Impl(file_system->instance(),
- file_system, validated_path);
- return file_ref->GetReference();
-}
-
-PPB_FileRef_API* PPB_FileRef_Impl::AsPPB_FileRef_API() {
- return this;
+const PPB_FileRef_Dev* PPB_FileRef_Impl::GetInterface() {
+ return &ppb_fileref;
}
PPB_FileRef_Impl* PPB_FileRef_Impl::AsPPB_FileRef_Impl() {
return this;
}
-PP_FileSystemType_Dev PPB_FileRef_Impl::GetFileSystemType() const {
- // When the file ref exists but there's no explicit filesystem object
- // associated with it, that means it's an "external" filesystem.
- if (!file_system_)
- return PP_FILESYSTEMTYPE_EXTERNAL;
- return file_system_->type();
-}
-
-PP_Var PPB_FileRef_Impl::GetName() const {
- std::string result;
+std::string PPB_FileRef_Impl::GetName() const {
if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) {
FilePath::StringType path = system_path_.value();
size_t pos = path.rfind(FilePath::kSeparators[0]);
DCHECK(pos != FilePath::StringType::npos);
#if defined(OS_WIN)
- result = WideToUTF8(path.substr(pos + 1));
+ return WideToUTF8(path.substr(pos + 1));
#elif defined(OS_POSIX)
- result = path.substr(pos + 1);
+ return path.substr(pos + 1);
#else
#error "Unsupported platform."
#endif
- } else if (virtual_path_.size() == 1 && virtual_path_[0] == '/') {
- result = virtual_path_;
- } else {
- // There should always be a leading slash at least!
- size_t pos = virtual_path_.rfind('/');
- DCHECK(pos != std::string::npos);
- result = virtual_path_.substr(pos + 1);
}
- return StringVar::StringToPPVar(instance()->module(), result);
-}
+ if (virtual_path_.size() == 1 && virtual_path_[0] == '/')
+ return virtual_path_;
-PP_Var PPB_FileRef_Impl::GetPath() const {
- if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
- return PP_MakeUndefined();
- return StringVar::StringToPPVar(instance()->module(), virtual_path_);
+ // There should always be a leading slash at least!
+ size_t pos = virtual_path_.rfind('/');
+ DCHECK(pos != std::string::npos);
+
+ return virtual_path_.substr(pos + 1);
}
-PP_Resource PPB_FileRef_Impl::GetParent() {
+scoped_refptr<PPB_FileRef_Impl> PPB_FileRef_Impl::GetParent() {
if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
- return 0;
+ return new PPB_FileRef_Impl();
// There should always be a leading slash at least!
size_t pos = virtual_path_.rfind('/');
@@ -156,73 +299,26 @@ PP_Resource PPB_FileRef_Impl::GetParent() {
pos++;
std::string parent_path = virtual_path_.substr(0, pos);
- scoped_refptr<PPB_FileRef_Impl> parent_ref(
- new PPB_FileRef_Impl(instance(), file_system_, parent_path));
- return parent_ref->GetReference();
+ PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(instance(), file_system_,
+ parent_path);
+ return parent_ref;
}
-int32_t PPB_FileRef_Impl::MakeDirectory(PP_Bool make_ancestors,
- PP_CompletionCallback callback) {
- if (!IsValidNonExternalFileSystem())
- return PP_ERROR_NOACCESS;
- if (!instance()->delegate()->MakeDirectory(
- GetFileSystemURL(), PP_ToBool(make_ancestors),
- new FileCallbacks(instance()->module()->AsWeakPtr(),
- GetReferenceNoAddRef(), callback,
- NULL, NULL, NULL)))
- return PP_ERROR_FAILED;
- return PP_OK_COMPLETIONPENDING;
+scoped_refptr<PPB_FileSystem_Impl> PPB_FileRef_Impl::GetFileSystem() const {
+ return file_system_;
}
-int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) {
- if (!IsValidNonExternalFileSystem())
- return PP_ERROR_NOACCESS;
- if (!instance()->delegate()->Touch(
- GetFileSystemURL(),
- base::Time::FromDoubleT(last_access_time),
- base::Time::FromDoubleT(last_modified_time),
- new FileCallbacks(instance()->module()->AsWeakPtr(),
- GetReferenceNoAddRef(), callback,
- NULL, NULL, NULL)))
- return PP_ERROR_FAILED;
- return PP_OK_COMPLETIONPENDING;
-}
+PP_FileSystemType_Dev PPB_FileRef_Impl::GetFileSystemType() const {
+ // When the file ref exists but there's no explicit filesystem object
+ // associated with it, that means it's an "external" filesystem.
+ if (!file_system_)
+ return PP_FILESYSTEMTYPE_EXTERNAL;
-int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
- if (!IsValidNonExternalFileSystem())
- return PP_ERROR_NOACCESS;
- if (!instance()->delegate()->Delete(
- GetFileSystemURL(),
- new FileCallbacks(instance()->module()->AsWeakPtr(),
- GetReferenceNoAddRef(), callback,
- NULL, NULL, NULL)))
- return PP_ERROR_FAILED;
- return PP_OK_COMPLETIONPENDING;
+ return file_system_->type();
}
-int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
- PP_CompletionCallback callback) {
- EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true);
- if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- PPB_FileRef_Impl* new_file_ref =
- static_cast<PPB_FileRef_Impl*>(enter.object());
-
- if (!IsValidNonExternalFileSystem() ||
- file_system_.get() != new_file_ref->file_system_.get())
- return PP_ERROR_NOACCESS;
-
- // TODO(viettrungluu): Also cancel when the new file ref is destroyed?
- // http://crbug.com/67624
- if (!instance()->delegate()->Rename(
- GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
- new FileCallbacks(instance()->module()->AsWeakPtr(),
- GetReferenceNoAddRef(), callback,
- NULL, NULL, NULL)))
- return PP_ERROR_FAILED;
- return PP_OK_COMPLETIONPENDING;
+std::string PPB_FileRef_Impl::GetPath() const {
+ return virtual_path_;
}
FilePath PPB_FileRef_Impl::GetSystemPath() const {
@@ -249,10 +345,5 @@ GURL PPB_FileRef_Impl::GetFileSystemURL() const {
return GURL(file_system_->root_url().spec() + virtual_path_.substr(1));
}
-bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
- return file_system_ && file_system_->opened() &&
- file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL;
-}
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
index a1406a3..234e150 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -10,7 +10,6 @@
#include "base/file_path.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/ppb_file_ref_dev.h"
-#include "ppapi/thunk/ppb_file_ref_api.h"
#include "webkit/plugins/ppapi/resource.h"
namespace webkit {
@@ -20,8 +19,7 @@ class PPB_FileSystem_Impl;
class PluginInstance;
class PluginModule;
-class PPB_FileRef_Impl : public Resource,
- public ::ppapi::thunk::PPB_FileRef_API {
+class PPB_FileRef_Impl : public Resource {
public:
PPB_FileRef_Impl();
PPB_FileRef_Impl(PluginInstance* instance,
@@ -31,32 +29,27 @@ class PPB_FileRef_Impl : public Resource,
const FilePath& external_file_path);
virtual ~PPB_FileRef_Impl();
- static PP_Resource Create(PP_Resource file_system, const char* path);
+ // Returns a pointer to the interface implementing PPB_FileRef that is
+ // exposed to the plugin.
+ static const PPB_FileRef_Dev* GetInterface();
// Resource overrides.
virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl();
- // ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE;
-
- // PPB_FileRef_API implementation.
- virtual PP_FileSystemType_Dev GetFileSystemType() const OVERRIDE;
- virtual PP_Var GetName() const OVERRIDE;
- virtual PP_Var GetPath() const OVERRIDE;
- virtual PP_Resource GetParent() OVERRIDE;
- virtual int32_t MakeDirectory(PP_Bool make_ancestors,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Rename(PP_Resource new_file_ref,
- PP_CompletionCallback callback) OVERRIDE;
-
- PPB_FileSystem_Impl* file_system() const { return file_system_.get(); }
- const std::string& virtual_path() const { return virtual_path_; }
+ // PPB_FileRef implementation.
+ std::string GetName() const;
+ scoped_refptr<PPB_FileRef_Impl> GetParent();
+
+ // Returns the file system to which this PPB_FileRef_Impl belongs.
+ scoped_refptr<PPB_FileSystem_Impl> GetFileSystem() const;
+
+ // Returns the type of the file system to which this PPB_FileRef_Impl belongs.
+ PP_FileSystemType_Dev GetFileSystemType() const;
// Returns the virtual path (i.e., the path that the pepper plugin sees)
+ // corresponding to this file.
+ std::string GetPath() const;
+
// Returns the system path corresponding to this file.
FilePath GetSystemPath() const;
@@ -64,11 +57,6 @@ class PPB_FileRef_Impl : public Resource,
GURL GetFileSystemURL() 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
- // access check for these functions.
- bool IsValidNonExternalFileSystem() const;
-
scoped_refptr<PPB_FileSystem_Impl> file_system_;
std::string virtual_path_; // UTF-8 encoded
FilePath system_path_;
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index 6a8a80b..0f4793c 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -21,27 +21,12 @@
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-using ppapi::thunk::PPB_FileSystem_API;
-
namespace webkit {
namespace ppapi {
-PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
- PP_FileSystemType_Dev type)
- : Resource(instance),
- instance_(instance),
- type_(type),
- opened_(false),
- called_open_(false) {
- DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
-}
-
-PPB_FileSystem_Impl::~PPB_FileSystem_Impl() {
-}
+namespace {
-// static
-PP_Resource PPB_FileSystem_Impl::Create(PP_Instance instance,
- PP_FileSystemType_Dev type) {
+PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) {
PluginInstance* plugin_instance =
ResourceTracker::Get()->GetInstance(instance);
if (!plugin_instance)
@@ -57,38 +42,77 @@ PP_Resource PPB_FileSystem_Impl::Create(PP_Instance instance,
return file_system->GetReference();
}
-PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() {
- return this;
+PP_Bool IsFileSystem(PP_Resource resource) {
+ scoped_refptr<PPB_FileSystem_Impl> file_system(
+ Resource::GetAs<PPB_FileSystem_Impl>(resource));
+ return BoolToPPBool(!!file_system.get());
}
-int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
- PP_CompletionCallback callback) {
+int32_t Open(PP_Resource file_system_id,
+ int64 expected_size,
+ PP_CompletionCallback callback) {
+ scoped_refptr<PPB_FileSystem_Impl> file_system(
+ Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
+ if (!file_system)
+ return PP_ERROR_BADRESOURCE;
+
// Should not allow multiple opens.
- if (called_open_)
+ if (file_system->called_open())
return PP_ERROR_FAILED;
- called_open_ = true;
+ file_system->set_called_open();
- if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
+ if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
+ (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY))
return PP_ERROR_FAILED;
+ PluginInstance* instance = file_system->instance();
fileapi::FileSystemType file_system_type =
- (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
+ (file_system->type() == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
fileapi::kFileSystemTypeTemporary :
fileapi::kFileSystemTypePersistent);
- if (!instance()->delegate()->OpenFileSystem(
- instance()->container()->element().document().frame()->url(),
+ if (!instance->delegate()->OpenFileSystem(
+ instance->container()->element().document().frame()->url(),
file_system_type, expected_size,
- new FileCallbacks(instance()->module()->AsWeakPtr(),
- GetReferenceNoAddRef(),
- callback, NULL,
- scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
+ new FileCallbacks(instance->module()->AsWeakPtr(), file_system_id,
+ callback, NULL, file_system, NULL)))
return PP_ERROR_FAILED;
+
return PP_OK_COMPLETIONPENDING;
}
-PP_FileSystemType_Dev PPB_FileSystem_Impl::GetType() {
- return type_;
+PP_FileSystemType_Dev GetType(PP_Resource resource) {
+ scoped_refptr<PPB_FileSystem_Impl> file_system(
+ Resource::GetAs<PPB_FileSystem_Impl>(resource));
+ if (!file_system)
+ return PP_FILESYSTEMTYPE_INVALID;
+ return file_system->type();
+}
+
+const PPB_FileSystem_Dev ppb_filesystem = {
+ &Create,
+ &IsFileSystem,
+ &Open,
+ &GetType
+};
+
+} // namespace
+
+PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
+ PP_FileSystemType_Dev type)
+ : Resource(instance),
+ instance_(instance),
+ type_(type),
+ opened_(false),
+ called_open_(false) {
+ DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
+}
+
+PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() {
+ return this;
+}
+
+const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() {
+ return &ppb_filesystem;
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.h b/webkit/plugins/ppapi/ppb_file_system_impl.h
index 7ebb86d..b381f56 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.h
@@ -6,10 +6,8 @@
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_SYSTEM_IMPL_H_
#include "base/basictypes.h"
-#include "base/compiler_specific.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
-#include "ppapi/thunk/ppb_file_system_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_FileSystem_Dev;
@@ -19,16 +17,14 @@ namespace ppapi {
class PluginInstance;
-class PPB_FileSystem_Impl : public Resource,
- public ::ppapi::thunk::PPB_FileSystem_API {
+class PPB_FileSystem_Impl : public Resource {
public:
- PPB_FileSystem_Impl(PluginInstance* instance, PP_FileSystemType_Dev type);
- ~PPB_FileSystem_Impl();
-
- static PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type);
+ // Returns a pointer to the interface implementing PPB_FileSystem that is
+ // exposed to the plugin.
+ static const PPB_FileSystem_Dev* GetInterface();
- // ResourceObjectBase overrides.
- virtual ::ppapi::thunk::PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE;
+ PPB_FileSystem_Impl(PluginInstance* instance, PP_FileSystemType_Dev type);
+ virtual PPB_FileSystem_Impl* AsPPB_FileSystem_Impl();
PluginInstance* instance() { return instance_; }
PP_FileSystemType_Dev type() { return type_; }
@@ -36,11 +32,8 @@ class PPB_FileSystem_Impl : public Resource,
void set_root_url(const GURL& root_url) { root_url_ = root_url; }
bool opened() const { return opened_; }
void set_opened(bool opened) { opened_ = opened; }
-
- // PPB_FileSystem_API implementation.
- virtual int32_t Open(int64_t expected_size,
- PP_CompletionCallback callback) OVERRIDE;
- virtual PP_FileSystemType_Dev GetType() OVERRIDE;
+ bool called_open() const { return called_open_; }
+ void set_called_open() { called_open_ = true; }
private:
PluginInstance* instance_;
diff --git a/webkit/plugins/ppapi/ppb_find_impl.cc b/webkit/plugins/ppapi/ppb_find_impl.cc
deleted file mode 100644
index d83bc19..0000000
--- a/webkit/plugins/ppapi/ppb_find_impl.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2011 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_find_impl.h"
-
-#include "webkit/plugins/ppapi/plugin_delegate.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-
-using ::ppapi::thunk::PPB_Find_FunctionAPI;
-
-namespace webkit {
-namespace ppapi {
-
-PPB_Find_Impl::PPB_Find_Impl(PluginInstance* instance) : instance_(instance) {
-}
-
-PPB_Find_Impl::~PPB_Find_Impl() {
-}
-
-PPB_Find_FunctionAPI* PPB_Find_Impl::AsPPB_Find_FunctionAPI() {
- return this;
-}
-
-void PPB_Find_Impl::NumberOfFindResultsChanged(PP_Instance instance,
- int32_t total,
- PP_Bool final_result) {
- DCHECK_NE(instance_->find_identifier(), -1);
- instance_->delegate()->NumberOfFindResultsChanged(
- instance_->find_identifier(), total, PP_ToBool(final_result));
-}
-
-void PPB_Find_Impl::SelectedFindResultChanged(PP_Instance instance,
- int32_t index) {
- DCHECK_NE(instance_->find_identifier(), -1);
- instance_->delegate()->SelectedFindResultChanged(
- instance_->find_identifier(), index);
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_find_impl.h b/webkit/plugins/ppapi/ppb_find_impl.h
deleted file mode 100644
index b6675cd..0000000
--- a/webkit/plugins/ppapi/ppb_find_impl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2011 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_FIND_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_FIND_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ppapi/shared_impl/function_group_base.h"
-#include "ppapi/thunk/ppb_find_api.h"
-
-namespace webkit {
-namespace ppapi {
-
-class PluginInstance;
-
-// Some of the backend functionality of this class is implemented by the
-// AudioImpl so it can be shared with the proxy.
-class PPB_Find_Impl : public ::ppapi::FunctionGroupBase,
- public ::ppapi::thunk::PPB_Find_FunctionAPI {
- public:
- PPB_Find_Impl(PluginInstance* instance);
- virtual ~PPB_Find_Impl();
-
- // FunctionBase overrides.
- virtual ::ppapi::thunk::PPB_Find_FunctionAPI* AsPPB_Find_FunctionAPI()
- OVERRIDE;
-
- // PPB_Find_API implementation.
- virtual void NumberOfFindResultsChanged(PP_Instance instance,
- int32_t total,
- PP_Bool final_result) OVERRIDE;
- virtual void SelectedFindResultChanged(PP_Instance instance,
- int32_t index) OVERRIDE;
-
- private:
- PluginInstance* instance_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_Find_Impl);
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_FIND_IMPL_H_
diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index 0da1b3a..6ff6928b 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -52,7 +52,7 @@ PPB_Font_Impl::PPB_Font_Impl(PluginInstance* instance,
PPB_Font_Impl::~PPB_Font_Impl() {
}
-::ppapi::thunk::PPB_Font_API* PPB_Font_Impl::AsPPB_Font_API() {
+::ppapi::thunk::PPB_Font_API* PPB_Font_Impl::AsFont_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h
index 23416ef..2c8886e 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -28,7 +28,7 @@ class PPB_Font_Impl : public Resource,
virtual ~PPB_Font_Impl();
// ResourceObjectBase.
- virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
+ virtual ::ppapi::thunk::PPB_Font_API* AsFont_API() OVERRIDE;
// Resource overrides.
virtual PPB_Font_Impl* AsPPB_Font_Impl() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index ff54442..813ea0f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -176,8 +176,7 @@ bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
return true;
}
-::ppapi::thunk::PPB_Graphics2D_API*
-PPB_Graphics2D_Impl::AsPPB_Graphics2D_API() {
+::ppapi::thunk::PPB_Graphics2D_API* PPB_Graphics2D_Impl::AsGraphics2D_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 6739b60..66e3032 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -42,7 +42,7 @@ class PPB_Graphics2D_Impl
bool is_always_opaque() const { return is_always_opaque_; }
- virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API();
+ virtual ::ppapi::thunk::PPB_Graphics2D_API* AsGraphics2D_API();
// Resource override.
virtual PPB_Graphics2D_Impl* AsPPB_Graphics2D_Impl();
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index 1c621a4..2f722e0 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -62,7 +62,7 @@ const PPB_ImageDataTrusted* PPB_ImageData_Impl::GetTrustedInterface() {
return &ppb_imagedata_trusted;
}
-::ppapi::thunk::PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() {
+::ppapi::thunk::PPB_ImageData_API* PPB_ImageData_Impl::AsImageData_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index 096e54e..14a004d 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -53,7 +53,7 @@ class PPB_ImageData_Impl : public Resource,
static const PPB_ImageData* GetInterface();
static const PPB_ImageDataTrusted* GetTrustedInterface();
- virtual ::ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API();
+ virtual ::ppapi::thunk::PPB_ImageData_API* AsImageData_API();
// Resource overrides.
virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl();
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 11a1e5a..6e4ef7d 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -10,11 +10,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_chooser_impl.h"
-#include "webkit/plugins/ppapi/ppb_file_io_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_font_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
@@ -30,7 +25,7 @@ ResourceCreationImpl::~ResourceCreationImpl() {
}
::ppapi::thunk::ResourceCreationAPI*
-ResourceCreationImpl::AsResourceCreationAPI() {
+ResourceCreationImpl::AsResourceCreation() {
return this;
}
@@ -80,32 +75,6 @@ PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
return PPB_Buffer_Impl::Create(instance, size);
}
-PP_Resource ResourceCreationImpl::CreateDirectoryReader(
- PP_Resource directory_ref) {
- return PPB_DirectoryReader_Impl::Create(directory_ref);
-}
-
-PP_Resource ResourceCreationImpl::CreateFileChooser(
- PP_Instance instance,
- const PP_FileChooserOptions_Dev* options) {
- return PPB_FileChooser_Impl::Create(instance, options);
-}
-
-PP_Resource ResourceCreationImpl::CreateFileIO(PP_Instance instance) {
- return PPB_FileIO_Impl::Create(instance);
-}
-
-PP_Resource ResourceCreationImpl::CreateFileRef(PP_Resource file_system,
- const char* path) {
- return PPB_FileRef_Impl::Create(file_system, path);
-}
-
-PP_Resource ResourceCreationImpl::CreateFileSystem(
- PP_Instance instance,
- PP_FileSystemType_Dev type) {
- return PPB_FileSystem_Impl::Create(instance, type);
-}
-
PP_Resource ResourceCreationImpl::CreateFontObject(
PP_Instance pp_instance,
const PP_FontDescription_Dev* description) {
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index c2550b3..9569620 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -22,7 +22,7 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
virtual ~ResourceCreationImpl();
// FunctionGroupBase implementation.
- virtual ::ppapi::thunk::ResourceCreationAPI* AsResourceCreationAPI();
+ virtual ::ppapi::thunk::ResourceCreationAPI* AsResourceCreation();
// ResourceCreationAPI implementation.
virtual PP_Resource CreateAudio(PP_Instance instance,
@@ -36,15 +36,6 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
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 CreateFileChooser(
- PP_Instance instance,
- const PP_FileChooserOptions_Dev* options) OVERRIDE;
- virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE;
- virtual PP_Resource CreateFileRef(PP_Resource file_system,
- const char* path) OVERRIDE;
- virtual PP_Resource CreateFileSystem(PP_Instance instance,
- PP_FileSystemType_Dev type) OVERRIDE;
virtual PP_Resource CreateFontObject(
PP_Instance instance,
const PP_FontDescription_Dev* description) OVERRIDE;
diff --git a/webkit/plugins/ppapi/resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc
index ba2ad6b..7e04f61 100644
--- a/webkit/plugins/ppapi/resource_tracker.cc
+++ b/webkit/plugins/ppapi/resource_tracker.cc
@@ -290,13 +290,6 @@ uint32 ResourceTracker::GetLiveObjectsForInstance(
return proxy.get();
}
-PP_Instance ResourceTracker::GetInstanceForResource(PP_Resource pp_resource) {
- scoped_refptr<Resource> resource(GetResource(pp_resource));
- if (!resource.get())
- return 0;
- return resource->instance()->pp_instance();
-}
-
scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const {
DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
<< var_id << " is not a PP_Var ID.";
diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h
index d5618e6..2d008f9 100644
--- a/webkit/plugins/ppapi/resource_tracker.h
+++ b/webkit/plugins/ppapi/resource_tracker.h
@@ -59,11 +59,10 @@ class ResourceTracker : public ::ppapi::TrackerBase {
// ResourceTrackerBase.
virtual ::ppapi::ResourceObjectBase* GetResourceAPI(
- PP_Resource res) OVERRIDE;
+ PP_Resource res);
virtual ::ppapi::FunctionGroupBase* GetFunctionAPI(
PP_Instance pp_instance,
- pp::proxy::InterfaceID id) OVERRIDE;
- virtual PP_Instance GetInstanceForResource(PP_Resource resource) OVERRIDE;
+ pp::proxy::InterfaceID id);
// PP_Vars -------------------------------------------------------------------