Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h

Issue 299143004: Pepper: TempFile cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Saner fd behavior Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PNACL_COORDINATOR_H_ 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_
7 7
8 #include <set> 8 #include <set>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // Other values indicate errors. 44 // Other values indicate errors.
45 // (3) After finish_callback runs, get the file descriptor of the translated 45 // (3) After finish_callback runs, get the file descriptor of the translated
46 // nexe, e.g., 46 // nexe, e.g.,
47 // fd = coord->ReleaseTranslatedFD(); 47 // fd = coord->ReleaseTranslatedFD();
48 // (4) Load the nexe from "fd". 48 // (4) Load the nexe from "fd".
49 // (5) delete coord. 49 // (5) delete coord.
50 // 50 //
51 // Translation proceeds in two steps: 51 // Translation proceeds in two steps:
52 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_. 52 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_.
53 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_. 53 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_.
54 //
55 // The coordinator proceeds through several states. They are
56 // OPEN_BITCODE_STREAM
57 // Complete when BitcodeStreamDidOpen is invoked
58 // LOAD_TRANSLATOR_BINARIES
59 // Complete when ResourcesDidLoad is invoked.
60 // GET_NEXE_FD
61 // Get an FD which contains the cached nexe, or is writeable for
62 // translation output. Complete when NexeFdDidOpen is called.
63 //
64 // If there was a cache hit, go to OPEN_NEXE_FOR_SEL_LDR, otherwise,
65 // continue streaming the bitcode, and:
66 // OPEN_TMP_FOR_LLC_TO_LD_COMMUNICATION
67 // Complete when ObjectFileDidOpen is invoked.
68 // OPEN_NEXE_FD_FOR_WRITING
69 // Complete when RunTranslate is invoked.
70 // START_LD_AND_LLC_SUBPROCESS_AND_INITIATE_TRANSLATION
71 // Complete when RunTranslate returns.
72 // TRANSLATION_COMPLETE
73 // Complete when TranslateFinished is invoked.
74 //
75 // OPEN_NEXE_FOR_SEL_LDR
76 // Complete when NexeReadDidOpen is invoked.
77 class PnaclCoordinator: public CallbackSource<FileStreamData> { 54 class PnaclCoordinator: public CallbackSource<FileStreamData> {
78 public: 55 public:
79 // Maximum number of object files passable to the translator. Cannot be 56 // Maximum number of object files passable to the translator. Cannot be
80 // changed without changing the RPC signatures. 57 // changed without changing the RPC signatures.
81 const static size_t kMaxTranslatorObjectFiles = 16; 58 const static size_t kMaxTranslatorObjectFiles = 16;
82 virtual ~PnaclCoordinator(); 59 virtual ~PnaclCoordinator();
83 60
84 // The factory method for translations. 61 // The factory method for translations.
85 static PnaclCoordinator* BitcodeToNative( 62 static PnaclCoordinator* BitcodeToNative(
86 Plugin* plugin, 63 Plugin* plugin,
87 const nacl::string& pexe_url, 64 const nacl::string& pexe_url,
88 const PP_PNaClOptions& pnacl_options, 65 const PP_PNaClOptions& pnacl_options,
89 const pp::CompletionCallback& translate_notify_callback); 66 const pp::CompletionCallback& translate_notify_callback);
90 67
91 // Call this to take ownership of the FD of the translated nexe after 68 // Call this to take ownership of the FD of the translated nexe after
92 // BitcodeToNative has completed (and the finish_callback called). 69 // BitcodeToNative has completed (and the finish_callback called).
93 nacl::DescWrapper* ReleaseTranslatedFD(); 70 PP_FileHandle TakeTranslatedFileHandle();
94 71
95 // Run |translate_notify_callback_| with an error condition that is not 72 // Run |translate_notify_callback_| with an error condition that is not
96 // PPAPI specific. Also set ErrorInfo report. 73 // PPAPI specific. Also set ErrorInfo report.
97 void ReportNonPpapiError(PP_NaClError err, const nacl::string& message); 74 void ReportNonPpapiError(PP_NaClError err, const nacl::string& message);
98 // Run when faced with a PPAPI error condition. Bring control back to the 75 // Run when faced with a PPAPI error condition. Bring control back to the
99 // plugin by invoking the |translate_notify_callback_|. 76 // plugin by invoking the |translate_notify_callback_|.
100 // Also set ErrorInfo report. 77 // Also set ErrorInfo report.
101 void ReportPpapiError(PP_NaClError err, 78 void ReportPpapiError(PP_NaClError err,
102 int32_t pp_error, const nacl::string& message); 79 int32_t pp_error, const nacl::string& message);
103 // Bring control back to the plugin by invoking the 80 // Bring control back to the plugin by invoking the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void ResourcesDidLoad(int32_t pp_error); 136 void ResourcesDidLoad(int32_t pp_error);
160 // Invoked when we've gotten a temp FD for the nexe, either with the nexe 137 // Invoked when we've gotten a temp FD for the nexe, either with the nexe
161 // data, or a writeable fd to save to. 138 // data, or a writeable fd to save to.
162 void NexeFdDidOpen(int32_t pp_error); 139 void NexeFdDidOpen(int32_t pp_error);
163 // Invoked when a pexe data chunk arrives (when using streaming translation) 140 // Invoked when a pexe data chunk arrives (when using streaming translation)
164 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data); 141 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data);
165 // Invoked when a pexe data chunk is compiled. 142 // Invoked when a pexe data chunk is compiled.
166 void BitcodeGotCompiled(int32_t pp_error, int64_t bytes_compiled); 143 void BitcodeGotCompiled(int32_t pp_error, int64_t bytes_compiled);
167 // Invoked when the pexe download finishes (using streaming translation) 144 // Invoked when the pexe download finishes (using streaming translation)
168 void BitcodeStreamDidFinish(int32_t pp_error); 145 void BitcodeStreamDidFinish(int32_t pp_error);
169 // Invoked when the write descriptor for obj_file_ is created.
170 void ObjectFileDidOpen(int32_t pp_error);
171 // Once llc and ld nexes have been loaded and the two temporary files have 146 // Once llc and ld nexes have been loaded and the two temporary files have
172 // been created, this starts the translation. Translation starts two 147 // been created, this starts the translation. Translation starts two
173 // subprocesses, one for llc and one for ld. 148 // subprocesses, one for llc and one for ld.
174 void RunTranslate(int32_t pp_error); 149 void RunTranslate(int32_t pp_error);
175 150
176 // Invoked when translation is finished. 151 // Invoked when translation is finished.
177 void TranslateFinished(int32_t pp_error); 152 void TranslateFinished(int32_t pp_error);
178 153
179 // Invoked when the read descriptor for nexe_file_ is created. 154 // Invoked when the read descriptor for nexe_file_ is created.
180 void NexeReadDidOpen(int32_t pp_error); 155 void NexeReadDidOpen(int32_t pp_error);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // The helper thread used to do translations via SRPC. 220 // The helper thread used to do translations via SRPC.
246 // It accesses fields of PnaclCoordinator so it must have a 221 // It accesses fields of PnaclCoordinator so it must have a
247 // shorter lifetime. 222 // shorter lifetime.
248 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; 223 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_;
249 }; 224 };
250 225
251 //---------------------------------------------------------------------- 226 //----------------------------------------------------------------------
252 227
253 } // namespace plugin; 228 } // namespace plugin;
254 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ 229 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.cc ('k') | ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698