summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/private/ppb_flash_file.h13
-rw-r--r--ppapi/cpp/private/flash_file.cc31
-rw-r--r--ppapi/cpp/private/flash_file.h6
-rw-r--r--ppapi/ppapi_ipc.gypi2
-rw-r--r--ppapi/ppapi_proxy.gypi3
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/flash_file_resource.cc231
-rw-r--r--ppapi/proxy/flash_file_resource.h73
-rw-r--r--ppapi/proxy/pepper_file_messages.cc68
-rw-r--r--ppapi/proxy/pepper_file_messages.h82
-rw-r--r--ppapi/proxy/plugin_dispatcher.cc1
-rw-r--r--ppapi/proxy/plugin_dispatcher.h3
-rw-r--r--ppapi/proxy/plugin_resource.cc13
-rw-r--r--ppapi/proxy/plugin_resource.h27
-rw-r--r--ppapi/proxy/ppapi_messages.h41
-rw-r--r--ppapi/proxy/ppapi_param_traits.cc44
-rw-r--r--ppapi/proxy/ppapi_param_traits.h9
-rw-r--r--ppapi/proxy/ppb_flash_proxy.cc234
-rw-r--r--ppapi/proxy/ppb_flash_proxy.h43
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc5
-rw-r--r--ppapi/proxy/resource_message_params.cc11
-rw-r--r--ppapi/proxy/resource_message_params.h6
-rw-r--r--ppapi/proxy/serialized_structs.cc17
-rw-r--r--ppapi/proxy/serialized_structs.h17
-rw-r--r--ppapi/shared_impl/file_path.cc31
-rw-r--r--ppapi/shared_impl/file_path.h6
-rw-r--r--ppapi/shared_impl/ppb_flash_shared.cc23
-rw-r--r--ppapi/shared_impl/ppb_flash_shared.h30
-rw-r--r--ppapi/shared_impl/resource.h1
-rw-r--r--ppapi/shared_impl/singleton_resource_id.h1
-rw-r--r--ppapi/tests/test_flash_file.cc212
-rw-r--r--ppapi/tests/test_flash_file.h15
-rw-r--r--ppapi/thunk/ppb_file_ref_api.h2
-rw-r--r--ppapi/thunk/ppb_flash_api.h34
-rw-r--r--ppapi/thunk/ppb_flash_file_api.h63
-rw-r--r--ppapi/thunk/ppb_flash_file_fileref_thunk.cc13
-rw-r--r--ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc49
37 files changed, 685 insertions, 777 deletions
diff --git a/ppapi/c/private/ppb_flash_file.h b/ppapi/c/private/ppb_flash_file.h
index 807fc04..758056f 100644
--- a/ppapi/c/private/ppb_flash_file.h
+++ b/ppapi/c/private/ppb_flash_file.h
@@ -32,9 +32,18 @@ struct PP_DirContents_Dev {
// Module-local file paths are '/'-separated UTF-8 strings, relative to a
// module-specific root.
struct PPB_Flash_File_ModuleLocal_3_0 {
- // Deprecated. Returns true.
+ // Does initialization necessary for proxying this interface on background
+ // threads. You must always call this function before using any other
+ // function in this interface for a given instance ID.
+ //
+ // Returns true if multithreaded access is supported. In this case you can
+ // use the rest of the functions from background threads. You may not call
+ // GetInterface or do any other PPAPI operations on background threads at
+ // this time.
bool (*CreateThreadAdapterForInstance)(PP_Instance instance);
- // Deprecated. Does nothing.
+
+ // Call when an instance is destroyed when you've previously called
+ // CreateThreadAdapterForInstance.
void (*ClearThreadAdapterForInstance)(PP_Instance instance);
// Opens a file, returning a file descriptor (posix) or a HANDLE (win32) into
diff --git a/ppapi/cpp/private/flash_file.cc b/ppapi/cpp/private/flash_file.cc
index a38f007..2aea2c3 100644
--- a/ppapi/cpp/private/flash_file.cc
+++ b/ppapi/cpp/private/flash_file.cc
@@ -40,6 +40,32 @@ bool FileModuleLocal::IsAvailable() {
}
// static
+bool FileModuleLocal::CreateThreadAdapterForInstance(
+ const InstanceHandle& instance) {
+ bool rv = false;
+ if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) {
+ rv = get_interface<PPB_Flash_File_ModuleLocal_3_0>()->
+ CreateThreadAdapterForInstance(instance.pp_instance());
+ } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) {
+ rv = get_interface<PPB_Flash_File_ModuleLocal_2_0>()->
+ CreateThreadAdapterForInstance( instance.pp_instance());
+ }
+ return rv;
+}
+
+// static
+void FileModuleLocal::ClearThreadAdapterForInstance(
+ const InstanceHandle& instance) {
+ if (has_interface<PPB_Flash_File_ModuleLocal_3_0>()) {
+ get_interface<PPB_Flash_File_ModuleLocal_3_0>()->
+ ClearThreadAdapterForInstance(instance.pp_instance());
+ } else if (has_interface<PPB_Flash_File_ModuleLocal_2_0>()) {
+ get_interface<PPB_Flash_File_ModuleLocal_2_0>()->
+ ClearThreadAdapterForInstance(instance.pp_instance());
+ }
+}
+
+// static
PP_FileHandle FileModuleLocal::OpenFile(const InstanceHandle& instance,
const std::string& path,
int32_t mode) {
@@ -153,6 +179,11 @@ bool FileModuleLocal::GetDirContents(
}
// static
+bool FileModuleLocal::IsCreateTemporaryFileAvailable() {
+ return has_interface<PPB_Flash_File_ModuleLocal_3_0>();
+}
+
+// static
PP_FileHandle FileModuleLocal::CreateTemporaryFile(
const InstanceHandle& instance) {
PP_FileHandle file_handle = PP_kInvalidFileHandle;
diff --git a/ppapi/cpp/private/flash_file.h b/ppapi/cpp/private/flash_file.h
index 04ab195..a7c655a 100644
--- a/ppapi/cpp/private/flash_file.h
+++ b/ppapi/cpp/private/flash_file.h
@@ -24,6 +24,9 @@ class FileModuleLocal {
// Returns true if the required interface is available.
static bool IsAvailable();
+ static bool CreateThreadAdapterForInstance(const InstanceHandle& instance);
+ static void ClearThreadAdapterForInstance(const InstanceHandle& instance);
+
// Returns |PP_kInvalidFileHandle| on error.
static PP_FileHandle OpenFile(const InstanceHandle& instance,
const std::string& path,
@@ -48,6 +51,9 @@ class FileModuleLocal {
const std::string& path,
std::vector<DirEntry>* dir_contents);
+ // Returns true if |CreateTemporaryFile()| is supported.
+ // TODO(viettrungluu): Remove this sometime after M21 ships to Stable?
+ static bool IsCreateTemporaryFileAvailable();
// Returns |PP_kInvalidFileHandle| on error.
static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance);
};
diff --git a/ppapi/ppapi_ipc.gypi b/ppapi/ppapi_ipc.gypi
index 8e374b2..8c23bf2 100644
--- a/ppapi/ppapi_ipc.gypi
+++ b/ppapi/ppapi_ipc.gypi
@@ -12,6 +12,8 @@
# This part is shared between the targets defined below.
['ppapi_ipc_target==1', {
'sources': [
+ 'proxy/pepper_file_messages.cc',
+ 'proxy/pepper_file_messages.h',
'proxy/ppapi_messages.cc',
'proxy/ppapi_messages.h',
'proxy/ppapi_param_traits.cc',
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 81ec94f..f835ff2 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -39,8 +39,6 @@
'proxy/flash_clipboard_resource.h',
'proxy/flash_device_id_resource.cc',
'proxy/flash_device_id_resource.h',
- 'proxy/flash_file_resource.cc',
- 'proxy/flash_file_resource.h',
'proxy/flash_font_file_resource.cc',
'proxy/flash_font_file_resource.h',
'proxy/flash_fullscreen_resource.cc',
@@ -189,7 +187,6 @@
'proxy/device_enumeration_resource_helper.cc',
'proxy/flash_clipboard_resource.cc',
'proxy/flash_device_id_resource.cc',
- 'proxy/flash_file_resource.cc',
'proxy/flash_font_file_resource.cc',
'proxy/flash_fullscreen_resource.cc',
'proxy/flash_menu_resource.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 9033612..da446ef 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -55,6 +55,8 @@
'shared_impl/ppb_file_io_shared.h',
'shared_impl/ppb_file_ref_shared.cc',
'shared_impl/ppb_file_ref_shared.h',
+ 'shared_impl/ppb_flash_shared.cc',
+ 'shared_impl/ppb_flash_shared.h',
'shared_impl/ppb_gamepad_shared.cc',
'shared_impl/ppb_gamepad_shared.h',
'shared_impl/ppb_graphics_3d_shared.cc',
diff --git a/ppapi/proxy/flash_file_resource.cc b/ppapi/proxy/flash_file_resource.cc
deleted file mode 100644
index ac9e555..0000000
--- a/ppapi/proxy/flash_file_resource.cc
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (c) 2012 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 "ppapi/proxy/flash_file_resource.h"
-
-#include "base/file_path.h"
-#include "ipc/ipc_message.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/shared_impl/file_type_conversion.h"
-#include "ppapi/shared_impl/scoped_pp_var.h"
-#include "ppapi/shared_impl/time_conversion.h"
-#include "ppapi/shared_impl/var.h"
-#include "ppapi/thunk/enter.h"
-
-namespace ppapi {
-namespace proxy {
-
-namespace {
-
-// Returns the path that a PPB_FileRef resource references as long as it is an
-// PP_FILESYSTEMTYPE_EXTERNAL path. Returns an empty string on error.
-std::string GetPathFromFileRef(PP_Resource file_ref) {
- thunk::EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true);
- if (enter.failed())
- return std::string();
- if (enter.object()->GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL)
- return std::string();
- ScopedPPVar var(ScopedPPVar::PassRef(), enter.object()->GetAbsolutePath());
- StringVar* string_var = StringVar::FromPPVar(var.get());
- if (!string_var)
- return std::string();
- return string_var->value();
-}
-
-} // namespace
-
-FlashFileResource::FlashFileResource(Connection connection,
- PP_Instance instance)
- : PluginResource(connection, instance) {
- SendCreate(BROWSER, PpapiHostMsg_FlashFile_Create());
-}
-
-FlashFileResource::~FlashFileResource() {
-}
-
-thunk::PPB_Flash_File_API* FlashFileResource::AsPPB_Flash_File_API() {
- return this;
-}
-
-int32_t FlashFileResource::OpenFile(PP_Instance /*instance*/,
- const char* path,
- int32_t mode,
- PP_FileHandle* file) {
- return OpenFileHelper(path, PepperFilePath::DOMAIN_MODULE_LOCAL, mode, file);
-}
-
-int32_t FlashFileResource::RenameFile(PP_Instance /*instance*/,
- const char* path_from,
- const char* path_to) {
- PepperFilePath pepper_from(PepperFilePath::DOMAIN_MODULE_LOCAL,
- FilePath::FromUTF8Unsafe(path_from));
- PepperFilePath pepper_to(PepperFilePath::DOMAIN_MODULE_LOCAL,
- FilePath::FromUTF8Unsafe(path_to));
-
- int32_t error = SyncCall<IPC::Message>(
- BROWSER, PpapiHostMsg_FlashFile_RenameFile(pepper_from, pepper_to));
-
- return error;
-}
-
-int32_t FlashFileResource::DeleteFileOrDir(PP_Instance /*instance*/,
- const char* path,
- PP_Bool recursive) {
- PepperFilePath pepper_path(PepperFilePath::DOMAIN_MODULE_LOCAL,
- FilePath::FromUTF8Unsafe(path));
-
- int32_t error = SyncCall<IPC::Message>(
- BROWSER, PpapiHostMsg_FlashFile_DeleteFileOrDir(pepper_path,
- PP_ToBool(recursive)));
-
- return error;
-}
-
-int32_t FlashFileResource::CreateDir(PP_Instance /*instance*/,
- const char* path) {
- PepperFilePath pepper_path(PepperFilePath::DOMAIN_MODULE_LOCAL,
- FilePath::FromUTF8Unsafe(path));
-
- int32_t error = SyncCall<IPC::Message>(BROWSER,
- PpapiHostMsg_FlashFile_CreateDir(pepper_path));
-
- return error;
-}
-
-int32_t FlashFileResource::QueryFile(PP_Instance /*instance*/,
- const char* path,
- PP_FileInfo* info) {
- return QueryFileHelper(path, PepperFilePath::DOMAIN_MODULE_LOCAL, info);
-}
-
-int32_t FlashFileResource::GetDirContents(PP_Instance /*instance*/,
- const char* path,
- PP_DirContents_Dev** contents) {
- ppapi::DirContents entries;
- PepperFilePath pepper_path(PepperFilePath::DOMAIN_MODULE_LOCAL,
- FilePath::FromUTF8Unsafe(path));
-
- int32_t error = SyncCall<PpapiPluginMsg_FlashFile_GetDirContentsReply>(
- BROWSER, PpapiHostMsg_FlashFile_GetDirContents(pepper_path), &entries);
-
- if (error == PP_OK) {
- // Copy the serialized dir entries to the output struct.
- *contents = new PP_DirContents_Dev;
- (*contents)->count = static_cast<int32_t>(entries.size());
- (*contents)->entries = new PP_DirEntry_Dev[entries.size()];
- for (size_t i = 0; i < entries.size(); i++) {
- const ppapi::DirEntry& source = entries[i];
- PP_DirEntry_Dev* dest = &(*contents)->entries[i];
- std::string name = source.name.AsUTF8Unsafe();
- char* name_copy = new char[name.size() + 1];
- memcpy(name_copy, name.c_str(), name.size() + 1);
- dest->name = name_copy;
- dest->is_dir = PP_FromBool(source.is_dir);
- }
- }
-
- return error;
-}
-
-void FlashFileResource::FreeDirContents(PP_Instance /*instance*/,
- PP_DirContents_Dev* contents) {
- for (int32_t i = 0; i < contents->count; ++i)
- delete[] contents->entries[i].name;
- delete[] contents->entries;
- delete contents;
-}
-
-int32_t FlashFileResource::CreateTemporaryFile(PP_Instance /*instance*/,
- PP_FileHandle* file) {
- if (!file)
- return PP_ERROR_BADARGUMENT;
-
- IPC::Message unused;
- ResourceMessageReplyParams reply_params;
- int32_t error = GenericSyncCall(BROWSER,
- PpapiHostMsg_FlashFile_CreateTemporaryFile(), &unused, &reply_params);
- if (error != PP_OK)
- return error;
-
- IPC::PlatformFileForTransit transit_file;
- if (!reply_params.TakeFileHandleAtIndex(0, &transit_file))
- return PP_ERROR_FAILED;
-
- *file = IPC::PlatformFileForTransitToPlatformFile(transit_file);
- return PP_OK;
-}
-
-int32_t FlashFileResource::OpenFileRef(PP_Instance /*instance*/,
- PP_Resource file_ref,
- int32_t mode,
- PP_FileHandle* file) {
- return OpenFileHelper(GetPathFromFileRef(file_ref),
- PepperFilePath::DOMAIN_ABSOLUTE, mode, file);
-}
-
-int32_t FlashFileResource::QueryFileRef(PP_Instance /*instance*/,
- PP_Resource file_ref,
- PP_FileInfo* info) {
- return QueryFileHelper(GetPathFromFileRef(file_ref),
- PepperFilePath::DOMAIN_ABSOLUTE, info);
-}
-
-int32_t FlashFileResource::OpenFileHelper(const std::string& path,
- PepperFilePath::Domain domain_type,
- int32_t mode,
- PP_FileHandle* file) {
- int flags = 0;
- if (path.empty() ||
- !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) ||
- !file)
- return PP_ERROR_BADARGUMENT;
-
- PepperFilePath pepper_path(domain_type, FilePath::FromUTF8Unsafe(path));
-
- IPC::Message unused;
- ResourceMessageReplyParams reply_params;
- int32_t error = GenericSyncCall(BROWSER,
- PpapiHostMsg_FlashFile_OpenFile(pepper_path, flags), &unused,
- &reply_params);
- if (error != PP_OK)
- return error;
-
- IPC::PlatformFileForTransit transit_file;
- if (!reply_params.TakeFileHandleAtIndex(0, &transit_file))
- return PP_ERROR_FAILED;
-
- *file = IPC::PlatformFileForTransitToPlatformFile(transit_file);
- return PP_OK;
-}
-
-int32_t FlashFileResource::QueryFileHelper(const std::string& path,
- PepperFilePath::Domain domain_type,
- PP_FileInfo* info) {
- if (path.empty() || !info)
- return PP_ERROR_BADARGUMENT;
-
- base::PlatformFileInfo file_info;
- PepperFilePath pepper_path(domain_type, FilePath::FromUTF8Unsafe(path));
-
- int32_t error = SyncCall<PpapiPluginMsg_FlashFile_QueryFileReply>(BROWSER,
- PpapiHostMsg_FlashFile_QueryFile(pepper_path), &file_info);
-
- if (error == PP_OK) {
- info->size = file_info.size;
- info->creation_time = TimeToPPTime(file_info.creation_time);
- info->last_access_time = TimeToPPTime(file_info.last_accessed);
- info->last_modified_time = TimeToPPTime(file_info.last_modified);
- info->system_type = PP_FILESYSTEMTYPE_EXTERNAL;
- if (file_info.is_directory)
- info->type = PP_FILETYPE_DIRECTORY;
- else
- info->type = PP_FILETYPE_REGULAR;
- }
-
- return error;
-}
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/flash_file_resource.h b/ppapi/proxy/flash_file_resource.h
deleted file mode 100644
index f8c4b18..0000000
--- a/ppapi/proxy/flash_file_resource.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 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 PPAPI_PROXY_FLASH_FILE_RESOURCE_H_
-#define PPAPI_PROXY_FLASH_FILE_RESOURCE_H_
-
-#include <string>
-
-#include "ppapi/proxy/connection.h"
-#include "ppapi/proxy/plugin_resource.h"
-#include "ppapi/shared_impl/file_path.h"
-#include "ppapi/thunk/ppb_flash_file_api.h"
-
-namespace ppapi {
-namespace proxy {
-
-class FlashFileResource
- : public PluginResource,
- public thunk::PPB_Flash_File_API {
- public:
- FlashFileResource(Connection connection, PP_Instance instance);
- virtual ~FlashFileResource();
-
- // Resource overrides.
- virtual thunk::PPB_Flash_File_API* AsPPB_Flash_File_API() OVERRIDE;
-
- // PPB_Flash_Functions_API.
- virtual int32_t OpenFile(PP_Instance instance,
- const char* path,
- int32_t mode,
- PP_FileHandle* file) OVERRIDE;
- virtual int32_t RenameFile(PP_Instance instance,
- const char* path_from,
- const char* path_to) OVERRIDE;
- virtual int32_t DeleteFileOrDir(PP_Instance instance,
- const char* path,
- PP_Bool recursive) OVERRIDE;
- virtual int32_t CreateDir(PP_Instance instance, const char* path) OVERRIDE;
- virtual int32_t QueryFile(PP_Instance instance,
- const char* path,
- PP_FileInfo* info) OVERRIDE;
- virtual int32_t GetDirContents(PP_Instance instance,
- const char* path,
- PP_DirContents_Dev** contents) OVERRIDE;
- virtual void FreeDirContents(PP_Instance instance,
- PP_DirContents_Dev* contents) OVERRIDE;
- virtual int32_t CreateTemporaryFile(PP_Instance instance,
- PP_FileHandle* file) OVERRIDE;
- virtual int32_t OpenFileRef(PP_Instance instance,
- PP_Resource file_ref,
- int32_t mode,
- PP_FileHandle* file) OVERRIDE;
- virtual int32_t QueryFileRef(PP_Instance instance,
- PP_Resource file_ref,
- PP_FileInfo* info) OVERRIDE;
-
- private:
- int32_t OpenFileHelper(const std::string& path,
- PepperFilePath::Domain domain_type,
- int32_t mode,
- PP_FileHandle* file);
- int32_t QueryFileHelper(const std::string& path,
- PepperFilePath::Domain domain_type,
- PP_FileInfo* info);
-
- DISALLOW_COPY_AND_ASSIGN(FlashFileResource);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_FLASH_FILE_RESOURCE_H_
diff --git a/ppapi/proxy/pepper_file_messages.cc b/ppapi/proxy/pepper_file_messages.cc
new file mode 100644
index 0000000..53b4fcb
--- /dev/null
+++ b/ppapi/proxy/pepper_file_messages.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 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.
+
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "ppapi/proxy/pepper_file_messages.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "ppapi/proxy/pepper_file_messages.h"
+
+// Generate destructors.
+#include "ipc/struct_destructor_macros.h"
+#include "ppapi/proxy/pepper_file_messages.h"
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+namespace IPC {
+#include "ppapi/proxy/pepper_file_messages.h"
+} // namespace IPC
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+namespace IPC {
+#include "ppapi/proxy/pepper_file_messages.h"
+} // namespace IPC
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+namespace IPC {
+#include "ppapi/proxy/pepper_file_messages.h"
+} // namespace IPC
+
+namespace IPC {
+
+void ParamTraits<ppapi::PepperFilePath>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, static_cast<unsigned>(p.domain()));
+ WriteParam(m, p.path());
+}
+
+bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m,
+ PickleIterator* iter,
+ param_type* p) {
+ unsigned domain;
+ FilePath path;
+ if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path))
+ return false;
+ if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID)
+ return false;
+
+ *p = ppapi::PepperFilePath(
+ static_cast<ppapi::PepperFilePath::Domain>(domain), path);
+ return true;
+}
+
+void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p,
+ std::string* l) {
+ l->append("(");
+ LogParam(static_cast<unsigned>(p.domain()), l);
+ l->append(", ");
+ LogParam(p.path(), l);
+ l->append(")");
+}
+
+} // namespace IPC
diff --git a/ppapi/proxy/pepper_file_messages.h b/ppapi/proxy/pepper_file_messages.h
new file mode 100644
index 0000000..3edd490
--- /dev/null
+++ b/ppapi/proxy/pepper_file_messages.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 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.
+
+// Multiply-included message file, no traditional include guard.
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+#include "ipc/ipc_platform_file.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/shared_impl/dir_contents.h"
+#include "ppapi/shared_impl/file_path.h"
+
+// Singly-included section since need custom serialization.
+#ifndef PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_
+#define PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_
+
+namespace IPC {
+
+template <>
+struct ParamTraits<ppapi::PepperFilePath> {
+ typedef ppapi::PepperFilePath param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+} // namespace IPC
+
+#endif // PPAPI_SHARED_IMPL_PEPPER_FILE_MESSAGES_H_
+
+#undef IPC_MESSAGE_EXPORT
+#define IPC_MESSAGE_EXPORT PPAPI_PROXY_EXPORT
+
+#define IPC_MESSAGE_START PepperFileMsgStart
+
+IPC_STRUCT_TRAITS_BEGIN(ppapi::DirEntry)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(is_dir)
+IPC_STRUCT_TRAITS_END()
+
+// Trusted Pepper Filesystem messages from the renderer to the browser.
+
+// Open the file.
+IPC_SYNC_MESSAGE_CONTROL2_2(PepperFileMsg_OpenFile,
+ ppapi::PepperFilePath /* path */,
+ int /* flags */,
+ base::PlatformFileError /* error_code */,
+ IPC::PlatformFileForTransit /* result */)
+
+// Rename the file.
+IPC_SYNC_MESSAGE_CONTROL2_1(PepperFileMsg_RenameFile,
+ ppapi::PepperFilePath /* from_path */,
+ ppapi::PepperFilePath /* to_path */,
+ base::PlatformFileError /* error_code */)
+
+// Delete the file.
+IPC_SYNC_MESSAGE_CONTROL2_1(PepperFileMsg_DeleteFileOrDir,
+ ppapi::PepperFilePath /* path */,
+ bool /* recursive */,
+ base::PlatformFileError /* error_code */)
+
+// Create the directory.
+IPC_SYNC_MESSAGE_CONTROL1_1(PepperFileMsg_CreateDir,
+ ppapi::PepperFilePath /* path */,
+ base::PlatformFileError /* error_code */)
+
+// Query the file's info.
+IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_QueryFile,
+ ppapi::PepperFilePath /* path */,
+ base::PlatformFileInfo, /* info */
+ base::PlatformFileError /* error_code */)
+
+// Get the directory's contents.
+IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_GetDirContents,
+ ppapi::PepperFilePath /* path */,
+ ppapi::DirContents, /* contents */
+ base::PlatformFileError /* error_code */)
+
+// Create a temporary file.
+IPC_SYNC_MESSAGE_CONTROL0_2(PepperFileMsg_CreateTemporaryFile,
+ base::PlatformFileError /* error_code */,
+ IPC::PlatformFileForTransit /* file */)
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc
index b864d99..939327b 100644
--- a/ppapi/proxy/plugin_dispatcher.cc
+++ b/ppapi/proxy/plugin_dispatcher.cc
@@ -16,7 +16,6 @@
#include "ppapi/c/ppp_instance.h"
#include "ppapi/proxy/flash_resource.h"
#include "ppapi/proxy/flash_clipboard_resource.h"
-#include "ppapi/proxy/flash_file_resource.h"
#include "ppapi/proxy/gamepad_resource.h"
#include "ppapi/proxy/interface_list.h"
#include "ppapi/proxy/interface_proxy.h"
diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h
index 8d12e39d..98f43a6 100644
--- a/ppapi/proxy/plugin_dispatcher.h
+++ b/ppapi/proxy/plugin_dispatcher.h
@@ -35,6 +35,9 @@ class ResourceCreationAPI;
namespace proxy {
+class FlashClipboardResource;
+class FlashResource;
+class GamepadResource;
class ResourceMessageReplyParams;
// Used to keep track of per-instance data.
diff --git a/ppapi/proxy/plugin_resource.cc b/ppapi/proxy/plugin_resource.cc
index 3dd47ba..fca0630 100644
--- a/ppapi/proxy/plugin_resource.cc
+++ b/ppapi/proxy/plugin_resource.cc
@@ -108,17 +108,16 @@ bool PluginResource::SendResourceCall(
new PpapiHostMsg_ResourceCall(call_params, nested_msg));
}
-int32_t PluginResource::GenericSyncCall(
- Destination dest,
- const IPC::Message& msg,
- IPC::Message* reply,
- ResourceMessageReplyParams* reply_params) {
+int32_t PluginResource::GenericSyncCall(Destination dest,
+ const IPC::Message& msg,
+ IPC::Message* reply) {
ResourceMessageCallParams params(pp_resource(), GetNextSequence());
params.set_has_callback();
+ ResourceMessageReplyParams reply_params;
bool success = GetSender(dest)->Send(new PpapiHostMsg_ResourceSyncCall(
- params, msg, reply_params, reply));
+ params, msg, &reply_params, reply));
if (success)
- return reply_params->result();
+ return reply_params.result();
return PP_ERROR_FAILED;
}
diff --git a/ppapi/proxy/plugin_resource.h b/ppapi/proxy/plugin_resource.h
index 2e2e10f..2363c8c 100644
--- a/ppapi/proxy/plugin_resource.h
+++ b/ppapi/proxy/plugin_resource.h
@@ -126,11 +126,6 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource {
int32_t SyncCall(
Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e);
- int32_t GenericSyncCall(Destination dest,
- const IPC::Message& msg,
- IPC::Message* reply_msg,
- ResourceMessageReplyParams* reply_params);
-
private:
IPC::Sender* GetSender(Destination dest) {
return dest == RENDERER ? connection_.renderer_sender :
@@ -143,6 +138,10 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource {
const ResourceMessageCallParams& call_params,
const IPC::Message& nested_msg);
+ int32_t GenericSyncCall(Destination dest,
+ const IPC::Message& msg,
+ IPC::Message* reply_msg);
+
int32_t GetNextSequence();
Connection connection_;
@@ -178,16 +177,14 @@ int32_t PluginResource::Call(Destination dest,
template <class ReplyMsgClass>
int32_t PluginResource::SyncCall(Destination dest, const IPC::Message& msg) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- return GenericSyncCall(dest, msg, &reply, &reply_params);
+ return GenericSyncCall(dest, msg, &reply);
}
template <class ReplyMsgClass, class A>
int32_t PluginResource::SyncCall(
Destination dest, const IPC::Message& msg, A* a) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params);
+ int32_t result = GenericSyncCall(dest, msg, &reply);
if (UnpackMessage<ReplyMsgClass>(reply, a))
return result;
@@ -198,8 +195,7 @@ template <class ReplyMsgClass, class A, class B>
int32_t PluginResource::SyncCall(
Destination dest, const IPC::Message& msg, A* a, B* b) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params);
+ int32_t result = GenericSyncCall(dest, msg, &reply);
if (UnpackMessage<ReplyMsgClass>(reply, a, b))
return result;
@@ -210,8 +206,7 @@ template <class ReplyMsgClass, class A, class B, class C>
int32_t PluginResource::SyncCall(
Destination dest, const IPC::Message& msg, A* a, B* b, C* c) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params);
+ int32_t result = GenericSyncCall(dest, msg, &reply);
if (UnpackMessage<ReplyMsgClass>(reply, a, b, c))
return result;
@@ -222,8 +217,7 @@ template <class ReplyMsgClass, class A, class B, class C, class D>
int32_t PluginResource::SyncCall(
Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params);
+ int32_t result = GenericSyncCall(dest, msg, &reply);
if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d))
return result;
@@ -234,8 +228,7 @@ template <class ReplyMsgClass, class A, class B, class C, class D, class E>
int32_t PluginResource::SyncCall(
Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) {
IPC::Message reply;
- ResourceMessageReplyParams reply_params;
- int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params);
+ int32_t result = GenericSyncCall(dest, msg, &reply);
if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d, e))
return result;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index b5e04de..959b93c 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -47,8 +47,6 @@
#include "ppapi/proxy/serialized_flash_menu.h"
#include "ppapi/proxy/serialized_structs.h"
#include "ppapi/proxy/serialized_var.h"
-#include "ppapi/shared_impl/dir_contents.h"
-#include "ppapi/shared_impl/file_path.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
#include "ppapi/shared_impl/ppb_device_ref_shared.h"
#include "ppapi/shared_impl/ppb_input_event_shared.h"
@@ -164,11 +162,6 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::DeviceRefData)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(ppapi::DirEntry)
- IPC_STRUCT_TRAITS_MEMBER(name)
- IPC_STRUCT_TRAITS_MEMBER(is_dir)
-IPC_STRUCT_TRAITS_END()
-
IPC_STRUCT_TRAITS_BEGIN(ppapi::FlashSiteSetting)
IPC_STRUCT_TRAITS_MEMBER(site)
IPC_STRUCT_TRAITS_MEMBER(permission)
@@ -1281,6 +1274,17 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_IsRectTopmost,
PP_Instance /* instance */,
PP_Rect /* rect */,
PP_Bool /* result */)
+IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBFlash_OpenFileRef,
+ PP_Instance /* instance */,
+ ppapi::HostResource /* file_ref */,
+ int32_t /* mode */,
+ IPC::PlatformFileForTransit /* file_handle */,
+ int32_t /* result */)
+IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlash_QueryFileRef,
+ PP_Instance /* instance */,
+ ppapi::HostResource /* file_ref */,
+ PP_FileInfo /* info */,
+ int32_t /* result */)
IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetSetting,
PP_Instance /* instance */,
PP_FlashSetting /* setting */,
@@ -1635,29 +1639,6 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_FlashClipboard_WriteData,
std::vector<uint32_t> /* formats */,
std::vector<std::string> /* data */)
-// Flash file.
-IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashFile_Create)
-IPC_MESSAGE_CONTROL2(PpapiHostMsg_FlashFile_OpenFile,
- ppapi::PepperFilePath /* path */,
- int /* flags */)
-IPC_MESSAGE_CONTROL2(PpapiHostMsg_FlashFile_RenameFile,
- ppapi::PepperFilePath /* from_path */,
- ppapi::PepperFilePath /* to_path */)
-IPC_MESSAGE_CONTROL2(PpapiHostMsg_FlashFile_DeleteFileOrDir,
- ppapi::PepperFilePath /* path */,
- bool /* recursive */)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_FlashFile_CreateDir,
- ppapi::PepperFilePath /* path */)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_FlashFile_QueryFile,
- ppapi::PepperFilePath /* path */)
-IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashFile_QueryFileReply,
- base::PlatformFileInfo /* file_info */)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_FlashFile_GetDirContents,
- ppapi::PepperFilePath /* path */)
-IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashFile_GetDirContentsReply,
- ppapi::DirContents /* entries */)
-IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashFile_CreateTemporaryFile)
-
// Flash font file.
IPC_MESSAGE_CONTROL2(PpapiHostMsg_FlashFontFile_Create,
ppapi::proxy::SerializedFontDescription /* description */,
diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc
index ea792e6..763d05c 100644
--- a/ppapi/proxy/ppapi_param_traits.cc
+++ b/ppapi/proxy/ppapi_param_traits.cc
@@ -346,7 +346,6 @@ void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m,
break;
case ppapi::proxy::SerializedHandle::SOCKET:
case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE:
- case ppapi::proxy::SerializedHandle::FILE:
ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor());
break;
case ppapi::proxy::SerializedHandle::INVALID:
@@ -387,14 +386,6 @@ bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m,
}
break;
}
- case ppapi::proxy::SerializedHandle::FILE: {
- IPC::PlatformFileForTransit desc;
- if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &desc)) {
- r->set_file_handle(desc);
- return true;
- }
- break;
- }
case ppapi::proxy::SerializedHandle::INVALID:
return true;
// No default so the compiler will warn us if a new type is added.
@@ -561,41 +552,6 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log(
std::string* l) {
}
-// ppapi::PepperFilePath -------------------------------------------------------
-
-// static
-void ParamTraits<ppapi::PepperFilePath>::Write(Message* m,
- const param_type& p) {
- WriteParam(m, static_cast<unsigned>(p.domain()));
- WriteParam(m, p.path());
-}
-
-// static
-bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m,
- PickleIterator* iter,
- param_type* p) {
- unsigned domain;
- FilePath path;
- if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path))
- return false;
- if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID)
- return false;
-
- *p = ppapi::PepperFilePath(
- static_cast<ppapi::PepperFilePath::Domain>(domain), path);
- return true;
-}
-
-// static
-void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p,
- std::string* l) {
- l->append("(");
- LogParam(static_cast<unsigned>(p.domain()), l);
- l->append(", ");
- LogParam(p.path(), l);
- l->append(")");
-}
-
// SerializedFlashMenu ---------------------------------------------------------
// static
diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h
index 7556e35..13f7351 100644
--- a/ppapi/proxy/ppapi_param_traits.h
+++ b/ppapi/proxy/ppapi_param_traits.h
@@ -14,7 +14,6 @@
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
-#include "ppapi/shared_impl/file_path.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ppapi/shared_impl/ppb_file_ref_shared.h"
@@ -167,14 +166,6 @@ struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> {
};
#if !defined(OS_NACL) && !defined(NACL_WIN64)
-template <>
-struct ParamTraits<ppapi::PepperFilePath> {
- typedef ppapi::PepperFilePath param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, PickleIterator* iter, param_type* p);
- static void Log(const param_type& p, std::string* l);
-};
-
template<>
struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFlashMenu> {
typedef ppapi::proxy::SerializedFlashMenu param_type;
diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc
index 919dd3a..4a9cd8f 100644
--- a/ppapi/proxy/ppb_flash_proxy.cc
+++ b/ppapi/proxy/ppb_flash_proxy.cc
@@ -19,11 +19,14 @@
#include "ppapi/c/private/ppb_flash.h"
#include "ppapi/c/private/ppb_flash_print.h"
#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/pepper_file_messages.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/proxy_module.h"
#include "ppapi/proxy/serialized_var.h"
+#include "ppapi/shared_impl/dir_contents.h"
+#include "ppapi/shared_impl/file_type_conversion.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
@@ -50,6 +53,19 @@ bool InSameMinute(PP_Time t1, PP_Time t2) {
return floor(t1 / 60.0) == floor(t2 / 60.0);
}
+IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit(
+ Dispatcher* dispatcher,
+ int32_t* error,
+ base::PlatformFile file) {
+ if (*error != PP_OK)
+ return IPC::InvalidPlatformFileForTransit();
+ IPC::PlatformFileForTransit out_handle =
+ dispatcher->ShareHandleWithRemote(file, true);
+ if (out_handle == IPC::InvalidPlatformFileForTransit())
+ *error = PP_ERROR_NOACCESS;
+ return out_handle;
+}
+
void InvokePrinting(PP_Instance instance) {
ProxyAutoLock lock;
@@ -95,6 +111,10 @@ bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgGetLocalTimeZoneOffset)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost,
OnHostMsgIsRectTopmost)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef,
+ OnHostMsgOpenFileRef)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef,
+ OnHostMsgQueryFileRef)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting,
OnHostMsgInvokePrinting)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting,
@@ -260,6 +280,187 @@ PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance,
return PP_MakeUndefined();
}
+bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) {
+ return true;
+}
+
+void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) {
+}
+
+int32_t PPB_Flash_Proxy::OpenFile(PP_Instance,
+ const char* path,
+ int32_t mode,
+ PP_FileHandle* file) {
+ int flags = 0;
+ if (!path ||
+ !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) ||
+ !file)
+ return PP_ERROR_BADARGUMENT;
+
+ base::PlatformFileError error;
+ IPC::PlatformFileForTransit transit_file;
+ ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(path));
+
+ if (PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_OpenFile(pepper_path, flags,
+ &error, &transit_file))) {
+ *file = IPC::PlatformFileForTransitToPlatformFile(transit_file);
+ } else {
+ *file = base::kInvalidPlatformFileValue;
+ error = base::PLATFORM_FILE_ERROR_FAILED;
+ }
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::RenameFile(PP_Instance,
+ const char* from_path,
+ const char* to_path) {
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ ppapi::PepperFilePath pepper_from(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(from_path));
+ ppapi::PepperFilePath pepper_to(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(to_path));
+
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_RenameFile(pepper_from, pepper_to, &error));
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::DeleteFileOrDir(PP_Instance,
+ const char* path,
+ PP_Bool recursive) {
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(path));
+
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_DeleteFileOrDir(pepper_path,
+ PP_ToBool(recursive),
+ &error));
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::CreateDir(PP_Instance, const char* path) {
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(path));
+
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_CreateDir(pepper_path, &error));
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::QueryFile(PP_Instance,
+ const char* path,
+ PP_FileInfo* info) {
+ base::PlatformFileInfo file_info;
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(path));
+
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_QueryFile(pepper_path, &file_info, &error));
+
+ if (error == base::PLATFORM_FILE_OK) {
+ info->size = file_info.size;
+ info->creation_time = TimeToPPTime(file_info.creation_time);
+ info->last_access_time = TimeToPPTime(file_info.last_accessed);
+ info->last_modified_time = TimeToPPTime(file_info.last_modified);
+ info->system_type = PP_FILESYSTEMTYPE_EXTERNAL;
+ if (file_info.is_directory)
+ info->type = PP_FILETYPE_DIRECTORY;
+ else
+ info->type = PP_FILETYPE_REGULAR;
+ }
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::GetDirContents(PP_Instance,
+ const char* path,
+ PP_DirContents_Dev** contents) {
+ ppapi::DirContents entries;
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ ppapi::PepperFilePath pepper_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ FilePath::FromUTF8Unsafe(path));
+
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_GetDirContents(pepper_path, &entries, &error));
+
+ if (error == base::PLATFORM_FILE_OK) {
+ // Copy the serialized dir entries to the output struct.
+ *contents = new PP_DirContents_Dev;
+ (*contents)->count = static_cast<int32_t>(entries.size());
+ (*contents)->entries = new PP_DirEntry_Dev[entries.size()];
+ for (size_t i = 0; i < entries.size(); i++) {
+ const ppapi::DirEntry& source = entries[i];
+ PP_DirEntry_Dev* dest = &(*contents)->entries[i];
+ std::string name = source.name.AsUTF8Unsafe();
+ char* name_copy = new char[name.size() + 1];
+ memcpy(name_copy, name.c_str(), name.size() + 1);
+ dest->name = name_copy;
+ dest->is_dir = PP_FromBool(source.is_dir);
+ }
+ }
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::CreateTemporaryFile(PP_Instance instance,
+ PP_FileHandle* file) {
+ if (!file)
+ return PP_ERROR_BADARGUMENT;
+
+ base::PlatformFileError error;
+ IPC::PlatformFileForTransit transit_file;
+
+ if (PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PepperFileMsg_CreateTemporaryFile(&error, &transit_file))) {
+ *file = IPC::PlatformFileForTransitToPlatformFile(transit_file);
+ } else {
+ error = base::PLATFORM_FILE_ERROR_FAILED;
+ *file = base::kInvalidPlatformFileValue;
+ }
+
+ return ppapi::PlatformFileErrorToPepperError(error);
+}
+
+int32_t PPB_Flash_Proxy::OpenFileRef(PP_Instance instance,
+ PP_Resource file_ref_id,
+ int32_t mode,
+ PP_FileHandle* file) {
+ EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref_id, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+
+ int32_t result = PP_ERROR_FAILED;
+ IPC::PlatformFileForTransit transit;
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_OpenFileRef(
+ API_ID_PPB_FLASH, instance, enter.resource()->host_resource(), mode,
+ &transit, &result));
+ *file = IPC::PlatformFileForTransitToPlatformFile(transit);
+ return result;
+}
+
+int32_t PPB_Flash_Proxy::QueryFileRef(PP_Instance instance,
+ PP_Resource file_ref_id,
+ PP_FileInfo* info) {
+ EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref_id, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+
+ int32_t result = PP_ERROR_FAILED;
+ dispatcher()->Send(new PpapiHostMsg_PPBFlash_QueryFileRef(
+ API_ID_PPB_FLASH, instance, enter.resource()->host_resource(), info,
+ &result));
+ return result;
+}
+
void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance,
PP_Bool on_top) {
EnterInstanceNoLock enter(instance);
@@ -350,6 +551,39 @@ void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance,
*result = PP_FALSE;
}
+void PPB_Flash_Proxy::OnHostMsgOpenFileRef(
+ PP_Instance instance,
+ const HostResource& host_resource,
+ int32_t mode,
+ IPC::PlatformFileForTransit* file_handle,
+ int32_t* result) {
+ EnterInstanceNoLock enter(instance);
+ if (enter.failed()) {
+ *result = PP_ERROR_BADARGUMENT;
+ return;
+ }
+
+ base::PlatformFile file;
+ *result = enter.functions()->GetFlashAPI()->OpenFileRef(
+ instance, host_resource.host_resource(), mode, &file);
+ *file_handle = PlatformFileToPlatformFileForTransit(dispatcher(),
+ result, file);
+}
+
+void PPB_Flash_Proxy::OnHostMsgQueryFileRef(
+ PP_Instance instance,
+ const HostResource& host_resource,
+ PP_FileInfo* info,
+ int32_t* result) {
+ EnterInstanceNoLock enter(instance);
+ if (enter.failed()) {
+ *result = PP_ERROR_BADARGUMENT;
+ return;
+ }
+ *result = enter.functions()->GetFlashAPI()->QueryFileRef(
+ instance, host_resource.host_resource(), info);
+}
+
void PPB_Flash_Proxy::OnHostMsgGetSetting(PP_Instance instance,
PP_FlashSetting setting,
SerializedVarReturnValue id) {
diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h
index 37f9175..6043d2c 100644
--- a/ppapi/proxy/ppb_flash_proxy.h
+++ b/ppapi/proxy/ppb_flash_proxy.h
@@ -6,8 +6,10 @@
#define PPAPI_PROXY_PPB_FLASH_PROXY_H_
#include <string>
+#include <vector>
#include "base/compiler_specific.h"
+#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
@@ -16,7 +18,7 @@
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/host_resource.h"
-#include "ppapi/thunk/ppb_flash_api.h"
+#include "ppapi/shared_impl/ppb_flash_shared.h"
struct PPB_Flash_Print_1_0;
@@ -35,7 +37,7 @@ class SerializedVarReturnValue;
// implemented in the new-style resource proxy (see flash_resource.h).
// TODO(raymes): All of these functions should be moved to the new-style proxy.
////////////////////////////////////////////////////////////////////////////////
-class PPB_Flash_Proxy : public InterfaceProxy, public thunk::PPB_Flash_API {
+class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared {
public:
explicit PPB_Flash_Proxy(Dispatcher* dispatcher);
virtual ~PPB_Flash_Proxy();
@@ -76,6 +78,34 @@ class PPB_Flash_Proxy : public InterfaceProxy, public thunk::PPB_Flash_API {
const PP_Rect* rect) OVERRIDE;
virtual PP_Var GetSetting(PP_Instance instance,
PP_FlashSetting setting) OVERRIDE;
+ virtual bool CreateThreadAdapterForInstance(PP_Instance instance) OVERRIDE;
+ virtual void ClearThreadAdapterForInstance(PP_Instance instance) OVERRIDE;
+ virtual int32_t OpenFile(PP_Instance instance,
+ const char* path,
+ int32_t mode,
+ PP_FileHandle* file) OVERRIDE;
+ virtual int32_t RenameFile(PP_Instance instance,
+ const char* path_from,
+ const char* path_to) OVERRIDE;
+ virtual int32_t DeleteFileOrDir(PP_Instance instance,
+ const char* path,
+ PP_Bool recursive) OVERRIDE;
+ virtual int32_t CreateDir(PP_Instance instance, const char* path) OVERRIDE;
+ virtual int32_t QueryFile(PP_Instance instance,
+ const char* path,
+ PP_FileInfo* info) OVERRIDE;
+ virtual int32_t GetDirContents(PP_Instance instance,
+ const char* path,
+ PP_DirContents_Dev** contents) OVERRIDE;
+ virtual int32_t CreateTemporaryFile(PP_Instance instance,
+ PP_FileHandle* file) OVERRIDE;
+ virtual int32_t OpenFileRef(PP_Instance instance,
+ PP_Resource file_ref,
+ int32_t mode,
+ PP_FileHandle* file) OVERRIDE;
+ virtual int32_t QueryFileRef(PP_Instance instance,
+ PP_Resource file_ref,
+ PP_FileInfo* info) OVERRIDE;
static const ApiID kApiID = API_ID_PPB_FLASH;
@@ -96,6 +126,15 @@ class PPB_Flash_Proxy : public InterfaceProxy, public thunk::PPB_Flash_API {
void OnHostMsgIsRectTopmost(PP_Instance instance,
PP_Rect rect,
PP_Bool* result);
+ void OnHostMsgOpenFileRef(PP_Instance instance,
+ const ppapi::HostResource& host_resource,
+ int32_t mode,
+ IPC::PlatformFileForTransit* file_handle,
+ int32_t* result);
+ void OnHostMsgQueryFileRef(PP_Instance instance,
+ const ppapi::HostResource& host_resource,
+ PP_FileInfo* info,
+ int32_t* result);
void OnHostMsgGetSetting(PP_Instance instance,
PP_FlashSetting setting,
SerializedVarReturnValue result);
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index d81fb8e..4e32822 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -17,7 +17,6 @@
#include "ppapi/proxy/content_decryptor_private_serializer.h"
#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/flash_clipboard_resource.h"
-#include "ppapi/proxy/flash_file_resource.h"
#include "ppapi/proxy/flash_fullscreen_resource.h"
#include "ppapi/proxy/flash_resource.h"
#include "ppapi/proxy/gamepad_resource.h"
@@ -383,9 +382,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
case FLASH_CLIPBOARD_SINGLETON_ID:
new_singleton = new FlashClipboardResource(connection, instance);
break;
- case FLASH_FILE_SINGLETON_ID:
- new_singleton = new FlashFileResource(connection, instance);
- break;
case FLASH_FULLSCREEN_SINGLETON_ID:
new_singleton = new FlashFullscreenResource(connection, instance);
break;
@@ -394,7 +390,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
break;
#else
case FLASH_CLIPBOARD_SINGLETON_ID:
- case FLASH_FILE_SINGLETON_ID:
case FLASH_FULLSCREEN_SINGLETON_ID:
case FLASH_SINGLETON_ID:
NOTREACHED();
diff --git a/ppapi/proxy/resource_message_params.cc b/ppapi/proxy/resource_message_params.cc
index 49b6328..aaca8c9 100644
--- a/ppapi/proxy/resource_message_params.cc
+++ b/ppapi/proxy/resource_message_params.cc
@@ -91,17 +91,6 @@ bool ResourceMessageParams::TakeSocketHandleAtIndex(
return true;
}
-bool ResourceMessageParams::TakeFileHandleAtIndex(
- size_t index,
- IPC::PlatformFileForTransit* handle) const {
- SerializedHandle serialized = TakeHandleOfTypeAtIndex(
- index, SerializedHandle::FILE);
- if (!serialized.is_file())
- return false;
- *handle = serialized.descriptor();
- return true;
-}
-
void ResourceMessageParams::TakeAllSharedMemoryHandles(
std::vector<base::SharedMemoryHandle>* handles) const {
for (size_t i = 0; i < handles_->data().size(); ++i) {
diff --git a/ppapi/proxy/resource_message_params.h b/ppapi/proxy/resource_message_params.h
index 663d35e..d8e4e9d 100644
--- a/ppapi/proxy/resource_message_params.h
+++ b/ppapi/proxy/resource_message_params.h
@@ -38,8 +38,8 @@ class PPAPI_PROXY_EXPORT ResourceMessageParams {
SerializedHandle TakeHandleOfTypeAtIndex(size_t index,
SerializedHandle::Type type) const;
- // Helper functions to return shared memory, socket or file handles passed in
- // the params struct.
+ // Helper functions to return shared memory or socket handles passed in the
+ // params struct.
// If the index has a valid handle of the given type, it will be placed in the
// output parameter, the corresponding slot in the list will be set to an
// invalid handle, and the function will return true. If the handle doesn't
@@ -54,8 +54,6 @@ class PPAPI_PROXY_EXPORT ResourceMessageParams {
base::SharedMemoryHandle* handle) const;
bool TakeSocketHandleAtIndex(size_t index,
IPC::PlatformFileForTransit* handle) const;
- bool TakeFileHandleAtIndex(size_t index,
- IPC::PlatformFileForTransit* handle) const;
void TakeAllSharedMemoryHandles(
std::vector<base::SharedMemoryHandle>* handles) const;
diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc
index 2ddf325..f83ae0b 100644
--- a/ppapi/proxy/serialized_structs.cc
+++ b/ppapi/proxy/serialized_structs.cc
@@ -107,17 +107,10 @@ SerializedHandle::SerializedHandle(
}
bool SerializedHandle::IsHandleValid() const {
- switch (type_) {
- case SHARED_MEMORY:
- return base::SharedMemory::IsHandleValid(shm_handle_);
- case SOCKET:
- case CHANNEL_HANDLE:
- case FILE:
- return !(IPC::InvalidPlatformFileForTransit() == descriptor_);
- case INVALID:
- return false;
- // No default so the compiler will warn us if a new type is added.
- }
+ if (type_ == SHARED_MEMORY)
+ return base::SharedMemory::IsHandleValid(shm_handle_);
+ else if (type_ == SOCKET || type_ == CHANNEL_HANDLE)
+ return !(IPC::InvalidPlatformFileForTransit() == descriptor_);
return false;
}
@@ -132,7 +125,6 @@ void SerializedHandle::Close() {
break;
case SOCKET:
case CHANNEL_HANDLE:
- case FILE:
base::PlatformFile file =
IPC::PlatformFileForTransitToPlatformFile(descriptor_);
#if !defined(OS_NACL)
@@ -176,7 +168,6 @@ bool SerializedHandle::ReadHeader(PickleIterator* iter, Header* hdr) {
}
case SOCKET:
case CHANNEL_HANDLE:
- case FILE:
case INVALID:
valid_type = true;
break;
diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h
index def852f..d27b52c 100644
--- a/ppapi/proxy/serialized_structs.h
+++ b/ppapi/proxy/serialized_structs.h
@@ -85,7 +85,7 @@ struct PPBURLLoader_UpdateProgress_Params {
// them in NaClIPCAdapter for use in NaCl.
class PPAPI_PROXY_EXPORT SerializedHandle {
public:
- enum Type { INVALID, SHARED_MEMORY, SOCKET, CHANNEL_HANDLE, FILE };
+ enum Type { INVALID, SHARED_MEMORY, SOCKET, CHANNEL_HANDLE };
struct Header {
Header() : type(INVALID), size(0) {}
Header(Type type_arg, uint32_t size_arg)
@@ -102,7 +102,7 @@ class PPAPI_PROXY_EXPORT SerializedHandle {
// Create a shared memory handle.
SerializedHandle(const base::SharedMemoryHandle& handle, uint32_t size);
- // Create a socket, channel or file handle.
+ // Create a socket or channel handle.
SerializedHandle(const Type type,
const IPC::PlatformFileForTransit& descriptor);
@@ -110,7 +110,6 @@ class PPAPI_PROXY_EXPORT SerializedHandle {
bool is_shmem() const { return type_ == SHARED_MEMORY; }
bool is_socket() const { return type_ == SOCKET; }
bool is_channel_handle() const { return type_ == CHANNEL_HANDLE; }
- bool is_file() const { return type_ == FILE; }
const base::SharedMemoryHandle& shmem() const {
DCHECK(is_shmem());
return shm_handle_;
@@ -120,7 +119,7 @@ class PPAPI_PROXY_EXPORT SerializedHandle {
return size_;
}
const IPC::PlatformFileForTransit& descriptor() const {
- DCHECK(is_socket() || is_channel_handle() || is_file());
+ DCHECK(is_socket() || is_channel_handle());
return descriptor_;
}
void set_shmem(const base::SharedMemoryHandle& handle, uint32_t size) {
@@ -144,13 +143,6 @@ class PPAPI_PROXY_EXPORT SerializedHandle {
shm_handle_ = base::SharedMemory::NULLHandle();
size_ = 0;
}
- void set_file_handle(const IPC::PlatformFileForTransit& descriptor) {
- type_ = FILE;
-
- descriptor_ = descriptor;
- shm_handle_ = base::SharedMemory::NULLHandle();
- size_ = 0;
- }
void set_null_shmem() {
set_shmem(base::SharedMemory::NULLHandle(), 0);
}
@@ -160,9 +152,6 @@ class PPAPI_PROXY_EXPORT SerializedHandle {
void set_null_channel_handle() {
set_channel_handle(IPC::InvalidPlatformFileForTransit());
}
- void set_null_file_handle() {
- set_file_handle(IPC::InvalidPlatformFileForTransit());
- }
bool IsHandleValid() const;
Header header() const {
diff --git a/ppapi/shared_impl/file_path.cc b/ppapi/shared_impl/file_path.cc
index 1502d89..1208b08 100644
--- a/ppapi/shared_impl/file_path.cc
+++ b/ppapi/shared_impl/file_path.cc
@@ -4,8 +4,26 @@
#include "ppapi/shared_impl/file_path.h"
+#include <string>
+
+#if defined(OS_WIN)
+#include "base/utf_string_conversions.h"
+#endif
+
namespace ppapi {
+namespace {
+
+FilePath GetFilePathFromUTF8(const std::string& utf8_path) {
+#if defined(OS_WIN)
+ return FilePath(UTF8ToUTF16(utf8_path));
+#else
+ return FilePath(utf8_path);
+#endif
+}
+
+} // namespace
+
PepperFilePath::PepperFilePath()
: domain_(DOMAIN_INVALID),
path_() {
@@ -17,4 +35,17 @@ PepperFilePath::PepperFilePath(Domain domain, const FilePath& path)
// TODO(viettrungluu): Should we DCHECK() some things here?
}
+// static
+PepperFilePath PepperFilePath::MakeAbsolute(const FilePath& path) {
+ return PepperFilePath(DOMAIN_ABSOLUTE, path);
+}
+
+// static
+PepperFilePath PepperFilePath::MakeModuleLocal(const std::string& name,
+ const char* utf8_path) {
+ FilePath full_path = GetFilePathFromUTF8(name).Append(
+ GetFilePathFromUTF8(utf8_path));
+ return PepperFilePath(DOMAIN_MODULE_LOCAL, full_path);
+}
+
} // namespace ppapi
diff --git a/ppapi/shared_impl/file_path.h b/ppapi/shared_impl/file_path.h
index 3d850f9..bcec9f8 100644
--- a/ppapi/shared_impl/file_path.h
+++ b/ppapi/shared_impl/file_path.h
@@ -5,6 +5,8 @@
#ifndef PPAPI_SHARED_IMPL_FILE_PATH_H_
#define PPAPI_SHARED_IMPL_FILE_PATH_H_
+#include <string>
+
#include "base/file_path.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
@@ -28,6 +30,10 @@ class PPAPI_SHARED_EXPORT PepperFilePath {
PepperFilePath();
PepperFilePath(Domain d, const FilePath& p);
+ static PepperFilePath MakeAbsolute(const FilePath& path);
+ static PepperFilePath MakeModuleLocal(const std::string& name,
+ const char* utf8_path);
+
Domain domain() const { return domain_; }
const FilePath& path() const { return path_; }
diff --git a/ppapi/shared_impl/ppb_flash_shared.cc b/ppapi/shared_impl/ppb_flash_shared.cc
new file mode 100644
index 0000000..c310e0e
--- /dev/null
+++ b/ppapi/shared_impl/ppb_flash_shared.cc
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 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 "ppapi/shared_impl/ppb_flash_shared.h"
+
+namespace ppapi {
+
+PPB_Flash_Shared::PPB_Flash_Shared() {
+}
+
+PPB_Flash_Shared::~PPB_Flash_Shared() {
+}
+
+void PPB_Flash_Shared::FreeDirContents(PP_Instance instance,
+ PP_DirContents_Dev* contents) {
+ for (int32_t i = 0; i < contents->count; ++i)
+ delete[] contents->entries[i].name;
+ delete[] contents->entries;
+ delete contents;
+}
+
+} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_flash_shared.h b/ppapi/shared_impl/ppb_flash_shared.h
new file mode 100644
index 0000000..29f8973
--- /dev/null
+++ b/ppapi/shared_impl/ppb_flash_shared.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 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 PPAPI_SHARED_IMPL_PPB_FLASH_SHARED_H_
+#define PPAPI_SHARED_IMPL_PPB_FLASH_SHARED_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+#include "ppapi/thunk/ppb_flash_api.h"
+
+namespace ppapi {
+
+class PPAPI_SHARED_EXPORT PPB_Flash_Shared : public thunk::PPB_Flash_API {
+ public:
+ PPB_Flash_Shared();
+ virtual ~PPB_Flash_Shared();
+
+ // Shared implementation of PPB_Flash_API.
+ virtual void FreeDirContents(PP_Instance instance,
+ PP_DirContents_Dev* contents) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Shared);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PPB_FLASH_SHARED_H_
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 6c86868..dc1bf3f 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -36,7 +36,6 @@
F(PPB_Find_API) \
F(PPB_Flash_Clipboard_API) \
F(PPB_Flash_DeviceID_API) \
- F(PPB_Flash_File_API) \
F(PPB_Flash_FontFile_API) \
F(PPB_Flash_Fullscreen_API) \
F(PPB_Flash_Functions_API) \
diff --git a/ppapi/shared_impl/singleton_resource_id.h b/ppapi/shared_impl/singleton_resource_id.h
index 442611a..9558db6 100644
--- a/ppapi/shared_impl/singleton_resource_id.h
+++ b/ppapi/shared_impl/singleton_resource_id.h
@@ -11,7 +11,6 @@ namespace ppapi {
// PPB_Instance_API.GetSingletonResource.
enum SingletonResourceID {
FLASH_CLIPBOARD_SINGLETON_ID,
- FLASH_FILE_SINGLETON_ID,
FLASH_FULLSCREEN_SINGLETON_ID,
FLASH_SINGLETON_ID,
GAMEPAD_SINGLETON_ID,
diff --git a/ppapi/tests/test_flash_file.cc b/ppapi/tests/test_flash_file.cc
index 86100d9..ac88b34 100644
--- a/ppapi/tests/test_flash_file.cc
+++ b/ppapi/tests/test_flash_file.cc
@@ -4,11 +4,6 @@
#include "ppapi/tests/test_flash_file.h"
-#include <algorithm>
-#include <vector>
-
-#include "ppapi/c/pp_file_info.h"
-#include "ppapi/c/ppb_file_io.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/private/flash_file.h"
#include "ppapi/tests/testing_instance.h"
@@ -79,18 +74,6 @@ bool ReadFile(PP_FileHandle file_handle, std::string* contents) {
return result;
}
-bool DirEntryEqual(FileModuleLocal::DirEntry i,
- FileModuleLocal::DirEntry j) {
- return i.name == j.name && i.is_dir == j.is_dir;
-}
-
-bool DirEntryLessThan(FileModuleLocal::DirEntry i,
- FileModuleLocal::DirEntry j) {
- if (i.name == j.name)
- return i.is_dir < j.is_dir;
- return i.name < j.name;
-}
-
} // namespace
REGISTER_TEST_CASE(FlashFile);
@@ -107,204 +90,15 @@ bool TestFlashFile::Init() {
}
void TestFlashFile::RunTests(const std::string& filter) {
- RUN_TEST(OpenFile, filter);
- RUN_TEST(RenameFile, filter);
- RUN_TEST(DeleteFileOrDir, filter);
- RUN_TEST(CreateDir, filter);
- RUN_TEST(QueryFile, filter);
- RUN_TEST(GetDirContents, filter);
RUN_TEST(CreateTemporaryFile, filter);
}
-void TestFlashFile::SetUp() {
- // Clear out existing test data.
- FileModuleLocal::DeleteFileOrDir(instance_, std::string(), true);
+std::string TestFlashFile::TestCreateTemporaryFile() {
+ ASSERT_TRUE(FileModuleLocal::IsCreateTemporaryFileAvailable());
+
// Make sure that the root directory exists.
FileModuleLocal::CreateDir(instance_, std::string());
-}
-
-std::string TestFlashFile::TestOpenFile() {
- SetUp();
- std::string filename = "abc.txt";
- PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
-
- std::string contents = "This is file.";
- std::string read_contents;
- ASSERT_TRUE(WriteFile(file_handle, contents));
- ASSERT_FALSE(ReadFile(file_handle, &read_contents));
- CloseFileHandle(file_handle);
-
- file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_READ);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
-
- ASSERT_FALSE(WriteFile(file_handle, contents));
- ASSERT_TRUE(ReadFile(file_handle, &read_contents));
- ASSERT_EQ(contents, read_contents);
- CloseFileHandle(file_handle);
-
- PASS();
-}
-
-std::string TestFlashFile::TestRenameFile() {
- SetUp();
- std::string filename = "abc.txt";
- std::string new_filename = "abc_new.txt";
- std::string contents = "This is file.";
- std::string read_contents;
-
- PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(WriteFile(file_handle, contents));
- CloseFileHandle(file_handle);
-
- ASSERT_TRUE(FileModuleLocal::RenameFile(instance_, filename, new_filename));
-
- file_handle = FileModuleLocal::OpenFile(instance_,
- new_filename,
- PP_FILEOPENFLAG_READ);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(ReadFile(file_handle, &read_contents));
- ASSERT_EQ(contents, read_contents);
- CloseFileHandle(file_handle);
-
- // Check that the old file no longer exists.
- PP_FileInfo unused;
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, filename, &unused));
-
- PASS();
-}
-std::string TestFlashFile::TestDeleteFileOrDir() {
- SetUp();
- std::string filename = "abc.txt";
- std::string dirname = "def";
- std::string contents = "This is file.";
-
- // Test file deletion.
- PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(WriteFile(file_handle, contents));
- CloseFileHandle(file_handle);
- ASSERT_TRUE(FileModuleLocal::DeleteFileOrDir(instance_, filename, false));
- PP_FileInfo unused;
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, filename, &unused));
-
- // Test directory deletion.
- ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
- ASSERT_TRUE(FileModuleLocal::DeleteFileOrDir(instance_, dirname, false));
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, dirname, &unused));
-
- // Test recursive directory deletion.
- ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
- file_handle = FileModuleLocal::OpenFile(
- instance_, dirname + "/" + filename,
- PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(WriteFile(file_handle, contents));
- CloseFileHandle(file_handle);
- ASSERT_FALSE(FileModuleLocal::DeleteFileOrDir(instance_, dirname, false));
- ASSERT_TRUE(FileModuleLocal::DeleteFileOrDir(instance_, dirname, true));
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, filename, &unused));
-
- PASS();
-}
-
-std::string TestFlashFile::TestCreateDir() {
- SetUp();
- std::string dirname = "abc";
- PP_FileInfo info;
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, dirname, &info));
- ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
- ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, dirname, &info));
- ASSERT_EQ(info.type, PP_FILETYPE_DIRECTORY);
-
- PASS();
-}
-
-std::string TestFlashFile::TestQueryFile() {
- std::string filename = "abc.txt";
- std::string dirname = "def";
- std::string contents = "This is file.";
- PP_FileInfo info;
-
- // Test querying a file.
- PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(WriteFile(file_handle, contents));
- CloseFileHandle(file_handle);
- ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, filename, &info));
- ASSERT_EQ(static_cast<size_t>(info.size), contents.size());
- ASSERT_EQ(info.type, PP_FILETYPE_REGULAR);
- // TODO(raymes): Test the other fields.
-
- // Test querying a directory.
- ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
- ASSERT_TRUE(FileModuleLocal::QueryFile(instance_, dirname, &info));
- ASSERT_EQ(info.type, PP_FILETYPE_DIRECTORY);
- // TODO(raymes): Test the other fields.
-
- // Test querying a non-existent file.
- ASSERT_FALSE(FileModuleLocal::QueryFile(instance_, "xx", &info));
-
- PASS();
-}
-
-std::string TestFlashFile::TestGetDirContents() {
- SetUp();
- std::vector<FileModuleLocal::DirEntry> result;
- ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, std::string(),
- &result));
- ASSERT_EQ(result.size(), 1);
- ASSERT_EQ(result[0].name, "..");
- ASSERT_EQ(result[0].is_dir, true);
-
- std::string filename = "abc.txt";
- std::string dirname = "def";
- std::string contents = "This is file.";
- PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_,
- filename,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE);
- ASSERT_NE(PP_kInvalidFileHandle, file_handle);
- ASSERT_TRUE(WriteFile(file_handle, contents));
- CloseFileHandle(file_handle);
- ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname));
-
- ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &result));
- FileModuleLocal::DirEntry expected[] =
- { {"..", true},
- {filename, false},
- {dirname, true}
- };
- size_t expected_size = sizeof(expected) / sizeof(expected[0]);
-
- std::sort(expected, expected + expected_size, DirEntryLessThan);
- std::sort(result.begin(), result.end(), DirEntryLessThan);
-
- ASSERT_EQ(expected_size, result.size());
- ASSERT_TRUE(std::equal(expected, expected + expected_size, result.begin(),
- DirEntryEqual));
-
- PASS();
-}
-
-std::string TestFlashFile::TestCreateTemporaryFile() {
- SetUp();
size_t before_create = 0;
ASSERT_SUBTEST_SUCCESS(GetItemCountUnderModuleLocalRoot(&before_create));
diff --git a/ppapi/tests/test_flash_file.h b/ppapi/tests/test_flash_file.h
index 86055db..b58890d 100644
--- a/ppapi/tests/test_flash_file.h
+++ b/ppapi/tests/test_flash_file.h
@@ -19,21 +19,10 @@ class TestFlashFile: public TestCase {
virtual void RunTests(const std::string& filter);
private:
- // TODO(raymes): We should have SetUp/TearDown methods for ppapi tests.
- void SetUp();
-
- std::string TestOpenFile();
- std::string TestRenameFile();
- std::string TestDeleteFileOrDir();
- std::string TestCreateDir();
- std::string TestQueryFile();
- std::string TestGetDirContents();
+ // TODO(yzshen): Add more test cases for PPB_Flash_File_ModuleLocal and
+ // PPB_Flash_File_FileRef.
std::string TestCreateTemporaryFile();
- // TODO(raymes): Add these when we can test file chooser properly.
- // std::string TestOpenFileRef();
- // std::string TestQueryFileRef();
-
// Gets the number of files and directories under the module-local root
// directory.
std::string GetItemCountUnderModuleLocalRoot(size_t* item_count);
diff --git a/ppapi/thunk/ppb_file_ref_api.h b/ppapi/thunk/ppb_file_ref_api.h
index 0f9bbaa..ed46098 100644
--- a/ppapi/thunk/ppb_file_ref_api.h
+++ b/ppapi/thunk/ppb_file_ref_api.h
@@ -33,7 +33,7 @@ class PPAPI_THUNK_EXPORT PPB_FileRef_API {
virtual int32_t Rename(PP_Resource new_file_ref,
scoped_refptr<TrackedCallback> callback) = 0;
- // Internal function for use in proxying. Returns the internal CreateInfo
+ // Intermal function for use in proxying. Returns the internal CreateInfo
// (the contained resource does not carry a ref on behalf of the caller).
virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const = 0;
diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h
index b787e1d..fad0600 100644
--- a/ppapi/thunk/ppb_flash_api.h
+++ b/ppapi/thunk/ppb_flash_api.h
@@ -56,6 +56,40 @@ class PPAPI_THUNK_EXPORT PPB_Flash_API {
virtual double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) = 0;
virtual PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) = 0;
virtual PP_Var GetSetting(PP_Instance instance, PP_FlashSetting setting) = 0;
+
+ // FlashFile_ModuleLocal.
+ virtual bool CreateThreadAdapterForInstance(PP_Instance instance) = 0;
+ virtual void ClearThreadAdapterForInstance(PP_Instance instance) = 0;
+ virtual int32_t OpenFile(PP_Instance instance,
+ const char* path,
+ int32_t mode,
+ PP_FileHandle* file) = 0;
+ virtual int32_t RenameFile(PP_Instance instance,
+ const char* path_from,
+ const char* path_to) = 0;
+ virtual int32_t DeleteFileOrDir(PP_Instance instance,
+ const char* path,
+ PP_Bool recursive) = 0;
+ virtual int32_t CreateDir(PP_Instance instance, const char* path) = 0;
+ virtual int32_t QueryFile(PP_Instance instance,
+ const char* path,
+ PP_FileInfo* info) = 0;
+ virtual int32_t GetDirContents(PP_Instance instance,
+ const char* path,
+ PP_DirContents_Dev** contents) = 0;
+ virtual void FreeDirContents(PP_Instance instance,
+ PP_DirContents_Dev* contents) = 0;
+ virtual int32_t CreateTemporaryFile(PP_Instance instance,
+ PP_FileHandle* file) = 0;
+
+ // FlashFile_FileRef.
+ virtual int32_t OpenFileRef(PP_Instance instance,
+ PP_Resource file_ref,
+ int32_t mode,
+ PP_FileHandle* file) = 0;
+ virtual int32_t QueryFileRef(PP_Instance instance,
+ PP_Resource file_ref,
+ PP_FileInfo* info) = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_flash_file_api.h b/ppapi/thunk/ppb_flash_file_api.h
deleted file mode 100644
index d757253..0000000
--- a/ppapi/thunk/ppb_flash_file_api.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 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 PPAPI_THUNK_PPB_FLASH_FILE_API_H_
-#define PPAPI_THUNK_PPB_FLASH_FILE_API_H_
-
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_stdint.h"
-#include "ppapi/c/private/pp_file_handle.h"
-#include "ppapi/c/private/ppb_flash_file.h"
-#include "ppapi/shared_impl/singleton_resource_id.h"
-#include "ppapi/thunk/ppapi_thunk_export.h"
-
-struct PP_FileInfo;
-
-namespace ppapi {
-namespace thunk {
-
-class PPAPI_THUNK_EXPORT PPB_Flash_File_API {
- public:
- virtual ~PPB_Flash_File_API() {}
-
- // FlashFile_ModuleLocal.
- virtual int32_t OpenFile(PP_Instance instance,
- const char* path,
- int32_t mode,
- PP_FileHandle* file) = 0;
- virtual int32_t RenameFile(PP_Instance instance,
- const char* path_from,
- const char* path_to) = 0;
- virtual int32_t DeleteFileOrDir(PP_Instance instance,
- const char* path,
- PP_Bool recursive) = 0;
- virtual int32_t CreateDir(PP_Instance instance, const char* path) = 0;
- virtual int32_t QueryFile(PP_Instance instance,
- const char* path,
- PP_FileInfo* info) = 0;
- virtual int32_t GetDirContents(PP_Instance instance,
- const char* path,
- PP_DirContents_Dev** contents) = 0;
- virtual void FreeDirContents(PP_Instance instance,
- PP_DirContents_Dev* contents) = 0;
- virtual int32_t CreateTemporaryFile(PP_Instance instance,
- PP_FileHandle* file) = 0;
-
- // FlashFile_FileRef.
- virtual int32_t OpenFileRef(PP_Instance instance,
- PP_Resource file_ref,
- int32_t mode,
- PP_FileHandle* file) = 0;
- virtual int32_t QueryFileRef(PP_Instance instance,
- PP_Resource file_ref,
- PP_FileInfo* info) = 0;
-
- static const SingletonResourceID kSingletonResourceID =
- FLASH_FILE_SINGLETON_ID;
-};
-
-} // namespace thunk
-} // namespace ppapi
-
-#endif // PPAPI_THUNK_PPB_FLASH_FILE_API_H_
diff --git a/ppapi/thunk/ppb_flash_file_fileref_thunk.cc b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc
index 8ea0f24..2b380c7 100644
--- a/ppapi/thunk/ppb_flash_file_fileref_thunk.cc
+++ b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc
@@ -6,7 +6,8 @@
#include "ppapi/c/private/ppb_flash_file.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_file_ref_api.h"
-#include "ppapi/thunk/ppb_flash_file_api.h"
+#include "ppapi/thunk/ppb_flash_api.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
@@ -26,20 +27,22 @@ int32_t OpenFile(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file) {
// TODO(brettw): this function should take an instance.
// To work around this, use the PP_Instance from the resource.
PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->OpenFileRef(instance, file_ref_id, mode, file);
+ return enter.functions()->GetFlashAPI()->OpenFileRef(instance, file_ref_id,
+ mode, file);
}
int32_t QueryFile(PP_Resource file_ref_id, struct PP_FileInfo* info) {
// TODO(brettw): this function should take an instance.
// To work around this, use the PP_Instance from the resource.
PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->QueryFileRef(instance, file_ref_id, info);
+ return enter.functions()->GetFlashAPI()->QueryFileRef(instance, file_ref_id,
+ info);
}
const PPB_Flash_File_FileRef g_ppb_flash_file_fileref_thunk = {
diff --git a/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
index 03d9032..7e9678a 100644
--- a/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
+++ b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
@@ -5,7 +5,8 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_flash_file.h"
#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_flash_file_api.h"
+#include "ppapi/thunk/ppb_flash_api.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
@@ -14,77 +15,89 @@ namespace thunk {
namespace {
bool CreateThreadAdapterForInstance(PP_Instance instance) {
- return true;
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return false;
+ return enter.functions()->GetFlashAPI()->CreateThreadAdapterForInstance(
+ instance);
}
void ClearThreadAdapterForInstance(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.succeeded()) {
+ return enter.functions()->GetFlashAPI()->ClearThreadAdapterForInstance(
+ instance);
+ }
}
int32_t OpenFile(PP_Instance instance,
const char* path,
int32_t mode,
PP_FileHandle* file) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->OpenFile(instance, path, mode, file);
+ return enter.functions()->GetFlashAPI()->OpenFile(instance, path, mode, file);
}
int32_t RenameFile(PP_Instance instance,
const char* path_from,
const char* path_to) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->RenameFile(instance, path_from, path_to);
+ return enter.functions()->GetFlashAPI()->RenameFile(instance,
+ path_from, path_to);
}
int32_t DeleteFileOrDir(PP_Instance instance,
const char* path,
PP_Bool recursive) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->DeleteFileOrDir(instance, path, recursive);
+ return enter.functions()->GetFlashAPI()->DeleteFileOrDir(instance, path,
+ recursive);
}
int32_t CreateDir(PP_Instance instance, const char* path) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->CreateDir(instance, path);
+ return enter.functions()->GetFlashAPI()->CreateDir(instance, path);
}
int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->QueryFile(instance, path, info);
+ return enter.functions()->GetFlashAPI()->QueryFile(instance, path, info);
}
int32_t GetDirContents(PP_Instance instance,
const char* path,
PP_DirContents_Dev** contents) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
- return enter.functions()->GetDirContents(instance, path, contents);
+ return enter.functions()->GetFlashAPI()->GetDirContents(instance, path,
+ contents);
}
void FreeDirContents(PP_Instance instance,
PP_DirContents_Dev* contents) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.succeeded())
- enter.functions()->FreeDirContents(instance, contents);
+ enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents);
}
int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) {
- EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
+ EnterInstance enter(instance);
if (enter.failed())
return PP_ERROR_BADARGUMENT;
*file = PP_kInvalidFileHandle;
- return enter.functions()->CreateTemporaryFile(instance, file);
+ return enter.functions()->GetFlashAPI()->CreateTemporaryFile(instance, file);
}
const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = {