| Index: content/browser/renderer_host/pepper/pepper_file_io_host.cc
|
| diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
|
| index 94243679d59db5f9f723689f8905025441a7b633..a4ff230e38c4adc8729706a636ae0a9b15374aca 100644
|
| --- a/content/browser/renderer_host/pepper/pepper_file_io_host.cc
|
| +++ b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
|
| @@ -86,7 +86,7 @@ PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host,
|
| : ResourceHost(host->GetPpapiHost(), instance, resource),
|
| browser_ppapi_host_(host),
|
| render_process_host_(NULL),
|
| - file_(base::kInvalidPlatformFileValue),
|
| + file_(BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)),
|
| open_flags_(0),
|
| file_system_type_(PP_FILESYSTEMTYPE_INVALID),
|
| max_written_offset_(0),
|
| @@ -97,8 +97,6 @@ PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host,
|
| instance, &render_process_id_, &unused)) {
|
| render_process_id_ = -1;
|
| }
|
| - file_message_loop_ =
|
| - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
|
| }
|
|
|
| PepperFileIOHost::~PepperFileIOHost() {}
|
| @@ -265,15 +263,14 @@ void PepperFileIOHost::DidOpenInternalFile(
|
| void PepperFileIOHost::GotResolvedRenderProcessId(
|
| ppapi::host::ReplyMessageContext reply_context,
|
| base::FilePath path,
|
| - int platform_file_flags,
|
| + int file_flags,
|
| base::ProcessId resolved_render_process_id) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| resolved_render_process_id_ = resolved_render_process_id;
|
| - base::FileUtilProxy::CreateOrOpen(
|
| - file_message_loop_,
|
| + file_.CreateOrOpen(
|
| path,
|
| - platform_file_flags,
|
| - base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
|
| + file_flags,
|
| + base::Bind(&PepperFileIOHost::OnOpenProxyCallback,
|
| weak_factory_.GetWeakPtr(),
|
| reply_context));
|
| }
|
| @@ -287,15 +284,14 @@ int32_t PepperFileIOHost::OnHostMsgTouch(
|
| if (rv != PP_OK)
|
| return rv;
|
|
|
| - if (!base::FileUtilProxy::Touch(
|
| - file_message_loop_,
|
| - file_,
|
| + if (!file_.SetTimes(
|
| PPTimeToTime(last_access_time),
|
| PPTimeToTime(last_modified_time),
|
| base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
|
| weak_factory_.GetWeakPtr(),
|
| - context->MakeReplyMessageContext())))
|
| + context->MakeReplyMessageContext()))) {
|
| return PP_ERROR_FAILED;
|
| + }
|
|
|
| state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
|
| return PP_OK_COMPLETIONPENDING;
|
| @@ -314,14 +310,13 @@ int32_t PepperFileIOHost::OnHostMsgSetLength(
|
| // Quota checks are performed on the plugin side, in order to use the same
|
| // quota reservation and request system as Write.
|
|
|
| - if (!base::FileUtilProxy::Truncate(
|
| - file_message_loop_,
|
| - file_,
|
| + if (!file_.SetLength(
|
| length,
|
| base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
|
| weak_factory_.GetWeakPtr(),
|
| - context->MakeReplyMessageContext())))
|
| + context->MakeReplyMessageContext()))) {
|
| return PP_ERROR_FAILED;
|
| + }
|
|
|
| state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
|
| return PP_OK_COMPLETIONPENDING;
|
| @@ -334,13 +329,12 @@ int32_t PepperFileIOHost::OnHostMsgFlush(
|
| if (rv != PP_OK)
|
| return rv;
|
|
|
| - if (!base::FileUtilProxy::Flush(
|
| - file_message_loop_,
|
| - file_,
|
| + if (!file_.Flush(
|
| base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
|
| weak_factory_.GetWeakPtr(),
|
| - context->MakeReplyMessageContext())))
|
| + context->MakeReplyMessageContext()))) {
|
| return PP_ERROR_FAILED;
|
| + }
|
|
|
| state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
|
| return PP_OK_COMPLETIONPENDING;
|
| @@ -354,12 +348,9 @@ int32_t PepperFileIOHost::OnHostMsgClose(
|
| check_quota_ = false;
|
| }
|
|
|
| - if (file_ != base::kInvalidPlatformFileValue) {
|
| - base::FileUtilProxy::Close(file_message_loop_,
|
| - file_,
|
| - base::Bind(&PepperFileIOHost::DidCloseFile,
|
| - weak_factory_.GetWeakPtr()));
|
| - file_ = base::kInvalidPlatformFileValue;
|
| + if (file_.IsValid()) {
|
| + file_.Close(base::Bind(&PepperFileIOHost::DidCloseFile,
|
| + weak_factory_.GetWeakPtr()));
|
| }
|
| return PP_OK;
|
| }
|
| @@ -425,17 +416,23 @@ void PepperFileIOHost::ExecutePlatformGeneralCallback(
|
| state_manager_.SetOperationFinished();
|
| }
|
|
|
| +// TODO(rvargas): this method should go away when FileApi moves to use File.
|
| void PepperFileIOHost::ExecutePlatformOpenFileCallback(
|
| ppapi::host::ReplyMessageContext reply_context,
|
| base::File::Error error_code,
|
| base::PassPlatformFile file,
|
| bool unused_created) {
|
| - int32_t pp_error = ppapi::FileErrorToPepperError(error_code);
|
| - DCHECK(file_ == base::kInvalidPlatformFileValue);
|
| - file_ = file.ReleaseValue();
|
| + DCHECK(!file_.IsValid());
|
| + file_.SetFile(base::File(file.ReleaseValue()));
|
|
|
| - if (file_ != base::kInvalidPlatformFileValue &&
|
| - !AddFileToReplyContext(open_flags_, &reply_context))
|
| + OnOpenProxyCallback(reply_context, error_code);
|
| +}
|
| +
|
| +void PepperFileIOHost::OnOpenProxyCallback(
|
| + ppapi::host::ReplyMessageContext reply_context,
|
| + base::File::Error error_code) {
|
| + int32_t pp_error = ppapi::FileErrorToPepperError(error_code);
|
| + if (file_.IsValid() && !AddFileToReplyContext(open_flags_, &reply_context))
|
| pp_error = PP_ERROR_FAILED;
|
|
|
| PP_Resource quota_file_system = 0;
|
| @@ -467,7 +464,8 @@ bool PepperFileIOHost::AddFileToReplyContext(
|
| plugin_process_id = resolved_render_process_id_;
|
|
|
| IPC::PlatformFileForTransit transit_file =
|
| - BrokerGetFileHandleForProcess(file_, plugin_process_id, false);
|
| + BrokerGetFileHandleForProcess(file_.GetPlatformFile(), plugin_process_id,
|
| + false);
|
| if (transit_file == IPC::InvalidPlatformFileForTransit())
|
| return false;
|
|
|
|
|