| Index: ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h
|
| diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h
|
| index 82e7d8d5a7bbfb9752a30f364996ebfd777823c7..499eee4ba69d721b87012c9e97006fad71793ac6 100644
|
| --- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h
|
| +++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h
|
| @@ -5,6 +5,9 @@
|
| #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_
|
| #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_
|
|
|
| +#include <deque>
|
| +#include <vector>
|
| +
|
| #include "native_client/src/include/nacl_macros.h"
|
| #include "native_client/src/include/nacl_scoped_ptr.h"
|
| #include "native_client/src/include/nacl_string.h"
|
| @@ -32,22 +35,29 @@ class TempFile;
|
| class PnaclTranslateThread {
|
| public:
|
| PnaclTranslateThread();
|
| - virtual ~PnaclTranslateThread();
|
| + ~PnaclTranslateThread();
|
|
|
| - virtual void RunTranslate(const pp::CompletionCallback& finish_callback,
|
| + // Start the translation process. It will continue to run and consume data
|
| + // as it is passed in with PutBytes.
|
| + void RunTranslate(const pp::CompletionCallback& finish_callback,
|
| const Manifest* manifest,
|
| const Manifest* ld_manifest,
|
| TempFile* obj_file,
|
| LocalTempFile* nexe_file,
|
| ErrorInfo* error_info,
|
| PnaclResources* resources,
|
| - Plugin* plugin) = 0;
|
| + Plugin* plugin);
|
| +
|
| + // Signal the translate thread and subprocesses that they should stop.
|
| + void SetSubprocessesShouldDie();
|
| +
|
| + // Send bitcode bytes to the translator. Called from the main thread.
|
| + void PutBytes(std::vector<char>* data, int count);
|
| +
|
| + private:
|
| // Returns true if the translate thread and subprocesses should stop.
|
| bool SubprocessesShouldDie();
|
| - // Signal the translate thread and subprocesses that they should stop.
|
| - virtual void SetSubprocessesShouldDie();
|
|
|
| - protected:
|
| // Starts an individual llc or ld subprocess used for translation.
|
| NaClSubprocess* StartSubprocess(const nacl::string& url,
|
| const Manifest* manifest,
|
| @@ -55,8 +65,8 @@ class PnaclTranslateThread {
|
| // Helper thread entry point for translation. Takes a pointer to
|
| // PnaclTranslateThread and calls DoTranslate().
|
| static void WINAPI DoTranslateThread(void* arg);
|
| - // Runs the SRPCs that control translation. Called from the helper thread.
|
| - virtual void DoTranslate() = 0;
|
| + // Runs the streaming translation. Called from the helper thread.
|
| + void DoTranslate() ;
|
| // Signal that Pnacl translation failed, from the translation thread only.
|
| void TranslateFailed(const nacl::string& error_string);
|
| // Run the LD subprocess, returning true on success
|
| @@ -85,6 +95,22 @@ class PnaclTranslateThread {
|
| // Reverse interface to shutdown on SetSubprocessesShouldDie
|
| PluginReverseInterface* current_rev_interface_;
|
|
|
| +
|
| +
|
| + // Condition variable to synchronize communication with the SRPC thread.
|
| + // SRPC thread waits on this condvar if data_buffers_ is empty (meaning
|
| + // there is no bitcode to send to the translator), and the main thread
|
| + // appends to data_buffers_ and signals it when it receives bitcode.
|
| + struct NaClCondVar buffer_cond_;
|
| + // Mutex for buffer_cond_.
|
| + struct NaClMutex cond_mu_;
|
| + // Data buffers from FileDownloader are enqueued here to pass from the
|
| + // main thread to the SRPC thread. Protected by cond_mu_
|
| + std::deque<std::vector<char> > data_buffers_;
|
| + // Whether all data has been downloaded and copied to translation thread.
|
| + // Associated with buffer_cond_
|
| + bool done_;
|
| +
|
| // Data about the translation files, owned by the coordinator
|
| const Manifest* manifest_;
|
| const Manifest* ld_manifest_;
|
|
|