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