| 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_TRANSLATE_THREAD_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
| 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 struct PP_PNaClOptions; | 22 struct PP_PNaClOptions; |
| 23 | 23 |
| 24 namespace nacl { | 24 namespace nacl { |
| 25 class DescWrapper; | 25 class DescWrapper; |
| 26 } | 26 } |
| 27 | 27 |
| 28 | 28 |
| 29 namespace plugin { | 29 namespace plugin { |
| 30 | 30 |
| 31 class Manifest; | |
| 32 class NaClSubprocess; | 31 class NaClSubprocess; |
| 33 class Plugin; | 32 class Plugin; |
| 34 class PnaclCoordinator; | 33 class PnaclCoordinator; |
| 35 class PnaclResources; | 34 class PnaclResources; |
| 36 class TempFile; | 35 class TempFile; |
| 37 | 36 |
| 38 class PnaclTranslateThread { | 37 class PnaclTranslateThread { |
| 39 public: | 38 public: |
| 40 PnaclTranslateThread(); | 39 PnaclTranslateThread(); |
| 41 ~PnaclTranslateThread(); | 40 ~PnaclTranslateThread(); |
| 42 | 41 |
| 43 // Start the translation process. It will continue to run and consume data | 42 // Start the translation process. It will continue to run and consume data |
| 44 // as it is passed in with PutBytes. | 43 // as it is passed in with PutBytes. |
| 45 void RunTranslate(const pp::CompletionCallback& finish_callback, | 44 void RunTranslate(const pp::CompletionCallback& finish_callback, |
| 46 const Manifest* manifest, | 45 int32_t manifest_id, |
| 47 const std::vector<TempFile*>* obj_files, | 46 const std::vector<TempFile*>* obj_files, |
| 48 TempFile* nexe_file, | 47 TempFile* nexe_file, |
| 49 nacl::DescWrapper* invalid_desc_wrapper, | 48 nacl::DescWrapper* invalid_desc_wrapper, |
| 50 ErrorInfo* error_info, | 49 ErrorInfo* error_info, |
| 51 PnaclResources* resources, | 50 PnaclResources* resources, |
| 52 PP_PNaClOptions* pnacl_options, | 51 PP_PNaClOptions* pnacl_options, |
| 53 PnaclCoordinator* coordinator, | 52 PnaclCoordinator* coordinator, |
| 54 Plugin* plugin); | 53 Plugin* plugin); |
| 55 | 54 |
| 56 // Kill the llc and/or ld subprocesses. This happens by closing the command | 55 // Kill the llc and/or ld subprocesses. This happens by closing the command |
| 57 // channel on the plugin side, which causes the trusted code in the nexe to | 56 // channel on the plugin side, which causes the trusted code in the nexe to |
| 58 // exit, which will cause any pending SRPCs to error. Because this is called | 57 // exit, which will cause any pending SRPCs to error. Because this is called |
| 59 // on the main thread, the translation thread must not use the subprocess | 58 // on the main thread, the translation thread must not use the subprocess |
| 60 // objects without the lock, other than InvokeSrpcMethod, which does not | 59 // objects without the lock, other than InvokeSrpcMethod, which does not |
| 61 // race with service runtime shutdown. | 60 // race with service runtime shutdown. |
| 62 void AbortSubprocesses(); | 61 void AbortSubprocesses(); |
| 63 | 62 |
| 64 // Send bitcode bytes to the translator. Called from the main thread. | 63 // Send bitcode bytes to the translator. Called from the main thread. |
| 65 void PutBytes(std::vector<char>* data, int count); | 64 void PutBytes(std::vector<char>* data, int count); |
| 66 | 65 |
| 67 int64_t GetCompileTime() const { return compile_time_; } | 66 int64_t GetCompileTime() const { return compile_time_; } |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 // Starts an individual llc or ld subprocess used for translation. | 69 // Starts an individual llc or ld subprocess used for translation. |
| 71 NaClSubprocess* StartSubprocess(const nacl::string& url, | 70 NaClSubprocess* StartSubprocess(const nacl::string& url, |
| 72 const Manifest* manifest, | 71 int32_t manifest_id, |
| 73 ErrorInfo* error_info); | 72 ErrorInfo* error_info); |
| 74 // Helper thread entry point for translation. Takes a pointer to | 73 // Helper thread entry point for translation. Takes a pointer to |
| 75 // PnaclTranslateThread and calls DoTranslate(). | 74 // PnaclTranslateThread and calls DoTranslate(). |
| 76 static void WINAPI DoTranslateThread(void* arg); | 75 static void WINAPI DoTranslateThread(void* arg); |
| 77 // Runs the streaming translation. Called from the helper thread. | 76 // Runs the streaming translation. Called from the helper thread. |
| 78 void DoTranslate() ; | 77 void DoTranslate() ; |
| 79 // Signal that Pnacl translation failed, from the translation thread only. | 78 // Signal that Pnacl translation failed, from the translation thread only. |
| 80 void TranslateFailed(PP_NaClError err_code, | 79 void TranslateFailed(PP_NaClError err_code, |
| 81 const nacl::string& error_string); | 80 const nacl::string& error_string); |
| 82 // Run the LD subprocess, returning true on success. | 81 // Run the LD subprocess, returning true on success. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 107 // Data buffers from FileDownloader are enqueued here to pass from the | 106 // Data buffers from FileDownloader are enqueued here to pass from the |
| 108 // main thread to the SRPC thread. Protected by cond_mu_ | 107 // main thread to the SRPC thread. Protected by cond_mu_ |
| 109 std::deque<std::vector<char> > data_buffers_; | 108 std::deque<std::vector<char> > data_buffers_; |
| 110 // Whether all data has been downloaded and copied to translation thread. | 109 // Whether all data has been downloaded and copied to translation thread. |
| 111 // Associated with buffer_cond_ | 110 // Associated with buffer_cond_ |
| 112 bool done_; | 111 bool done_; |
| 113 | 112 |
| 114 int64_t compile_time_; | 113 int64_t compile_time_; |
| 115 | 114 |
| 116 // Data about the translation files, owned by the coordinator | 115 // Data about the translation files, owned by the coordinator |
| 117 const Manifest* manifest_; | 116 int32_t manifest_id_; |
| 118 const std::vector<TempFile*>* obj_files_; | 117 const std::vector<TempFile*>* obj_files_; |
| 119 TempFile* nexe_file_; | 118 TempFile* nexe_file_; |
| 120 nacl::DescWrapper* invalid_desc_wrapper_; | 119 nacl::DescWrapper* invalid_desc_wrapper_; |
| 121 ErrorInfo* coordinator_error_info_; | 120 ErrorInfo* coordinator_error_info_; |
| 122 PnaclResources* resources_; | 121 PnaclResources* resources_; |
| 123 PP_PNaClOptions* pnacl_options_; | 122 PP_PNaClOptions* pnacl_options_; |
| 124 PnaclCoordinator* coordinator_; | 123 PnaclCoordinator* coordinator_; |
| 125 Plugin* plugin_; | 124 Plugin* plugin_; |
| 126 private: | 125 private: |
| 127 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); | 126 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 } | 129 } |
| 131 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 130 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
| OLD | NEW |