summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/nacl/renderer/plugin/pnacl_coordinator.cc10
-rw-r--r--components/nacl/renderer/plugin/temporary_file.cc12
-rw-r--r--components/nacl/renderer/plugin/temporary_file.h3
3 files changed, 12 insertions, 13 deletions
diff --git a/components/nacl/renderer/plugin/pnacl_coordinator.cc b/components/nacl/renderer/plugin/pnacl_coordinator.cc
index 28caad5..f80a465 100644
--- a/components/nacl/renderer/plugin/pnacl_coordinator.cc
+++ b/components/nacl/renderer/plugin/pnacl_coordinator.cc
@@ -14,8 +14,6 @@
#include "components/nacl/renderer/plugin/pnacl_translate_thread.h"
#include "components/nacl/renderer/plugin/service_runtime.h"
#include "components/nacl/renderer/plugin/temporary_file.h"
-#include "native_client/src/include/portability_io.h"
-#include "native_client/src/trusted/service_runtime/include/sys/stat.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_errors.h"
@@ -202,13 +200,7 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
pexe_bytes_compiled_,
expected_pexe_size_);
}
- nacl_abi_off_t nexe_size = 0;
- struct nacl_abi_stat stbuf;
- struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc();
- if (0 == (*((struct NaClDescVtbl const *)desc->base.vtbl)->Fstat)(desc,
- &stbuf)) {
- nexe_size = stbuf.nacl_abi_st_size;
- }
+ int64_t nexe_size = temp_nexe_file_->GetLength();
// The nexe is written to the temp_nexe_file_. We must Reset() the file
// pointer to be able to read it again from the beginning.
temp_nexe_file_->Reset();
diff --git a/components/nacl/renderer/plugin/temporary_file.cc b/components/nacl/renderer/plugin/temporary_file.cc
index bd942c5..579352d 100644
--- a/components/nacl/renderer/plugin/temporary_file.cc
+++ b/components/nacl/renderer/plugin/temporary_file.cc
@@ -54,13 +54,17 @@ int32_t TempFile::Open(bool writeable) {
}
bool TempFile::Reset() {
- // Use the read_wrapper_ to reset the file pos. The write_wrapper_ is also
- // backed by the same file, so it should also reset.
- CHECK(read_wrapper_);
- nacl_off64_t newpos = read_wrapper_->Seek(0, SEEK_SET);
+ // file_handle_, read_wrapper_ and write_wrapper_ are all backed by the
+ // same file handle/descriptor, so resetting the seek position of one
+ // will reset them all.
+ int64_t newpos = file_handle_.Seek(base::File::FROM_BEGIN, 0);
return newpos == 0;
}
+int64_t TempFile::GetLength() {
+ return file_handle_.GetLength();
+}
+
PP_FileHandle TempFile::TakeFileHandle() {
DCHECK(file_handle_.IsValid());
return file_handle_.TakePlatformFile();
diff --git a/components/nacl/renderer/plugin/temporary_file.h b/components/nacl/renderer/plugin/temporary_file.h
index 4e4e9af..21663e3 100644
--- a/components/nacl/renderer/plugin/temporary_file.h
+++ b/components/nacl/renderer/plugin/temporary_file.h
@@ -51,6 +51,9 @@ class TempFile {
// Resets file position of the handle, for reuse.
bool Reset();
+ // Returns the current size of this file.
+ int64_t GetLength();
+
// Accessors.
// The nacl::DescWrapper* for the writeable version of the file.
nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); }