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

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

Issue 10834173: Retry "Add an interface for PNaCl to check if the session is incognito..." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for compiler warnings. Created 8 years, 4 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // (4) Load the nexe from "fd". 55 // (4) Load the nexe from "fd".
56 // (5) delete coord. 56 // (5) delete coord.
57 // 57 //
58 // Translation proceeds in two steps: 58 // Translation proceeds in two steps:
59 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_. 59 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_.
60 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_. 60 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_.
61 // 61 //
62 // The coordinator proceeds through several states. They are 62 // The coordinator proceeds through several states. They are
63 // LOAD_TRANSLATOR_BINARIES 63 // LOAD_TRANSLATOR_BINARIES
64 // Complete when ResourcesDidLoad is invoked. 64 // Complete when ResourcesDidLoad is invoked.
65 // OPEN_LOCAL_FILE_SYSTEM 65 //
66 // Complete when FileSystemDidOpen is invoked. 66 // If cache is enabled:
67 // CREATED_PNACL_TEMP_DIRECTORY 67 // OPEN_LOCAL_FILE_SYSTEM
68 // Complete when DirectoryWasCreated is invoked. 68 // Complete when FileSystemDidOpen is invoked.
69 // CACHED_FILE_OPEN 69 // CREATED_PNACL_TEMP_DIRECTORY
70 // Complete with success if cached version is available and jump to end. 70 // Complete when DirectoryWasCreated is invoked.
71 // Otherwise, proceed with usual pipeline of translation. 71 // CACHED_FILE_OPEN
72 // OPEN_TMP_WRITE_FOR_LLC_TO_LD_COMMUNICATION 72 // Complete with success if cached version is available and jump to end.
73 // Complete when ObjectWriteDidOpen is invoked. 73 // Otherwise, proceed with usual pipeline of translation.
74 // OPEN_TMP_READ_FOR_LLC_TO_LD_COMMUNICATION 74 //
75 // Complete when ObjectReadDidOpen is invoked. 75 // OPEN_TMP_FOR_LLC_TO_LD_COMMUNICATION
76 // Complete when ObjectFileDidOpen is invoked.
76 // OPEN_TMP_FOR_LD_WRITING 77 // OPEN_TMP_FOR_LD_WRITING
77 // Complete when NexeWriteDidOpen is invoked. 78 // Complete when NexeWriteDidOpen is invoked.
78 // PREPARE_PEXE_FOR_STREAMING 79 // PREPARE_PEXE_FOR_STREAMING
79 // Complete when RunTranslate is invoked. 80 // Complete when RunTranslate is invoked.
80 // START_LD_AND_LLC_SUBPROCESS_AND_INITIATE_TRANSLATION 81 // START_LD_AND_LLC_SUBPROCESS_AND_INITIATE_TRANSLATION
81 // Complete when RunTranslate returns. 82 // Complete when RunTranslate returns.
82 // TRANSLATION_COMPLETE 83 // TRANSLATION_COMPLETE
83 // Complete when TranslateFinished is invoked. 84 // Complete when TranslateFinished is invoked.
84 // CLOSE_OBJECT_FILE 85 //
85 // Complete when ObjectFileWasClosed is invoked. 86 // If cache is enabled:
86 // DELETE_OBJECT_FILE 87 // OPEN_CACHE_FOR_WRITE
87 // Complete when ObjectFileWasDeleted is invoked. 88 // Complete when CachedNexeOpenedForWrite is invoked
88 // CLOSE_NEXE_FILE 89 // COPY_NEXE_TO_CACHE
89 // Complete when NexeFileWasClosed is invoked. 90 // Complete when NexeWasCopiedToCache is invoked.
90 // RENAME_NEXE_FILE 91 // RENAME_CACHE_FILE
91 // Complete when NexeFileWasRenamed is invoked. 92 // Complete when NexeFileWasRenamed is invoked.
93 //
92 // OPEN_NEXE_FOR_SEL_LDR 94 // OPEN_NEXE_FOR_SEL_LDR
93 // Complete when NexeReadDidOpen is invoked. 95 // Complete when NexeReadDidOpen is invoked.
94 class PnaclCoordinator: public CallbackSource<FileStreamData> { 96 class PnaclCoordinator: public CallbackSource<FileStreamData> {
95 public: 97 public:
96 virtual ~PnaclCoordinator(); 98 virtual ~PnaclCoordinator();
97 99
98 // The factory method for translations. 100 // The factory method for translations.
99 static PnaclCoordinator* BitcodeToNative( 101 static PnaclCoordinator* BitcodeToNative(
100 Plugin* plugin, 102 Plugin* plugin,
101 const nacl::string& pexe_url, 103 const nacl::string& pexe_url,
102 const nacl::string& cache_identity, 104 const nacl::string& cache_identity,
103 const pp::CompletionCallback& translate_notify_callback); 105 const pp::CompletionCallback& translate_notify_callback);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Invoked after we are sure the PNaCl temporary directory exists. 150 // Invoked after we are sure the PNaCl temporary directory exists.
149 void DirectoryWasCreated(int32_t pp_error); 151 void DirectoryWasCreated(int32_t pp_error);
150 // Invoked after we have checked the PNaCl cache for a translated version. 152 // Invoked after we have checked the PNaCl cache for a translated version.
151 void CachedFileDidOpen(int32_t pp_error); 153 void CachedFileDidOpen(int32_t pp_error);
152 // Invoked when a pexe data chunk arrives (when using streaming translation) 154 // Invoked when a pexe data chunk arrives (when using streaming translation)
153 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data); 155 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data);
154 // Invoked when the pexe download finishes (using streaming translation) 156 // Invoked when the pexe download finishes (using streaming translation)
155 void BitcodeStreamDidFinish(int32_t pp_error); 157 void BitcodeStreamDidFinish(int32_t pp_error);
156 // Invoked when the write descriptor for obj_file_ is created. 158 // Invoked when the write descriptor for obj_file_ is created.
157 void ObjectFileDidOpen(int32_t pp_error); 159 void ObjectFileDidOpen(int32_t pp_error);
158 // Invoked when the descriptors for nexe_file_ have been closed.
159 void NexeFileWasClosed(int32_t pp_error);
160 // Invoked when the nexe_file_ temporary has been renamed to the nexe name.
161 void NexeFileWasRenamed(int32_t pp_error);
162 // Invoked when the read descriptor for nexe_file_ is created.
163 void NexeReadDidOpen(int32_t pp_error);
164 // Invoked if there was an error and we've cleaned up the nexe_file_ temp.
165 void NexeFileWasDeleted(int32_t pp_error);
166
167 // Once llc and ld nexes have been loaded and the two temporary files have 160 // Once llc and ld nexes have been loaded and the two temporary files have
168 // been created, this starts the translation. Translation starts two 161 // been created, this starts the translation. Translation starts two
169 // subprocesses, one for llc and one for ld. 162 // subprocesses, one for llc and one for ld.
170 void RunTranslate(int32_t pp_error); 163 void RunTranslate(int32_t pp_error);
171 164
165 // Invoked when translation is finished.
172 void TranslateFinished(int32_t pp_error); 166 void TranslateFinished(int32_t pp_error);
167
168 // If the cache is enabled, open a cache file for write, then copy
169 // the nexe data from temp_nexe_file_ to> cached_nexe_file_.
170 // Once the copy is done, we commit it to the cache by renaming the
171 // cache file to the final name.
172 void CachedNexeOpenedForWrite(int32_t pp_error);
173 void DidCopyNexeToCachePartial(int32_t pp_error, int32_t num_read_prev,
174 int64_t cur_offset);
175 void NexeWasCopiedToCache(int32_t pp_error);
176 // Invoked when the nexe_file_ temporary has been renamed to the nexe name.
177 void NexeFileWasRenamed(int32_t pp_error);
178 // Invoked when the read descriptor for nexe_file_ is created.
179 void NexeReadDidOpen(int32_t pp_error);
180
173 // Keeps track of the pp_error upon entry to TranslateFinished, 181 // Keeps track of the pp_error upon entry to TranslateFinished,
174 // for inspection after cleanup. 182 // for inspection after cleanup.
175 int32_t translate_finish_error_; 183 int32_t translate_finish_error_;
176 184
177 // The plugin owning the nexe for which we are doing translation. 185 // The plugin owning the nexe for which we are doing translation.
178 Plugin* plugin_; 186 Plugin* plugin_;
179 187
180 pp::CompletionCallback translate_notify_callback_; 188 pp::CompletionCallback translate_notify_callback_;
181 // Threadsafety is required to support file lookups. 189 // Threadsafety is required to support file lookups.
182 pp::CompletionCallbackFactory<PnaclCoordinator, 190 pp::CompletionCallbackFactory<PnaclCoordinator,
(...skipping 19 matching lines...) Expand all
202 210
203 // State used for querying the temporary directory. 211 // State used for querying the temporary directory.
204 nacl::scoped_ptr<pp::FileRef> dir_ref_; 212 nacl::scoped_ptr<pp::FileRef> dir_ref_;
205 213
206 // The URL for the pexe file. 214 // The URL for the pexe file.
207 nacl::string pexe_url_; 215 nacl::string pexe_url_;
208 // Optional cache identity for translation caching. 216 // Optional cache identity for translation caching.
209 nacl::string cache_identity_; 217 nacl::string cache_identity_;
210 // Object file, produced by the translator and consumed by the linker. 218 // Object file, produced by the translator and consumed by the linker.
211 nacl::scoped_ptr<TempFile> obj_file_; 219 nacl::scoped_ptr<TempFile> obj_file_;
212 // Translated nexe file, produced by the linker and consumed by sel_ldr. 220 // Translated nexe file, produced by the linker.
213 nacl::scoped_ptr<LocalTempFile> nexe_file_; 221 nacl::scoped_ptr<TempFile> temp_nexe_file_;
222 // Cached nexe file, consumed by sel_ldr. This will be NULL if we do
223 // not have a writeable cache file. That is currently the case when
224 // off_the_record_ is true.
225 nacl::scoped_ptr<LocalTempFile> cached_nexe_file_;
214 226
215 // Downloader for streaming translation 227 // Downloader for streaming translation
216 nacl::scoped_ptr<FileDownloader> streaming_downloader_; 228 nacl::scoped_ptr<FileDownloader> streaming_downloader_;
217 229
218 // Used to report information when errors (PPAPI or otherwise) are reported. 230 // Used to report information when errors (PPAPI or otherwise) are reported.
219 ErrorInfo error_info_; 231 ErrorInfo error_info_;
220 // True if an error was already reported, and translate_notify_callback_ 232 // True if an error was already reported, and translate_notify_callback_
221 // was already run/consumed. 233 // was already run/consumed.
222 bool error_already_reported_; 234 bool error_already_reported_;
223 235
236 // True if compilation is off_the_record.
237 bool off_the_record_;
238
224 // The helper thread used to do translations via SRPC. 239 // The helper thread used to do translations via SRPC.
225 // Keep this last in declaration order to ensure the other variables 240 // Keep this last in declaration order to ensure the other variables
226 // haven't been destroyed yet when its destructor runs. 241 // haven't been destroyed yet when its destructor runs.
227 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; 242 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_;
228 243
229 }; 244 };
230 245
231 //---------------------------------------------------------------------- 246 //----------------------------------------------------------------------
232 247
233 } // namespace plugin; 248 } // namespace plugin;
234 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ 249 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/local_temp_file.h ('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