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

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

Issue 251883002: Replace FileUtilProxy with FileProxy on NaClBrowser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indentation Created 6 years, 8 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.h ('k') | components/nacl/browser/nacl_process_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/browser/nacl_browser.cc
diff --git a/components/nacl/browser/nacl_browser.cc b/components/nacl/browser/nacl_browser.cc
index f271af69b0f8c957fa9a914cc4baefba1102c9cd..84e710f84fcbecb7774a470b75fde934b8e49ef9 100644
--- a/components/nacl/browser/nacl_browser.cc
+++ b/components/nacl/browser/nacl_browser.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/files/file_proxy.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
@@ -140,7 +141,6 @@ base::File OpenNaClExecutableImpl(const base::FilePath& file_path) {
NaClBrowser::NaClBrowser()
: weak_factory_(this),
- irt_platform_file_(base::kInvalidPlatformFileValue),
irt_filepath_(),
irt_state_(NaClResourceUninitialized),
validation_cache_file_path_(),
@@ -172,8 +172,6 @@ void NaClBrowser::EarlyStartup() {
}
NaClBrowser::~NaClBrowser() {
- if (irt_platform_file_ != base::kInvalidPlatformFileValue)
- base::ClosePlatformFile(irt_platform_file_);
}
void NaClBrowser::InitIrtFilePath() {
@@ -224,11 +222,11 @@ bool NaClBrowser::IsOk() const {
return ok_;
}
-base::PlatformFile NaClBrowser::IrtFile() const {
+const base::File& NaClBrowser::IrtFile() const {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
CHECK_EQ(irt_state_, NaClResourceReady);
- CHECK_NE(irt_platform_file_, base::kInvalidPlatformFileValue);
- return irt_platform_file_;
+ CHECK(irt_file_.IsValid());
+ return irt_file_;
}
void NaClBrowser::EnsureAllResourcesAvailable() {
@@ -243,28 +241,27 @@ void NaClBrowser::EnsureIrtAvailable() {
if (IsOk() && irt_state_ == NaClResourceUninitialized) {
irt_state_ = NaClResourceRequested;
// TODO(ncbray) use blocking pool.
- if (!base::FileUtilProxy::CreateOrOpen(
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::FILE)
- .get(),
- irt_filepath_,
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
- base::Bind(&NaClBrowser::OnIrtOpened,
- weak_factory_.GetWeakPtr()))) {
+ scoped_ptr<base::FileProxy> file_proxy(new base::FileProxy(
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::FILE).get()));
+ base::FileProxy* proxy = file_proxy.get();
+ if (!proxy->CreateOrOpen(irt_filepath_,
+ base::File::FLAG_OPEN | base::File::FLAG_READ,
+ base::Bind(&NaClBrowser::OnIrtOpened,
+ weak_factory_.GetWeakPtr(),
+ Passed(&file_proxy)))) {
LOG(ERROR) << "Internal error, NaCl disabled.";
MarkAsFailed();
}
}
}
-void NaClBrowser::OnIrtOpened(base::File::Error error_code,
- base::PassPlatformFile file,
- bool created) {
+void NaClBrowser::OnIrtOpened(scoped_ptr<base::FileProxy> file_proxy,
+ base::File::Error error_code) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
DCHECK_EQ(irt_state_, NaClResourceRequested);
- DCHECK(!created);
- if (error_code == base::File::FILE_OK) {
- irt_platform_file_ = file.ReleaseValue();
+ if (file_proxy->IsValid()) {
+ irt_file_ = file_proxy->TakeFile();
} else {
LOG(ERROR) << "Failed to open NaCl IRT file \""
<< irt_filepath_.LossyDisplayName()
« no previous file with comments | « components/nacl/browser/nacl_browser.h ('k') | components/nacl/browser/nacl_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698