Chromium Code Reviews| 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 "native_client/src/include/nacl_macros.h" | 8 #include "native_client/src/include/nacl_macros.h" |
| 9 #include "native_client/src/include/nacl_scoped_ptr.h" | 9 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 10 #include "native_client/src/include/nacl_string.h" | 10 #include "native_client/src/include/nacl_string.h" |
| 11 #include "native_client/src/shared/platform/nacl_threads.h" | 11 #include "native_client/src/shared/platform/nacl_threads.h" |
| 12 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 12 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
| 13 #include "native_client/src/trusted/plugin/plugin_error.h" | 13 #include "native_client/src/trusted/plugin/plugin_error.h" |
| 14 #include "native_client/src/trusted/plugin/service_runtime.h" | |
| 14 | 15 |
| 15 #include "ppapi/cpp/completion_callback.h" | 16 #include "ppapi/cpp/completion_callback.h" |
| 16 | 17 |
| 17 namespace nacl { | 18 namespace nacl { |
| 18 class DescWrapper; | 19 class DescWrapper; |
| 19 } | 20 } |
| 20 | 21 |
| 21 | 22 |
| 22 namespace plugin { | 23 namespace plugin { |
| 23 | 24 |
| 24 class LocalTempFile; | 25 class LocalTempFile; |
| 25 class Manifest; | 26 class Manifest; |
| 26 class NaClSubprocess; | 27 class NaClSubprocess; |
| 27 class Plugin; | 28 class Plugin; |
| 28 class PnaclResources; | 29 class PnaclResources; |
| 29 class TempFile; | 30 class TempFile; |
| 30 | 31 |
| 31 class PnaclTranslateThread { | 32 class PnaclTranslateThread { |
| 32 public: | 33 public: |
| 33 PnaclTranslateThread(); | 34 PnaclTranslateThread(); |
| 34 virtual ~PnaclTranslateThread(); | 35 virtual ~PnaclTranslateThread(); |
| 35 // TODO(jvoung/dschuff): handle surfaway issues when coordinator/plugin | 36 // TODO(jvoung/dschuff): handle surfaway issues when coordinator/plugin |
|
jvoung (off chromium)
2012/07/31 18:51:45
is this TODO() obsolete, w/ the joining?
Derek Schuff
2012/07/31 18:57:50
Done.
| |
| 36 // goes away. This data may have to be refcounted not touched in that case. | 37 // goes away. This data may have to be refcounted not touched in that case. |
| 37 virtual void RunTranslate(const pp::CompletionCallback& finish_callback, | 38 virtual void RunTranslate(const pp::CompletionCallback& finish_callback, |
| 38 const Manifest* manifest, | 39 const Manifest* manifest, |
| 39 const Manifest* ld_manifest, | 40 const Manifest* ld_manifest, |
| 40 TempFile* obj_file, | 41 TempFile* obj_file, |
| 41 LocalTempFile* nexe_file, | 42 LocalTempFile* nexe_file, |
| 42 ErrorInfo* error_info, | 43 ErrorInfo* error_info, |
| 43 PnaclResources* resources, | 44 PnaclResources* resources, |
| 44 Plugin* plugin) = 0; | 45 Plugin* plugin) = 0; |
| 45 // Returns true if the translate thread and subprocesses should stop. | 46 // Returns true if the translate thread and subprocesses should stop. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 57 static void WINAPI DoTranslateThread(void* arg); | 58 static void WINAPI DoTranslateThread(void* arg); |
| 58 // Runs the SRPCs that control translation. Called from the helper thread. | 59 // Runs the SRPCs that control translation. Called from the helper thread. |
| 59 virtual void DoTranslate() = 0; | 60 virtual void DoTranslate() = 0; |
| 60 // Signal that Pnacl translation failed, from the translation thread only. | 61 // Signal that Pnacl translation failed, from the translation thread only. |
| 61 void TranslateFailed(const nacl::string& error_string); | 62 void TranslateFailed(const nacl::string& error_string); |
| 62 // Run the LD subprocess, returning true on success | 63 // Run the LD subprocess, returning true on success |
| 63 bool RunLdSubprocess(int is_shared_library, | 64 bool RunLdSubprocess(int is_shared_library, |
| 64 const nacl::string& soname, | 65 const nacl::string& soname, |
| 65 const nacl::string& lib_dependencies); | 66 const nacl::string& lib_dependencies); |
| 66 | 67 |
| 68 // Register a reverse service interface which will be shutdown if the | |
| 69 // plugin is shutdown. The reverse service pointer must be available on the | |
|
jvoung (off chromium)
2012/07/31 18:51:45
extra spaces: "pointer must be"
Derek Schuff
2012/07/31 18:57:50
Done.
| |
| 70 // main thread because the translation thread could be blocked on SRPC | |
|
jvoung (off chromium)
2012/07/31 18:51:45
for a future CL: would it be possible to make it m
Derek Schuff
2012/07/31 18:57:50
Yeah, actually i think all the code is main thread
| |
| 71 // waiting for the translator, which could be waiting on a reverse | |
| 72 // service call. | |
| 73 // (see also the comments in Plugin::~Plugin about ShutdownSubprocesses, | |
| 74 // but that only handles the main nexe and not the translator nexes.) | |
| 75 void RegisterReverseInterface(PluginReverseInterface *interface); | |
| 76 | |
| 67 // Callback to run when tasks are completed or an error has occurred. | 77 // Callback to run when tasks are completed or an error has occurred. |
| 68 pp::CompletionCallback report_translate_finished_; | 78 pp::CompletionCallback report_translate_finished_; |
| 69 // True if the translation thread and related subprocesses should exit. | 79 // True if the translation thread and related subprocesses should exit. |
| 70 bool subprocesses_should_die_; | 80 bool subprocesses_should_die_; |
| 71 // Used to guard and publish subprocesses_should_die_. | 81 // Used to guard and publish subprocesses_should_die_. |
| 72 struct NaClMutex subprocess_mu_; | 82 struct NaClMutex subprocess_mu_; |
| 73 | 83 |
| 74 nacl::scoped_ptr<NaClThread> translate_thread_; | 84 nacl::scoped_ptr<NaClThread> translate_thread_; |
| 75 | 85 |
| 86 // Reverse interface to shutdown on SetSubprocessesShouldDie | |
| 87 PluginReverseInterface* current_rev_interface_; | |
| 88 | |
| 76 // Data about the translation files, owned by the coordinator | 89 // Data about the translation files, owned by the coordinator |
| 77 const Manifest* manifest_; | 90 const Manifest* manifest_; |
| 78 const Manifest* ld_manifest_; | 91 const Manifest* ld_manifest_; |
| 79 TempFile* obj_file_; | 92 TempFile* obj_file_; |
| 80 LocalTempFile* nexe_file_; | 93 LocalTempFile* nexe_file_; |
| 81 ErrorInfo* coordinator_error_info_; | 94 ErrorInfo* coordinator_error_info_; |
| 82 PnaclResources* resources_; | 95 PnaclResources* resources_; |
| 83 Plugin* plugin_; | 96 Plugin* plugin_; |
| 84 private: | 97 private: |
| 85 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); | 98 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); |
| 86 }; | 99 }; |
| 87 | 100 |
| 88 } | 101 } |
| 89 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 102 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
| OLD | NEW |