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

Unified Diff: content/browser/renderer_host/pepper/pepper_file_io_host.cc

Issue 252583007: Replace FileUtilProxy with FileProxy in renderer_host/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments Created 6 years, 7 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/browser/renderer_host/pepper/pepper_file_io_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_file_io_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698