| 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_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 20 matching lines...) Expand all Loading... |
| 31 #include "ppapi/cpp/file_ref.h" | 31 #include "ppapi/cpp/file_ref.h" |
| 32 #include "ppapi/cpp/file_system.h" | 32 #include "ppapi/cpp/file_system.h" |
| 33 | 33 |
| 34 | 34 |
| 35 namespace plugin { | 35 namespace plugin { |
| 36 | 36 |
| 37 class Manifest; | 37 class Manifest; |
| 38 class Plugin; | 38 class Plugin; |
| 39 class PnaclCoordinator; | 39 class PnaclCoordinator; |
| 40 class PnaclTranslateThread; | 40 class PnaclTranslateThread; |
| 41 class TempFile; |
| 41 | 42 |
| 42 // A class invoked by Plugin to handle PNaCl client-side translation. | 43 // A class invoked by Plugin to handle PNaCl client-side translation. |
| 43 // Usage: | 44 // Usage: |
| 44 // (1) Invoke the factory method, e.g., | 45 // (1) Invoke the factory method, e.g., |
| 45 // PnaclCoordinator* coord = BitcodeToNative(plugin, | 46 // PnaclCoordinator* coord = BitcodeToNative(plugin, |
| 46 // "http://foo.com/my.pexe", | 47 // "http://foo.com/my.pexe", |
| 47 // TranslateNotifyCallback); | 48 // TranslateNotifyCallback); |
| 48 // (2) TranslateNotifyCallback gets invoked when translation is complete. | 49 // (2) TranslateNotifyCallback gets invoked when translation is complete. |
| 49 // If the translation was successful, the pp_error argument is PP_OK. | 50 // If the translation was successful, the pp_error argument is PP_OK. |
| 50 // Other values indicate errors. | 51 // Other values indicate errors. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void FileSystemDidOpen(int32_t pp_error); | 147 void FileSystemDidOpen(int32_t pp_error); |
| 147 // Invoked after we are sure the PNaCl temporary directory exists. | 148 // Invoked after we are sure the PNaCl temporary directory exists. |
| 148 void DirectoryWasCreated(int32_t pp_error); | 149 void DirectoryWasCreated(int32_t pp_error); |
| 149 // Invoked after we have checked the PNaCl cache for a translated version. | 150 // Invoked after we have checked the PNaCl cache for a translated version. |
| 150 void CachedFileDidOpen(int32_t pp_error); | 151 void CachedFileDidOpen(int32_t pp_error); |
| 151 // Invoked when a pexe data chunk arrives (when using streaming translation) | 152 // Invoked when a pexe data chunk arrives (when using streaming translation) |
| 152 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data); | 153 void BitcodeStreamGotData(int32_t pp_error, FileStreamData data); |
| 153 // Invoked when the pexe download finishes (using streaming translation) | 154 // Invoked when the pexe download finishes (using streaming translation) |
| 154 void BitcodeStreamDidFinish(int32_t pp_error); | 155 void BitcodeStreamDidFinish(int32_t pp_error); |
| 155 // Invoked when the write descriptor for obj_file_ is created. | 156 // Invoked when the write descriptor for obj_file_ is created. |
| 156 void ObjectWriteDidOpen(int32_t pp_error); | 157 void ObjectFileDidOpen(int32_t pp_error); |
| 157 // Invoked when the read descriptor for obj_file_ is created. | |
| 158 void ObjectReadDidOpen(int32_t pp_error); | |
| 159 // Invoked when the descriptors for obj_file_ have been closed. | |
| 160 void ObjectFileWasClosed(int32_t pp_error); | |
| 161 // Invoked when the obj_file_ temporary has been deleted. | |
| 162 void ObjectFileWasDeleted(int32_t pp_error); | |
| 163 // Invoked when the descriptors for nexe_file_ have been closed. | 158 // Invoked when the descriptors for nexe_file_ have been closed. |
| 164 void NexeFileWasClosed(int32_t pp_error); | 159 void NexeFileWasClosed(int32_t pp_error); |
| 165 // Invoked when the nexe_file_ temporary has been renamed to the nexe name. | 160 // Invoked when the nexe_file_ temporary has been renamed to the nexe name. |
| 166 void NexeFileWasRenamed(int32_t pp_error); | 161 void NexeFileWasRenamed(int32_t pp_error); |
| 167 // Invoked when the read descriptor for nexe_file_ is created. | 162 // Invoked when the read descriptor for nexe_file_ is created. |
| 168 void NexeReadDidOpen(int32_t pp_error); | 163 void NexeReadDidOpen(int32_t pp_error); |
| 169 // Invoked if there was an error and we've cleaned up the nexe_file_ temp. | 164 // Invoked if there was an error and we've cleaned up the nexe_file_ temp. |
| 170 void NexeFileWasDeleted(int32_t pp_error); | 165 void NexeFileWasDeleted(int32_t pp_error); |
| 171 | 166 |
| 167 void TestFileWrapper(const nacl::string& prefix, |
| 168 nacl::DescWrapper* wrapper); |
| 169 |
| 172 // Once llc and ld nexes have been loaded and the two temporary files have | 170 // Once llc and ld nexes have been loaded and the two temporary files have |
| 173 // been created, this starts the translation. Translation starts two | 171 // been created, this starts the translation. Translation starts two |
| 174 // subprocesses, one for llc and one for ld. | 172 // subprocesses, one for llc and one for ld. |
| 175 void RunTranslate(int32_t pp_error); | 173 void RunTranslate(int32_t pp_error); |
| 176 | 174 |
| 177 void TranslateFinished(int32_t pp_error); | 175 void TranslateFinished(int32_t pp_error); |
| 178 // Keeps track of the pp_error upon entry to TranslateFinished, | 176 // Keeps track of the pp_error upon entry to TranslateFinished, |
| 179 // for inspection after cleanup. | 177 // for inspection after cleanup. |
| 180 int32_t translate_finish_error_; | 178 int32_t translate_finish_error_; |
| 181 | 179 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 206 nacl::scoped_ptr<PnaclResources> resources_; | 204 nacl::scoped_ptr<PnaclResources> resources_; |
| 207 | 205 |
| 208 // State used for querying the temporary directory. | 206 // State used for querying the temporary directory. |
| 209 nacl::scoped_ptr<pp::FileRef> dir_ref_; | 207 nacl::scoped_ptr<pp::FileRef> dir_ref_; |
| 210 | 208 |
| 211 // The URL for the pexe file. | 209 // The URL for the pexe file. |
| 212 nacl::string pexe_url_; | 210 nacl::string pexe_url_; |
| 213 // Optional cache identity for translation caching. | 211 // Optional cache identity for translation caching. |
| 214 nacl::string cache_identity_; | 212 nacl::string cache_identity_; |
| 215 // Object file, produced by the translator and consumed by the linker. | 213 // Object file, produced by the translator and consumed by the linker. |
| 216 nacl::scoped_ptr<LocalTempFile> obj_file_; | 214 nacl::scoped_ptr<TempFile> obj_file_; |
| 217 // Translated nexe file, produced by the linker and consumed by sel_ldr. | 215 // Translated nexe file, produced by the linker and consumed by sel_ldr. |
| 218 nacl::scoped_ptr<LocalTempFile> nexe_file_; | 216 nacl::scoped_ptr<LocalTempFile> nexe_file_; |
| 219 | 217 |
| 220 // Downloader for streaming translation | 218 // Downloader for streaming translation |
| 221 nacl::scoped_ptr<FileDownloader> streaming_downloader_; | 219 nacl::scoped_ptr<FileDownloader> streaming_downloader_; |
| 222 | 220 |
| 223 // Used to report information when errors (PPAPI or otherwise) are reported. | 221 // Used to report information when errors (PPAPI or otherwise) are reported. |
| 224 ErrorInfo error_info_; | 222 ErrorInfo error_info_; |
| 225 // True if an error was already reported, and translate_notify_callback_ | 223 // True if an error was already reported, and translate_notify_callback_ |
| 226 // was already run/consumed. | 224 // was already run/consumed. |
| 227 bool error_already_reported_; | 225 bool error_already_reported_; |
| 228 | 226 |
| 229 // The helper thread used to do translations via SRPC. | 227 // The helper thread used to do translations via SRPC. |
| 230 // Keep this last in declaration order to ensure the other variables | 228 // Keep this last in declaration order to ensure the other variables |
| 231 // haven't been destroyed yet when its destructor runs. | 229 // haven't been destroyed yet when its destructor runs. |
| 232 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; | 230 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; |
| 233 | 231 |
| 234 }; | 232 }; |
| 235 | 233 |
| 236 //---------------------------------------------------------------------- | 234 //---------------------------------------------------------------------- |
| 237 | 235 |
| 238 } // namespace plugin; | 236 } // namespace plugin; |
| 239 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ | 237 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ |
| OLD | NEW |