| 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 COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ | 5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ |
| 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ | 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "components/nacl/renderer/plugin/nacl_subprocess.h" | 10 #include "components/nacl/renderer/plugin/nacl_subprocess.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class PnaclCoordinator; | 25 class PnaclCoordinator; |
| 26 class PnaclTranslateThread; | 26 class PnaclTranslateThread; |
| 27 class TempFile; | 27 class TempFile; |
| 28 | 28 |
| 29 // A class invoked by Plugin to handle PNaCl client-side translation. | 29 // A class invoked by Plugin to handle PNaCl client-side translation. |
| 30 // Usage: | 30 // Usage: |
| 31 // (1) Invoke the factory method, e.g., | 31 // (1) Invoke the factory method, e.g., |
| 32 // PnaclCoordinator* coord = BitcodeToNative(plugin, | 32 // PnaclCoordinator* coord = BitcodeToNative(plugin, |
| 33 // "http://foo.com/my.pexe", | 33 // "http://foo.com/my.pexe", |
| 34 // pnacl_options, | 34 // pnacl_options, |
| 35 // TranslateNotifyCallback); | 35 // translate_notify_callback); |
| 36 // (2) TranslateNotifyCallback gets invoked when translation is complete. | 36 // (2) translate_notify_callback gets invoked when translation is complete. |
| 37 // If the translation was successful, the pp_error argument is PP_OK. | 37 // If the translation was successful, the pp_error argument is PP_OK. |
| 38 // Other values indicate errors. | 38 // Other values indicate errors. |
| 39 // (3) After finish_callback runs, get the file descriptor of the translated | 39 // (3) After finish_callback runs, get the file descriptor of the translated |
| 40 // nexe, e.g., | 40 // nexe, e.g., |
| 41 // fd = coord->ReleaseTranslatedFD(); | 41 // fd = coord->TakeTranslatedFileHandle(); |
| 42 // (4) Load the nexe from "fd". | 42 // (4) Load the nexe from "fd". |
| 43 // (5) delete coord. | 43 // (5) delete coord. |
| 44 // | 44 // |
| 45 // Translation proceeds in two steps: | 45 // Translation proceeds in two steps: |
| 46 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_. | 46 // (1) llc translates the bitcode in pexe_url_ to an object in obj_file_. |
| 47 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_. | 47 // (2) ld links the object code in obj_file_ and produces a nexe in nexe_file_. |
| 48 class PnaclCoordinator { | 48 class PnaclCoordinator { |
| 49 public: | 49 public: |
| 50 // Maximum number of object files passable to the translator. Cannot be | 50 // Maximum number of object files passable to the translator. Cannot be |
| 51 // changed without changing the RPC signatures. | 51 // changed without changing the RPC signatures. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const pp::CompletionCallback& translate_notify_callback); | 99 const pp::CompletionCallback& translate_notify_callback); |
| 100 | 100 |
| 101 // Invoke to issue a GET request for bitcode. | 101 // Invoke to issue a GET request for bitcode. |
| 102 void OpenBitcodeStream(); | 102 void OpenBitcodeStream(); |
| 103 | 103 |
| 104 // Invoked when a pexe data chunk is compiled. | 104 // Invoked when a pexe data chunk is compiled. |
| 105 void BitcodeGotCompiled(int32_t pp_error, int64_t bytes_compiled); | 105 void BitcodeGotCompiled(int32_t pp_error, int64_t bytes_compiled); |
| 106 // Once llc and ld nexes have been loaded and the two temporary files have | 106 // Once llc and ld nexes have been loaded and the two temporary files have |
| 107 // been created, this starts the translation. Translation starts two | 107 // been created, this starts the translation. Translation starts two |
| 108 // subprocesses, one for llc and one for ld. | 108 // subprocesses, one for llc and one for ld. |
| 109 void RunTranslate(int32_t pp_error); | 109 void LoadCompiler(int32_t pp_error); |
| 110 void RunCompile(int32_t pp_error, int64_t compile_load_start_time); |
| 111 void LoadLinker(int32_t pp_error); |
| 112 void RunLink(int32_t pp_error, int64_t ld_load_start_time); |
| 110 | 113 |
| 111 // Invoked when translation is finished. | 114 // Invoked when translation is finished. |
| 112 void TranslateFinished(int32_t pp_error); | 115 void TranslateFinished(int32_t pp_error); |
| 113 | 116 |
| 114 // Invoked when the read descriptor for nexe_file_ is created. | 117 // Invoked when the read descriptor for nexe_file_ is created. |
| 115 void NexeReadDidOpen(int32_t pp_error); | 118 void NexeReadDidOpen(int32_t pp_error); |
| 116 | 119 |
| 117 // Bring control back to the plugin by invoking the | 120 // Bring control back to the plugin by invoking the |
| 118 // |translate_notify_callback_|. This does not set the ErrorInfo report, | 121 // |translate_notify_callback_|. This does not set the ErrorInfo report, |
| 119 // it is assumed that it was already set. | 122 // it is assumed that it was already set. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 141 // notified via ReportTranslationFinished. If it is not set before | 144 // notified via ReportTranslationFinished. If it is not set before |
| 142 // plugin/coordinator destruction, the destructor will call | 145 // plugin/coordinator destruction, the destructor will call |
| 143 // ReportTranslationFinished. | 146 // ReportTranslationFinished. |
| 144 bool translation_finished_reported_; | 147 bool translation_finished_reported_; |
| 145 // Threadsafety is required to support file lookups. | 148 // Threadsafety is required to support file lookups. |
| 146 pp::CompletionCallbackFactory<PnaclCoordinator, | 149 pp::CompletionCallbackFactory<PnaclCoordinator, |
| 147 pp::ThreadSafeThreadTraits> callback_factory_; | 150 pp::ThreadSafeThreadTraits> callback_factory_; |
| 148 | 151 |
| 149 // An auxiliary class that manages downloaded resources (llc and ld nexes). | 152 // An auxiliary class that manages downloaded resources (llc and ld nexes). |
| 150 nacl::scoped_ptr<PnaclResources> resources_; | 153 nacl::scoped_ptr<PnaclResources> resources_; |
| 154 NaClSubprocess compiler_subprocess_; |
| 155 NaClSubprocess ld_subprocess_; |
| 151 | 156 |
| 152 // The URL for the pexe file. | 157 // The URL for the pexe file. |
| 153 std::string pexe_url_; | 158 std::string pexe_url_; |
| 154 // Options for translation. | 159 // Options for translation. |
| 155 PP_PNaClOptions pnacl_options_; | 160 PP_PNaClOptions pnacl_options_; |
| 156 // Architecture-specific attributes used for translation. These are | 161 // Architecture-specific attributes used for translation. These are |
| 157 // supplied by Chrome, not the developer, and are therefore different | 162 // supplied by Chrome, not the developer, and are therefore different |
| 158 // from PNaCl options. | 163 // from PNaCl options. |
| 159 std::string architecture_attributes_; | 164 std::string architecture_attributes_; |
| 160 | 165 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 184 // The helper thread used to do translations via SRPC. | 189 // The helper thread used to do translations via SRPC. |
| 185 // It accesses fields of PnaclCoordinator so it must have a | 190 // It accesses fields of PnaclCoordinator so it must have a |
| 186 // shorter lifetime. | 191 // shorter lifetime. |
| 187 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; | 192 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; |
| 188 }; | 193 }; |
| 189 | 194 |
| 190 //---------------------------------------------------------------------- | 195 //---------------------------------------------------------------------- |
| 191 | 196 |
| 192 } // namespace plugin; | 197 } // namespace plugin; |
| 193 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ | 198 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_COORDINATOR_H_ |
| OLD | NEW |