| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" | 5 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/portability_io.h" | 7 #include "native_client/src/include/portability_io.h" |
| 8 #include "native_client/src/shared/platform/nacl_check.h" | 8 #include "native_client/src/shared/platform/nacl_check.h" |
| 9 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" | 9 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace plugin { | 24 namespace plugin { |
| 25 | 25 |
| 26 uint32_t TempFile::next_identifier = 0; | 26 uint32_t TempFile::next_identifier = 0; |
| 27 | 27 |
| 28 TempFile::TempFile(Plugin* plugin) : plugin_(plugin), | 28 TempFile::TempFile(Plugin* plugin) : plugin_(plugin), |
| 29 existing_handle_(PP_kInvalidFileHandle) { | 29 existing_handle_(PP_kInvalidFileHandle) { |
| 30 PLUGIN_PRINTF(("TempFile::TempFile\n")); | 30 PLUGIN_PRINTF(("TempFile::TempFile\n")); |
| 31 ++next_identifier; | 31 ++next_identifier; |
| 32 SNPRINTF(reinterpret_cast<char *>(identifier_), sizeof identifier_, | 32 SNPRINTF(reinterpret_cast<char *>(identifier_), sizeof identifier_, |
| 33 "%"NACL_PRIu32, next_identifier); | 33 "%" NACL_PRIu32, next_identifier); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TempFile::~TempFile() { | 36 TempFile::~TempFile() { |
| 37 PLUGIN_PRINTF(("TempFile::~TempFile\n")); | 37 PLUGIN_PRINTF(("TempFile::~TempFile\n")); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool TempFile::SetExistingFd(PP_FileHandle handle) { | 40 bool TempFile::SetExistingFd(PP_FileHandle handle) { |
| 41 // Check if we got a bad handle or if Open has already been called. | 41 // Check if we got a bad handle or if Open has already been called. |
| 42 if (handle == PP_kInvalidFileHandle || read_wrapper_.get() != NULL) | 42 if (handle == PP_kInvalidFileHandle || read_wrapper_.get() != NULL) |
| 43 return false; | 43 return false; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 bool TempFile::Reset() { | 109 bool TempFile::Reset() { |
| 110 PLUGIN_PRINTF(("TempFile::Reset\n")); | 110 PLUGIN_PRINTF(("TempFile::Reset\n")); |
| 111 // Use the read_wrapper_ to reset the file pos. The write_wrapper_ is also | 111 // Use the read_wrapper_ to reset the file pos. The write_wrapper_ is also |
| 112 // backed by the same file, so it should also reset. | 112 // backed by the same file, so it should also reset. |
| 113 CHECK(read_wrapper_.get() != NULL); | 113 CHECK(read_wrapper_.get() != NULL); |
| 114 nacl_off64_t newpos = read_wrapper_->Seek(0, SEEK_SET); | 114 nacl_off64_t newpos = read_wrapper_->Seek(0, SEEK_SET); |
| 115 return newpos >= 0; | 115 return newpos >= 0; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace plugin | 118 } // namespace plugin |
| OLD | NEW |