summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 01:27:26 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 01:27:26 +0000
commitd062d9636fb69a79942ada2321fe48e9f326cf8c (patch)
tree411c6f8c59b2f282a2ff539d2a6b22adade8cb84 /ppapi
parentc35d5507f07fa3a7820b991b69786c6175590849 (diff)
downloadchromium_src-d062d9636fb69a79942ada2321fe48e9f326cf8c.zip
chromium_src-d062d9636fb69a79942ada2321fe48e9f326cf8c.tar.gz
chromium_src-d062d9636fb69a79942ada2321fe48e9f326cf8c.tar.bz2
Pepper/Flapper: Get rid of unimplemented private file ref stuff and implement proxy.
BUG=none TEST=builds? works? Review URL: http://codereview.chromium.org/6594099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/private/ppb_flash_file.h16
-rw-r--r--ppapi/proxy/dispatcher.cc1
-rw-r--r--ppapi/proxy/interface_id.h3
-rw-r--r--ppapi/proxy/ppapi_messages_internal.h11
-rw-r--r--ppapi/proxy/ppb_flash_file_proxy.cc134
-rw-r--r--ppapi/proxy/ppb_flash_file_proxy.h28
6 files changed, 172 insertions, 21 deletions
diff --git a/ppapi/c/private/ppb_flash_file.h b/ppapi/c/private/ppb_flash_file.h
index 9e2def9..9b674fa 100644
--- a/ppapi/c/private/ppb_flash_file.h
+++ b/ppapi/c/private/ppb_flash_file.h
@@ -88,28 +88,20 @@ struct PPB_Flash_File_ModuleLocal {
// PPB_Flash_File_FileRef ------------------------------------------------------
-#define PPB_FLASH_FILE_FILEREF_INTERFACE "PPB_Flash_File_FileRef;1"
+#define PPB_FLASH_FILE_FILEREF_INTERFACE "PPB_Flash_File_FileRef;2"
// This interface provides (for Flash) synchronous access to files whose paths
// are given by a Pepper FileRef. Such FileRefs are typically obtained via the
// Pepper file chooser.
struct PPB_Flash_File_FileRef {
- // The functions below correspond exactly to the ones in the module-local file
- // interface (except in taking FileRefs instead of paths, of course).
+ // The functions below correspond exactly to their module-local counterparts
+ // (except in taking FileRefs instead of paths, of course). We omit the
+ // functionality which we do not provide for FileRefs.
int32_t (*OpenFile)(PP_Resource file_ref_id,
int32_t mode,
PP_FileHandle* file);
- int32_t (*RenameFile)(PP_Resource from_file_ref_id,
- PP_Resource to_file_ref_id);
- int32_t (*DeleteFileOrDir)(PP_Resource file_ref_id,
- PP_Bool recursive);
- int32_t (*CreateDir)(PP_Resource file_ref_id);
int32_t (*QueryFile)(PP_Resource file_ref_id,
struct PP_FileInfo_Dev* info);
- int32_t (*GetDirContents)(PP_Resource file_ref_id,
- struct PP_DirContents_Dev** contents);
- void (*FreeDirContents)(PP_Instance instance,
- struct PP_DirContents_Dev* contents);
};
#endif // PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index ad0094d..2051588 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -109,6 +109,7 @@ InterfaceList::InterfaceList() {
AddPPB(PPB_FileChooser_Proxy::GetInfo());
AddPPB(PPB_FileRef_Proxy::GetInfo());
AddPPB(PPB_FileSystem_Proxy::GetInfo());
+ AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo());
AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo());
AddPPB(PPB_Flash_Proxy::GetInfo());
AddPPB(PPB_Flash_Menu_Proxy::GetInfo());
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h
index b412441..191f990 100644
--- a/ppapi/proxy/interface_id.h
+++ b/ppapi/proxy/interface_id.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -24,6 +24,7 @@ enum InterfaceID {
INTERFACE_ID_PPB_FILE_REF,
INTERFACE_ID_PPB_FILE_SYSTEM,
INTERFACE_ID_PPB_FLASH,
+ INTERFACE_ID_PPB_FLASH_FILE_FILEREF,
INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL,
INTERFACE_ID_PPB_FLASH_MENU,
INTERFACE_ID_PPB_FONT,
diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h
index 9446f22..7ad4551 100644
--- a/ppapi/proxy/ppapi_messages_internal.h
+++ b/ppapi/proxy/ppapi_messages_internal.h
@@ -356,6 +356,17 @@ IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlash_RunMessageLoop,
IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlash_QuitMessageLoop,
PP_Instance /* instance */)
+// PPB_Flash_File_FileRef.
+IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlashFile_FileRef_OpenFile,
+ pp::proxy::HostResource /* file_ref */,
+ int32_t /* mode */,
+ IPC::PlatformFileForTransit /* file_handle */,
+ int32_t /* result */)
+IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBFlashFile_FileRef_QueryFile,
+ pp::proxy::HostResource /* file_ref */,
+ PP_FileInfo_Dev /* info */,
+ int32_t /* result */)
+
// PPB_Flash_File_ModuleLocal.
IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBFlashFile_ModuleLocal_OpenFile,
PP_Instance /* instance */,
diff --git a/ppapi/proxy/ppb_flash_file_proxy.cc b/ppapi/proxy/ppb_flash_file_proxy.cc
index 0c0869a..da0f2b9 100644
--- a/ppapi/proxy/ppb_flash_file_proxy.cc
+++ b/ppapi/proxy/ppb_flash_file_proxy.cc
@@ -42,6 +42,12 @@ void FreeDirContents(PP_Instance /* instance */,
delete contents;
}
+} // namespace
+
+// PPB_Flash_File_ModuleLocal --------------------------------------------------
+
+namespace {
+
int32_t OpenModuleLocalFile(PP_Instance instance,
const char* path,
int32_t mode,
@@ -60,8 +66,8 @@ int32_t OpenModuleLocalFile(PP_Instance instance,
}
int32_t RenameModuleLocalFile(PP_Instance instance,
- const char* path_from,
- const char* path_to) {
+ const char* from_path,
+ const char* to_path) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return PP_ERROR_BADARGUMENT;
@@ -69,7 +75,7 @@ int32_t RenameModuleLocalFile(PP_Instance instance,
int32_t result = PP_ERROR_FAILED;
dispatcher->Send(new PpapiHostMsg_PPBFlashFile_ModuleLocal_RenameFile(
INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL,
- instance, path_from, path_to, &result));
+ instance, from_path, to_path, &result));
return result;
}
@@ -144,7 +150,7 @@ int32_t GetModuleLocalDirContents(PP_Instance instance,
return result;
}
-const PPB_Flash_File_ModuleLocal flash_file_module_local_interface = {
+const PPB_Flash_File_ModuleLocal flash_file_modulelocal_interface = {
&OpenModuleLocalFile,
&RenameModuleLocalFile,
&DeleteModuleLocalFileOrDir,
@@ -173,7 +179,7 @@ PPB_Flash_File_ModuleLocal_Proxy::~PPB_Flash_File_ModuleLocal_Proxy() {
// static
const InterfaceProxy::Info* PPB_Flash_File_ModuleLocal_Proxy::GetInfo() {
static const Info info = {
- &flash_file_module_local_interface,
+ &flash_file_modulelocal_interface,
PPB_FLASH_FILE_MODULELOCAL_INTERFACE,
INTERFACE_ID_PPB_FLASH_FILE_MODULELOCAL,
true,
@@ -219,11 +225,11 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgOpenFile(
void PPB_Flash_File_ModuleLocal_Proxy::OnMsgRenameFile(
PP_Instance instance,
- const std::string& path_from,
- const std::string& path_to,
+ const std::string& from_path,
+ const std::string& to_path,
int32_t* result) {
*result = ppb_flash_file_module_local_target()->
- RenameFile(instance, path_from.c_str(), path_to.c_str());
+ RenameFile(instance, from_path.c_str(), to_path.c_str());
}
void PPB_Flash_File_ModuleLocal_Proxy::OnMsgDeleteFileOrDir(
@@ -270,5 +276,117 @@ void PPB_Flash_File_ModuleLocal_Proxy::OnMsgGetDirContents(
ppb_flash_file_module_local_target()->FreeDirContents(instance, contents);
}
+// PPB_Flash_File_FileRef ------------------------------------------------------
+
+namespace {
+
+int32_t OpenFileRefFile(PP_Resource file_ref_id,
+ int32_t mode,
+ PP_FileHandle* file) {
+ PluginResource* file_ref =
+ PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id);
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ PluginDispatcher* dispatcher =
+ PluginDispatcher::GetForInstance(file_ref->instance());
+ if (!dispatcher)
+ return PP_ERROR_BADARGUMENT;
+
+ int32_t result = PP_ERROR_FAILED;
+ IPC::PlatformFileForTransit transit;
+ dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_OpenFile(
+ INTERFACE_ID_PPB_FLASH_FILE_FILEREF,
+ file_ref->host_resource(), mode, &transit, &result));
+ *file = IPC::PlatformFileForTransitToPlatformFile(transit);
+ return result;
+}
+
+int32_t QueryFileRefFile(PP_Resource file_ref_id,
+ PP_FileInfo_Dev* info) {
+ PluginResource* file_ref =
+ PluginResourceTracker::GetInstance()->GetResourceObject(file_ref_id);
+ if (!file_ref)
+ return PP_ERROR_BADRESOURCE;
+
+ PluginDispatcher* dispatcher =
+ PluginDispatcher::GetForInstance(file_ref->instance());
+ if (!dispatcher)
+ return PP_ERROR_BADARGUMENT;
+
+ int32_t result = PP_ERROR_FAILED;
+ dispatcher->Send(new PpapiHostMsg_PPBFlashFile_FileRef_QueryFile(
+ INTERFACE_ID_PPB_FLASH_FILE_FILEREF,
+ file_ref->host_resource(), info, &result));
+ return result;
+}
+
+const PPB_Flash_File_FileRef flash_file_fileref_interface = {
+ &OpenFileRefFile,
+ &QueryFileRefFile,
+};
+
+InterfaceProxy* CreateFlashFileFileRefProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_Flash_File_FileRef_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_Flash_File_FileRef_Proxy::PPB_Flash_File_FileRef_Proxy(
+ Dispatcher* dispatcher,
+ const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+}
+
+PPB_Flash_File_FileRef_Proxy::~PPB_Flash_File_FileRef_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPB_Flash_File_FileRef_Proxy::GetInfo() {
+ static const Info info = {
+ &flash_file_fileref_interface,
+ PPB_FLASH_FILE_FILEREF_INTERFACE,
+ INTERFACE_ID_PPB_FLASH_FILE_FILEREF,
+ true,
+ &CreateFlashFileFileRefProxy,
+ };
+ return &info;
+}
+
+bool PPB_Flash_File_FileRef_Proxy::OnMessageReceived(
+ const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPB_Flash_File_FileRef_Proxy, msg)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashFile_FileRef_OpenFile,
+ OnMsgOpenFile)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashFile_FileRef_QueryFile,
+ OnMsgQueryFile)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ // TODO(brettw) handle bad messages!
+ return handled;
+}
+
+void PPB_Flash_File_FileRef_Proxy::OnMsgOpenFile(
+ const HostResource& host_resource,
+ int32_t mode,
+ IPC::PlatformFileForTransit* file_handle,
+ int32_t* result) {
+ base::PlatformFile file;
+ *result = ppb_flash_file_module_local_target()->
+ OpenFile(host_resource.host_resource(), mode, &file);
+ *file_handle = PlatformFileToPlatformFileForTransit(
+ dispatcher(), result, file);
+}
+
+void PPB_Flash_File_FileRef_Proxy::OnMsgQueryFile(
+ const HostResource& host_resource,
+ PP_FileInfo_Dev* info,
+ int32_t* result) {
+ *result = ppb_flash_file_module_local_target()->
+ QueryFile(host_resource.host_resource(), info);
+}
+
} // namespace proxy
} // namespace pp
diff --git a/ppapi/proxy/ppb_flash_file_proxy.h b/ppapi/proxy/ppb_flash_file_proxy.h
index be4821c..e10bb94 100644
--- a/ppapi/proxy/ppb_flash_file_proxy.h
+++ b/ppapi/proxy/ppb_flash_file_proxy.h
@@ -13,11 +13,13 @@
#include "ppapi/proxy/interface_proxy.h"
struct PP_FileInfo_Dev;
+struct PPB_Flash_File_FileRef;
struct PPB_Flash_File_ModuleLocal;
namespace pp {
namespace proxy {
+class HostResource;
struct SerializedDirEntry;
class PPB_Flash_File_ModuleLocal_Proxy : public InterfaceProxy {
@@ -63,6 +65,32 @@ class PPB_Flash_File_ModuleLocal_Proxy : public InterfaceProxy {
int32_t* result);
};
+class PPB_Flash_File_FileRef_Proxy : public InterfaceProxy {
+ public:
+ PPB_Flash_File_FileRef_Proxy(Dispatcher* dispatcher,
+ const void* target_interface);
+ virtual ~PPB_Flash_File_FileRef_Proxy();
+
+ static const Info* GetInfo();
+
+ const PPB_Flash_File_FileRef* ppb_flash_file_module_local_target() const {
+ return static_cast<const PPB_Flash_File_FileRef*>(target_interface());
+ }
+
+ // InterfaceProxy implementation.
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+ private:
+ // Message handlers.
+ void OnMsgOpenFile(const HostResource& host_resource,
+ int32_t mode,
+ IPC::PlatformFileForTransit* file_handle,
+ int32_t* result);
+ void OnMsgQueryFile(const HostResource& host_resource,
+ PP_FileInfo_Dev* info,
+ int32_t* result);
+};
+
} // namespace proxy
} // namespace pp