Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: ppapi/proxy/ppb_flash_proxy.cc

Issue 11359097: Refactored the PPB_Flash_File_ModuleLocal/FileRef to the new ppapi resource model (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/ppb_flash_proxy.cc
diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc
index 23e335d044102ee22f1387a2da97f45fbb080724..15958692f0c8ed74774c3846c12a51b52557cca2 100644
--- a/ppapi/proxy/ppb_flash_proxy.cc
+++ b/ppapi/proxy/ppb_flash_proxy.cc
@@ -19,7 +19,6 @@
#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/plugin_proxy_delegate.h"
@@ -122,10 +121,6 @@ bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgFlashSetFullscreen)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize,
OnHostMsgFlashGetScreenSize)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef,
- OnHostMsgOpenFileRef)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef,
- OnHostMsgQueryFileRef)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID,
OnHostMsgGetDeviceID)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting,
@@ -357,187 +352,6 @@ PP_Bool PPB_Flash_Proxy::SetCrashData(PP_Instance instance,
return PP_FALSE;
}
-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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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()->plugin_proxy_delegate()->SendToBrowser(
- 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;
-}
-
PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) {
InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
GetInstanceData(instance);
@@ -702,39 +516,6 @@ void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance,
}
}
-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) {

Powered by Google App Engine
This is Rietveld 408576698