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" | |
10 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
11 | 10 |
12 #include "ppapi/c/private/pp_file_handle.h" | 11 #include "ppapi/c/private/pp_file_handle.h" |
13 #include "ppapi/cpp/completion_callback.h" | 12 #include "ppapi/cpp/completion_callback.h" |
14 | 13 |
15 namespace plugin { | 14 namespace plugin { |
16 | 15 |
17 class Plugin; | 16 class Plugin; |
18 | 17 |
19 // Translation creates two temporary files. The first temporary file holds | 18 // Translation creates two temporary files. The first temporary file holds |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // Accessors. | 50 // Accessors. |
52 // The nacl::DescWrapper* for the writeable version of the file. | 51 // The nacl::DescWrapper* for the writeable version of the file. |
53 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } | 52 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } |
54 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } | 53 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } |
55 nacl::DescWrapper* release_read_wrapper() { | 54 nacl::DescWrapper* release_read_wrapper() { |
56 return read_wrapper_.release(); | 55 return read_wrapper_.release(); |
57 } | 56 } |
58 | 57 |
59 PP_FileHandle* existing_handle() { return &existing_handle_; } | 58 PP_FileHandle* existing_handle() { return &existing_handle_; } |
60 | 59 |
61 // For quota management. | |
62 const nacl::string identifier() const { | |
63 return nacl::string(reinterpret_cast<const char*>(identifier_)); | |
64 } | |
65 | |
66 private: | 60 private: |
67 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); | 61 NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); |
68 | 62 |
69 Plugin* plugin_; | 63 Plugin* plugin_; |
70 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; | 64 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; |
71 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; | 65 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; |
72 PP_FileHandle existing_handle_; | 66 PP_FileHandle existing_handle_; |
73 | |
74 // An identifier string used for quota request processing. The quota | |
75 // interface needs a string that is unique per sel_ldr instance only, so | |
76 // the identifiers can be reused between runs of the translator, start-ups of | |
77 // the browser, etc. | |
78 uint8_t identifier_[16]; | |
79 // A counter to dole out unique identifiers. | |
80 static uint32_t next_identifier; | |
81 }; | 67 }; |
82 | 68 |
83 } // namespace plugin | 69 } // namespace plugin |
84 | 70 |
85 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ | 71 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ |
OLD | NEW |