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

Unified Diff: ppapi/native_client/src/trusted/plugin/temporary_file.cc

Issue 10834173: Retry "Add an interface for PNaCl to check if the session is incognito..." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for compiler warnings. Created 8 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 | « ppapi/native_client/src/trusted/plugin/temporary_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/native_client/src/trusted/plugin/temporary_file.cc
diff --git a/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/ppapi/native_client/src/trusted/plugin/temporary_file.cc
index 4cdd04daee3558d5c978891ebda5bb02b889b497..fe8b779b52c0819054616fe682b79dc811317b26 100644
--- a/ppapi/native_client/src/trusted/plugin/temporary_file.cc
+++ b/ppapi/native_client/src/trusted/plugin/temporary_file.cc
@@ -69,16 +69,31 @@ void TempFile::Open(const pp::CompletionCallback& cb) {
return;
}
+ // dup the fd to make allow making a non-Quota-based wrapper.
+ // sel_ldr currently does not allow loading from Quota-backed descs,
+ // only plain host descs. It's probably good hygiene to separate the
+ // read wrapper from the write wrapper anyway.
+ int32_t read_fd = DUP(fd);
+ if (read_fd == NACL_NO_FILE_DESC) {
+ PLUGIN_PRINTF(("TempFile::Open DUP failed\n"));
+ core->CallOnMainThread(0, cb, PP_ERROR_FAILED);
+ return;
+ }
+
// The descriptor for a writeable file needs to have quota management.
- wrapper_.reset(
- plugin_->wrapper_factory()->MakeFileDescQuota(fd, O_RDWR, identifier_));
+ write_wrapper_.reset(
+ plugin_->wrapper_factory()->MakeFileDescQuota(fd, O_RDWR, identifier_));
+ read_wrapper_.reset(
+ plugin_->wrapper_factory()->MakeFileDesc(read_fd, O_RDONLY));
core->CallOnMainThread(0, cb, PP_OK);
}
bool TempFile::Reset() {
PLUGIN_PRINTF(("TempFile::Reset\n"));
- CHECK(wrapper_.get() != NULL);
- nacl_off64_t newpos = wrapper_->Seek(0, SEEK_SET);
+ // Use the write_wrapper_ to reset the file pos. The read_wrapper_ is also
+ // backed by the same file, so it should also reset.
+ CHECK(write_wrapper_.get() != NULL);
+ nacl_off64_t newpos = write_wrapper_->Seek(0, SEEK_SET);
return newpos >= 0;
}
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/temporary_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698