| 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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ |
| 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ |
| 7 | 7 |
| 8 #include "native_client/src/include/nacl_macros.h" | 8 #include "native_client/src/include/nacl_macros.h" |
| 9 #include "native_client/src/include/nacl_string.h" | 9 #include "native_client/src/include/nacl_string.h" |
| 10 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 10 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 explicit TempFile(Plugin* plugin); | 40 explicit TempFile(Plugin* plugin); |
| 41 ~TempFile(); | 41 ~TempFile(); |
| 42 | 42 |
| 43 // Opens a writeable file IO object and descriptor referring to the file. | 43 // Opens a writeable file IO object and descriptor referring to the file. |
| 44 void Open(const pp::CompletionCallback& cb); | 44 void Open(const pp::CompletionCallback& cb); |
| 45 // Resets file position of the handle, for reuse. | 45 // Resets file position of the handle, for reuse. |
| 46 bool Reset(); | 46 bool Reset(); |
| 47 | 47 |
| 48 // Accessors. | 48 // Accessors. |
| 49 // The nacl::DescWrapper* for the writeable version of the file. | 49 // The nacl::DescWrapper* for the writeable version of the file. |
| 50 nacl::DescWrapper* get_wrapper() { return wrapper_.get(); } | 50 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } |
| 51 nacl::DescWrapper* release_wrapper() { | 51 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } |
| 52 return wrapper_.release(); | 52 nacl::DescWrapper* release_read_wrapper() { |
| 53 return read_wrapper_.release(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 // For quota management. | 56 // For quota management. |
| 56 const nacl::string identifier() const { | 57 const nacl::string identifier() const { |
| 57 return nacl::string(reinterpret_cast<const char*>(identifier_)); | 58 return nacl::string(reinterpret_cast<const char*>(identifier_)); |
| 58 } | 59 } |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); | 62 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); |
| 62 | 63 |
| 63 Plugin* plugin_; | 64 Plugin* plugin_; |
| 64 nacl::scoped_ptr<nacl::DescWrapper> wrapper_; | 65 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; |
| 66 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; |
| 65 | 67 |
| 66 // An identifier string used for quota request processing. The quota | 68 // An identifier string used for quota request processing. The quota |
| 67 // interface needs a string that is unique per sel_ldr instance only, so | 69 // interface needs a string that is unique per sel_ldr instance only, so |
| 68 // the identifiers can be reused between runs of the translator, start-ups of | 70 // the identifiers can be reused between runs of the translator, start-ups of |
| 69 // the browser, etc. | 71 // the browser, etc. |
| 70 uint8_t identifier_[16]; | 72 uint8_t identifier_[16]; |
| 71 // A counter to dole out unique identifiers. | 73 // A counter to dole out unique identifiers. |
| 72 static uint32_t next_identifier; | 74 static uint32_t next_identifier; |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace plugin | 77 } // namespace plugin |
| 76 | 78 |
| 77 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ | 79 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ |
| OLD | NEW |