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

Unified Diff: content/renderer/pepper/pepper_file_io_host.cc

Issue 22646005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to final patch. Created 7 years, 4 months 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
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.h ('k') | ppapi/proxy/file_io_resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_file_io_host.cc
diff --git a/content/renderer/pepper/pepper_file_io_host.cc b/content/renderer/pepper/pepper_file_io_host.cc
index 7d72cd21e3af1c06ea46788002b44dda7de6c057..0431b1ce3f1109605d6d3cfa72c4c2101078219c 100644
--- a/content/renderer/pepper/pepper_file_io_host.cc
+++ b/content/renderer/pepper/pepper_file_io_host.cc
@@ -42,13 +42,6 @@ using ppapi::thunk::EnterResourceNoLock;
namespace {
-// The maximum size we'll support reading in one chunk. The renderer process
-// must allocate a buffer sized according to the request of the plugin. To
-// keep things from getting out of control, we cap the read size to this value.
-// This should generally be OK since the API specifies that it may perform a
-// partial read.
-static const int32_t kMaxReadSize = 32 * 1024 * 1024; // 32MB
-
typedef base::Callback<void (base::PlatformFileError)> PlatformGeneralCallback;
int32_t ErrorOrByteNumber(int32_t pp_error, int32_t byte_number) {
@@ -167,12 +160,8 @@ int32_t PepperFileIOHost::OnResourceMessageReceived(
IPC_BEGIN_MESSAGE_MAP(PepperFileIOHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Open,
OnHostMsgOpen)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_Query,
- OnHostMsgQuery)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Touch,
OnHostMsgTouch)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Read,
- OnHostMsgRead)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Write,
OnHostMsgWrite)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_SetLength,
@@ -304,25 +293,6 @@ void PepperFileIOHost::DidGetFileRefInfo(
}
}
-int32_t PepperFileIOHost::OnHostMsgQuery(
- ppapi::host::HostMessageContext* context) {
- int32_t rv = state_manager_.CheckOperationState(
- FileIOStateManager::OPERATION_EXCLUSIVE, true);
- if (rv != PP_OK)
- return rv;
-
- if (!base::FileUtilProxy::GetFileInfoFromPlatformFile(
- RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(),
- file_,
- base::Bind(&PepperFileIOHost::ExecutePlatformQueryCallback,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext())))
- return PP_ERROR_FAILED;
-
- state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
- return PP_OK_COMPLETIONPENDING;
-}
-
int32_t PepperFileIOHost::OnHostMsgTouch(
ppapi::host::HostMessageContext* context,
PP_Time last_access_time,
@@ -362,39 +332,6 @@ int32_t PepperFileIOHost::OnHostMsgTouch(
return PP_OK_COMPLETIONPENDING;
}
-int32_t PepperFileIOHost::OnHostMsgRead(
- ppapi::host::HostMessageContext* context,
- int64_t offset,
- int32_t max_read_length) {
- int32_t rv = state_manager_.CheckOperationState(
- FileIOStateManager::OPERATION_READ, true);
- if (rv != PP_OK)
- return rv;
-
- // Validate max_read_length before allocating below. This value is coming from
- // the untrusted plugin.
- if (max_read_length < 0) {
- ReplyMessageContext reply_context = context->MakeReplyMessageContext();
- reply_context.params.set_result(PP_ERROR_FAILED);
- host()->SendReply(reply_context,
- PpapiPluginMsg_FileIO_ReadReply(std::string()));
- return PP_OK_COMPLETIONPENDING;
- }
-
- if (!base::FileUtilProxy::Read(
- RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(),
- file_,
- offset,
- max_read_length,
- base::Bind(&PepperFileIOHost::ExecutePlatformReadCallback,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext())))
- return PP_ERROR_FAILED;
-
- state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_READ);
- return PP_OK_COMPLETIONPENDING;
-}
-
int32_t PepperFileIOHost::OnHostMsgWrite(
ppapi::host::HostMessageContext* context,
int64_t offset,
@@ -642,36 +579,6 @@ void PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback(
ExecutePlatformOpenFileCallback(reply_context, error_code, file);
}
-void PepperFileIOHost::ExecutePlatformQueryCallback(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- const base::PlatformFileInfo& file_info) {
- PP_FileInfo pp_info;
- ppapi::PlatformFileInfoToPepperFileInfo(file_info, file_system_type_,
- &pp_info);
-
- int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code);
- reply_context.params.set_result(pp_error);
- host()->SendReply(reply_context,
- PpapiPluginMsg_FileIO_QueryReply(pp_info));
- state_manager_.SetOperationFinished();
-}
-
-void PepperFileIOHost::ExecutePlatformReadCallback(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- const char* data, int bytes_read) {
- int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code);
-
- // Only send the amount of data in the string that was actually read.
- std::string buffer;
- if (pp_error == PP_OK)
- buffer.append(data, bytes_read);
- reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_read));
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_ReadReply(buffer));
- state_manager_.SetOperationFinished();
-}
-
void PepperFileIOHost::ExecutePlatformWriteCallback(
ppapi::host::ReplyMessageContext reply_context,
base::PlatformFileError error_code,
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.h ('k') | ppapi/proxy/file_io_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698