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

Unified Diff: components/nacl/browser/nacl_file_host.cc

Issue 165663002: Remove some PlatformFile uses from NaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add empty line Created 6 years, 10 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 | « components/nacl/browser/nacl_browser.cc ('k') | components/nacl/browser/nacl_host_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/browser/nacl_file_host.cc
diff --git a/components/nacl/browser/nacl_file_host.cc b/components/nacl/browser/nacl_file_host.cc
index 80eab39e37be9ba3e64630fc320cc090a028e85b..2744b8e948bc6ea86d2bfc1d2e6e60c14e02fe0e 100644
--- a/components/nacl/browser/nacl_file_host.cc
+++ b/components/nacl/browser/nacl_file_host.cc
@@ -6,9 +6,9 @@
#include "base/bind.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
-#include "base/platform_file.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/nacl/browser/nacl_browser.h"
@@ -38,18 +38,9 @@ void NotifyRendererOfError(
nacl_host_message_filter->Send(reply_msg);
}
-bool PnaclDoOpenFile(const base::FilePath& file_to_open,
- base::PlatformFile* out_file) {
- base::PlatformFileError error_code;
- *out_file = base::CreatePlatformFile(file_to_open,
- base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_READ,
- NULL,
- &error_code);
- if (error_code != base::PLATFORM_FILE_OK) {
- return false;
- }
- return true;
+base::File PnaclDoOpenFile(const base::FilePath& file_to_open) {
+ return base::File(file_to_open,
+ base::File::FLAG_OPEN | base::File::FLAG_READ);
}
void DoOpenPnaclFile(
@@ -73,8 +64,8 @@ void DoOpenPnaclFile(
return;
}
- base::PlatformFile file_to_open;
- if (!PnaclDoOpenFile(full_filepath, &file_to_open)) {
+ base::File file_to_open = PnaclDoOpenFile(full_filepath);
+ if (!file_to_open.IsValid()) {
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -82,9 +73,8 @@ void DoOpenPnaclFile(
// Send the reply!
// Do any DuplicateHandle magic that is necessary first.
IPC::PlatformFileForTransit target_desc =
- IPC::GetFileHandleForProcess(file_to_open,
- nacl_host_message_filter->PeerHandle(),
- true /* Close source */);
+ IPC::TakeFileHandleForProcess(file_to_open.Pass(),
+ nacl_host_message_filter->PeerHandle());
if (target_desc == IPC::InvalidPlatformFileForTransit()) {
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
@@ -96,7 +86,7 @@ void DoOpenPnaclFile(
void DoRegisterOpenedNaClExecutableFile(
scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter,
- base::PlatformFile file,
+ base::File file,
base::FilePath file_path,
IPC::Message* reply_msg) {
// IO thread owns the NaClBrowser singleton.
@@ -107,10 +97,9 @@ void DoRegisterOpenedNaClExecutableFile(
uint64 file_token_hi = 0;
nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi);
- IPC::PlatformFileForTransit file_desc = IPC::GetFileHandleForProcess(
- file,
- nacl_host_message_filter->PeerHandle(),
- true /* close_source */);
+ IPC::PlatformFileForTransit file_desc = IPC::TakeFileHandleForProcess(
+ file.Pass(),
+ nacl_host_message_filter->PeerHandle());
NaClHostMsg_OpenNaClExecutable::WriteReplyParams(
reply_msg, file_desc, file_token_lo, file_token_hi);
@@ -133,8 +122,8 @@ void DoOpenNaClExecutableOnThreadPool(
return;
}
- base::PlatformFile file = nacl::OpenNaClExecutableImpl(file_path);
- if (file != base::kInvalidPlatformFileValue) {
+ base::File file = nacl::OpenNaClExecutableImpl(file_path);
+ if (file.IsValid()) {
// This function is running on the blocking pool, but the path needs to be
// registered in a structure owned by the IO thread.
BrowserThread::PostTask(
@@ -142,7 +131,7 @@ void DoOpenNaClExecutableOnThreadPool(
base::Bind(
&DoRegisterOpenedNaClExecutableFile,
nacl_host_message_filter,
- file, file_path, reply_msg));
+ Passed(file.Pass()), file_path, reply_msg));
} else {
NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
« no previous file with comments | « components/nacl/browser/nacl_browser.cc ('k') | components/nacl/browser/nacl_host_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698