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/trusted/desc/nacl_desc_wrapper.h" | 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
10 | 10 |
11 #include "ppapi/c/private/pp_file_handle.h" | 11 #include "ppapi/c/private/pp_file_handle.h" |
12 #include "ppapi/cpp/completion_callback.h" | |
13 | 12 |
14 namespace plugin { | 13 namespace plugin { |
15 | 14 |
16 class Plugin; | 15 class Plugin; |
17 | 16 |
18 // Translation creates two temporary files. The first temporary file holds | 17 // Translation creates two temporary files. The first temporary file holds |
19 // the object file created by llc. The second holds the nexe produced by | 18 // the object file created by llc. The second holds the nexe produced by |
20 // the linker. Both of these temporary files are used to both write and | 19 // the linker. Both of these temporary files are used to both write and |
21 // read according to the following matrix: | 20 // read according to the following matrix: |
22 // | 21 // |
(...skipping 13 matching lines...) Expand all Loading... |
36 // of the file between sessions. | 35 // of the file between sessions. |
37 class TempFile { | 36 class TempFile { |
38 public: | 37 public: |
39 // Create a TempFile. | 38 // Create a TempFile. |
40 explicit TempFile(Plugin* plugin); | 39 explicit TempFile(Plugin* plugin); |
41 ~TempFile(); | 40 ~TempFile(); |
42 | 41 |
43 // Opens a temporary file object and descriptor wrapper referring to the file. | 42 // Opens a temporary file object and descriptor wrapper referring to the file. |
44 // If |writeable| is true, the descriptor will be opened for writing, and | 43 // If |writeable| is true, the descriptor will be opened for writing, and |
45 // write_wrapper will return a valid pointer, otherwise it will return NULL. | 44 // write_wrapper will return a valid pointer, otherwise it will return NULL. |
46 void Open(const pp::CompletionCallback& cb, bool writeable); | 45 int32_t Open(bool writeable); |
47 // Resets file position of the handle, for reuse. | 46 // Resets file position of the handle, for reuse. |
48 bool Reset(); | 47 bool Reset(); |
49 | 48 |
50 // Accessors. | 49 // Accessors. |
51 // The nacl::DescWrapper* for the writeable version of the file. | 50 // The nacl::DescWrapper* for the writeable version of the file. |
52 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } | 51 nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } |
53 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } | 52 nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } |
54 nacl::DescWrapper* release_read_wrapper() { | |
55 return read_wrapper_.release(); | |
56 } | |
57 | 53 |
58 PP_FileHandle* existing_handle() { return &existing_handle_; } | 54 // Returns the handle to the file repesented and resets the internal handle |
| 55 // and all wrappers. |
| 56 PP_FileHandle TakeFileHandle(); |
| 57 |
| 58 // Used by GetNexeFd() to set the underlying internal handle. |
| 59 PP_FileHandle* internal_handle() { return &internal_handle_; } |
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> read_wrapper_; | 65 nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; |
65 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; | 66 nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; |
66 PP_FileHandle existing_handle_; | 67 PP_FileHandle internal_handle_; |
67 }; | 68 }; |
68 | 69 |
69 } // namespace plugin | 70 } // namespace plugin |
70 | 71 |
71 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ | 72 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_TEMPORARY_FILE_H_ |
OLD | NEW |