summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 00:54:12 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 00:54:12 +0000
commit45afd9a78d3316144d6702ff3cc230b4b76d76c7 (patch)
tree1218e4defacc49ab0347605e1150f3baf9b46abb /webkit
parent0e33985b3bf62dab5266b1fcbfbdf11991b0822e (diff)
downloadchromium_src-45afd9a78d3316144d6702ff3cc230b4b76d76c7.zip
chromium_src-45afd9a78d3316144d6702ff3cc230b4b76d76c7.tar.gz
chromium_src-45afd9a78d3316144d6702ff3cc230b4b76d76c7.tar.bz2
Support sync file io for pepper, to support LSOs
BUG=chromium-os:7492 TEST=run pepper flash (with LSO support) on http://www.bestflashanimationsite.com/tutorials/4/ , check that it properly stores the objects. Review URL: http://codereview.chromium.org/3800010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/pepper_dir_contents.h18
-rw-r--r--webkit/glue/plugins/pepper_plugin_delegate.h26
-rw-r--r--webkit/glue/plugins/pepper_plugin_module.h6
-rw-r--r--webkit/glue/plugins/pepper_private2.cc189
-rw-r--r--webkit/glue/plugins/ppb_private2.h72
5 files changed, 303 insertions, 8 deletions
diff --git a/webkit/glue/plugins/pepper_dir_contents.h b/webkit/glue/plugins/pepper_dir_contents.h
new file mode 100644
index 0000000..661c577
--- /dev/null
+++ b/webkit/glue/plugins/pepper_dir_contents.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_
+#define WEBKIT_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_
+
+#include <vector>
+#include "base/file_path.h"
+
+struct PepperDirEntry {
+ FilePath name;
+ bool is_dir;
+};
+
+typedef std::vector<PepperDirEntry> PepperDirContents;
+
+#endif // WEBKIT_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_
diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/glue/plugins/pepper_plugin_delegate.h
index f080f34..7558a2c 100644
--- a/webkit/glue/plugins/pepper_plugin_delegate.h
+++ b/webkit/glue/plugins/pepper_plugin_delegate.h
@@ -16,6 +16,7 @@
#include "third_party/ppapi/c/pp_completion_callback.h"
#include "third_party/ppapi/c/pp_errors.h"
#include "third_party/ppapi/c/pp_stdint.h"
+#include "webkit/glue/plugins/pepper_dir_contents.h"
class AudioMessageFilter;
class GURL;
@@ -191,6 +192,31 @@ class PluginDelegate {
const FilePath& new_file_path,
fileapi::FileSystemCallbackDispatcher* dispatcher) = 0;
+ virtual base::PlatformFileError OpenModuleLocalFile(
+ const std::string& module_name,
+ const FilePath& path,
+ int flags,
+ base::PlatformFile* file) = 0;
+ virtual base::PlatformFileError RenameModuleLocalFile(
+ const std::string& module_name,
+ const FilePath& path_from,
+ const FilePath& path_to) = 0;
+ virtual base::PlatformFileError DeleteModuleLocalFileOrDir(
+ const std::string& module_name,
+ const FilePath& path,
+ bool recursive) = 0;
+ virtual base::PlatformFileError CreateModuleLocalDir(
+ const std::string& module_name,
+ const FilePath& path) = 0;
+ virtual base::PlatformFileError QueryModuleLocalFile(
+ const std::string& module_name,
+ const FilePath& path,
+ base::PlatformFileInfo* info) = 0;
+ virtual base::PlatformFileError GetModuleLocalDirContents(
+ const std::string& module_name,
+ const FilePath& path,
+ PepperDirContents* contents) = 0;
+
// Returns a MessageLoopProxy instance associated with the message loop
// of the file thread in this renderer.
virtual scoped_refptr<base::MessageLoopProxy>
diff --git a/webkit/glue/plugins/pepper_plugin_module.h b/webkit/glue/plugins/pepper_plugin_module.h
index edb9e12..4ac13c3 100644
--- a/webkit/glue/plugins/pepper_plugin_module.h
+++ b/webkit/glue/plugins/pepper_plugin_module.h
@@ -61,6 +61,9 @@ class PluginModule : public base::RefCounted<PluginModule>,
PP_Module pp_module() const { return pp_module_; }
+ void set_name(const std::string& name) { name_ = name; }
+ const std::string& name() const { return name_; }
+
PluginInstance* CreateInstance(PluginDelegate* delegate);
// Returns "some" plugin instance associated with this module. This is not
@@ -115,6 +118,9 @@ class PluginModule : public base::RefCounted<PluginModule>,
// implementation.
EntryPoints entry_points_;
+ // The name of the module.
+ std::string name_;
+
// Non-owning pointers to all instances associated with this module. When
// there are no more instances, this object should be deleted.
typedef std::set<PluginInstance*> PluginInstanceSet;
diff --git a/webkit/glue/plugins/pepper_private2.cc b/webkit/glue/plugins/pepper_private2.cc
index 71ffc4b..a96ef30 100644
--- a/webkit/glue/plugins/pepper_private2.cc
+++ b/webkit/glue/plugins/pepper_private2.cc
@@ -4,8 +4,15 @@
#include "webkit/glue/plugins/pepper_private2.h"
+#include <string.h>
+
+#include "base/file_path.h"
#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
+#include "third_party/ppapi/c/dev/pp_file_info_dev.h"
+#include "third_party/ppapi/c/dev/ppb_file_io_dev.h"
+#include "webkit/glue/plugins/pepper_error_util.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
@@ -16,6 +23,14 @@ namespace pepper {
namespace {
+PluginInstance* GetSomeInstance(PP_Module pp_module) {
+ PluginModule* module = ResourceTracker::Get()->GetModule(pp_module);
+ if (!module)
+ return NULL;
+
+ return module->GetSomeInstance();
+}
+
void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
@@ -24,11 +39,7 @@ void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) {
}
PP_Var GetProxyForURL(PP_Module pp_module, const char* url) {
- PluginModule* module = ResourceTracker::Get()->GetModule(pp_module);
- if (!module)
- return PP_MakeUndefined();
-
- PluginInstance* instance = module->GetSomeInstance();
+ PluginInstance* instance = GetSomeInstance(pp_module);
if (!instance)
return PP_MakeUndefined();
@@ -39,13 +50,177 @@ PP_Var GetProxyForURL(PP_Module pp_module, const char* url) {
std::string proxy_host = instance->delegate()->ResolveProxy(gurl);
if (proxy_host.empty())
return PP_MakeUndefined(); // No proxy.
- return StringVar::StringToPPVar(module, proxy_host);
+ return StringVar::StringToPPVar(instance->module(), proxy_host);
+}
+
+FilePath GetFilePathFromUTF8(const char* path) {
+#if defined(OS_WIN)
+ return FilePath(UTF8ToUTF16(path));
+#else
+ return FilePath(path);
+#endif
+}
+
+int32_t OpenModuleLocalFile(PP_Module module,
+ const char* path,
+ int32_t mode,
+ PP_FileHandle* file) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ int flags = 0;
+ if (mode & PP_FILEOPENFLAG_READ)
+ flags |= base::PLATFORM_FILE_READ;
+ if (mode & PP_FILEOPENFLAG_WRITE) {
+ flags |= base::PLATFORM_FILE_WRITE;
+ flags |= base::PLATFORM_FILE_WRITE_ATTRIBUTES;
+ }
+ if (mode & PP_FILEOPENFLAG_TRUNCATE) {
+ DCHECK(mode & PP_FILEOPENFLAG_WRITE);
+ flags |= base::PLATFORM_FILE_TRUNCATE;
+ }
+
+ if (mode & PP_FILEOPENFLAG_CREATE) {
+ if (mode & PP_FILEOPENFLAG_EXCLUSIVE)
+ flags |= base::PLATFORM_FILE_CREATE;
+ else
+ flags |= base::PLATFORM_FILE_OPEN_ALWAYS;
+ } else {
+ flags |= base::PLATFORM_FILE_OPEN;
+ }
+
+ base::PlatformFile base_file;
+ base::PlatformFileError result = instance->delegate()->OpenModuleLocalFile(
+ instance->module()->name(),
+ GetFilePathFromUTF8(path),
+ flags,
+ &base_file);
+ *file = base_file;
+ return PlatformFileErrorToPepperError(result);
+}
+
+
+int32_t RenameModuleLocalFile(PP_Module module,
+ const char* path_from,
+ const char* path_to) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ base::PlatformFileError result = instance->delegate()->RenameModuleLocalFile(
+ instance->module()->name(),
+ GetFilePathFromUTF8(path_from),
+ GetFilePathFromUTF8(path_to));
+ return PlatformFileErrorToPepperError(result);
+}
+
+int32_t DeleteModuleLocalFileOrDir(PP_Module module,
+ const char* path,
+ bool recursive) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ base::PlatformFileError result =
+ instance->delegate()->DeleteModuleLocalFileOrDir(
+ instance->module()->name(), GetFilePathFromUTF8(path), recursive);
+ return PlatformFileErrorToPepperError(result);
+}
+
+int32_t CreateModuleLocalDir(PP_Module module, const char* path) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ base::PlatformFileError result = instance->delegate()->CreateModuleLocalDir(
+ instance->module()->name(), GetFilePathFromUTF8(path));
+ return PlatformFileErrorToPepperError(result);
+}
+
+int32_t QueryModuleLocalFile(PP_Module module,
+ const char* path,
+ PP_FileInfo_Dev* info) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ base::PlatformFileInfo file_info;
+ base::PlatformFileError result = instance->delegate()->QueryModuleLocalFile(
+ instance->module()->name(), GetFilePathFromUTF8(path), &file_info);
+ if (result == base::PLATFORM_FILE_OK) {
+ info->size = file_info.size;
+ info->creation_time = file_info.creation_time.ToDoubleT();
+ info->last_access_time = file_info.last_accessed.ToDoubleT();
+ info->last_modified_time = file_info.last_modified.ToDoubleT();
+ info->system_type = PP_FILESYSTEMTYPE_EXTERNAL;
+ if (file_info.is_directory)
+ info->type = PP_FILETYPE_DIRECTORY;
+ else
+ info->type = PP_FILETYPE_REGULAR;
+ }
+ return PlatformFileErrorToPepperError(result);
+}
+
+int32_t GetModuleLocalDirContents(PP_Module module,
+ const char* path,
+ PP_DirContents_Dev** contents) {
+ PluginInstance* instance = GetSomeInstance(module);
+ if (!instance)
+ return PP_ERROR_FAILED;
+
+ *contents = NULL;
+ PepperDirContents pepper_contents;
+ base::PlatformFileError result =
+ instance->delegate()->GetModuleLocalDirContents(
+ instance->module()->name(),
+ GetFilePathFromUTF8(path),
+ &pepper_contents);
+
+ if (result != base::PLATFORM_FILE_OK)
+ return PlatformFileErrorToPepperError(result);
+
+ *contents = new PP_DirContents_Dev;
+ size_t count = pepper_contents.size();
+ (*contents)->count = count;
+ (*contents)->entries = new PP_DirEntry_Dev[count];
+ for (size_t i = 0; i < count; ++i) {
+ PP_DirEntry_Dev& entry = (*contents)->entries[i];
+#if defined(OS_WIN)
+ const std::string& name = UTF16ToUTF8(pepper_contents[i].name.value());
+#else
+ const std::string& name = pepper_contents[i].name.value();
+#endif
+ size_t size = name.size() + 1;
+ char* name_copy = new char[size];
+ memcpy(name_copy, name.c_str(), size);
+ entry.name = name_copy;
+ entry.is_dir = pepper_contents[i].is_dir;
+ }
+ return PP_OK;
+}
+
+void FreeModuleLocalDirContents(PP_Module module,
+ PP_DirContents_Dev* contents) {
+ DCHECK(contents);
+ for (int32_t i = 0; i < contents->count; ++i) {
+ delete [] contents->entries[i].name;
+ }
+ delete [] contents->entries;
+ delete contents;
}
const PPB_Private2 ppb_private2 = {
&SetInstanceAlwaysOnTop,
&Private2::DrawGlyphs,
- &GetProxyForURL
+ &GetProxyForURL,
+ &OpenModuleLocalFile,
+ &RenameModuleLocalFile,
+ &DeleteModuleLocalFileOrDir,
+ &CreateModuleLocalDir,
+ &QueryModuleLocalFile,
+ &GetModuleLocalDirContents,
+ &FreeModuleLocalDirContents,
};
} // namespace
diff --git a/webkit/glue/plugins/ppb_private2.h b/webkit/glue/plugins/ppb_private2.h
index 667d5c5..0b0df98 100644
--- a/webkit/glue/plugins/ppb_private2.h
+++ b/webkit/glue/plugins/ppb_private2.h
@@ -5,6 +5,11 @@
#ifndef WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#include "third_party/ppapi/c/pp_errors.h"
#include "third_party/ppapi/c/pp_instance.h"
#include "third_party/ppapi/c/pp_module.h"
#include "third_party/ppapi/c/pp_point.h"
@@ -12,9 +17,28 @@
#include "third_party/ppapi/c/pp_resource.h"
#include "third_party/ppapi/c/pp_var.h"
-#define PPB_PRIVATE2_INTERFACE "PPB_Private2;2"
+#define PPB_PRIVATE2_INTERFACE "PPB_Private2;3"
+
+#ifdef _WIN32
+typedef HANDLE PP_FileHandle;
+static const PP_FileHandle PP_kInvalidFileHandle = NULL;
+#else
+typedef int PP_FileHandle;
+static const PP_FileHandle PP_kInvalidFileHandle = -1;
+#endif
struct PP_FontDescription_Dev;
+struct PP_FileInfo_Dev;
+
+struct PP_DirEntry_Dev {
+ const char* name;
+ bool is_dir;
+};
+
+struct PP_DirContents_Dev {
+ int32_t count;
+ PP_DirEntry_Dev* entries;
+};
struct PPB_Private2 {
// Sets or clears the rendering hint that the given plugin instance is always
@@ -35,6 +59,52 @@ struct PPB_Private2 {
// Retrieves the proxy that will be used for the given URL. The result will
// be a string in PAC format, or an undefined var on error.
PP_Var (*GetProxyForURL)(PP_Module module, const char* url);
+
+ // Opens a module-local file, returning a file descriptor (posix) or a HANDLE
+ // (win32) into file. Module-local file paths (here and below) are
+ // '/'-separated UTF-8 strings, relative to a module-specific root. The return
+ // value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in case
+ // of failure.
+ int32_t (*OpenModuleLocalFile)(PP_Module module,
+ const char* path,
+ int32_t mode,
+ PP_FileHandle* file);
+
+ // Renames a module-local file. The return value is the ppapi error, PP_OK if
+ // success, one of the PP_ERROR_* in case of failure.
+ int32_t (*RenameModuleLocalFile)(PP_Module module,
+ const char* path_from,
+ const char* path_to);
+
+ // Deletes a module-local file or directory. If recursive is set and the path
+ // points to a directory, deletes all the contents of the directory. The
+ // return value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in
+ // case of failure.
+ int32_t (*DeleteModuleLocalFileOrDir)(PP_Module module,
+ const char* path,
+ bool recursive);
+
+ // Creates a module-local directory. The return value is the ppapi error,
+ // PP_OK if success, one of the PP_ERROR_* in case of failure.
+ int32_t (*CreateModuleLocalDir)(PP_Module module, const char* path);
+
+ // Queries information about a module-local file. The return value is the
+ // ppapi error, PP_OK if success, one of the PP_ERROR_* in case of failure.
+ int32_t (*QueryModuleLocalFile)(PP_Module module,
+ const char* path,
+ PP_FileInfo_Dev* info);
+
+ // Gets the list of files contained in a module-local directory. The return
+ // value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in case
+ // of failure. If non-NULL, the returned contents should be freed with
+ // FreeModuleLocalDirContents.
+ int32_t (*GetModuleLocalDirContents)(PP_Module module,
+ const char* path,
+ PP_DirContents_Dev** contents);
+
+ // Frees the data allocated by GetModuleLocalDirContents.
+ void (*FreeModuleLocalDirContents)(PP_Module module,
+ PP_DirContents_Dev* contents);
};
#endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_