OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | |
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | |
7 | |
8 #include "native_client/src/include/nacl_scoped_ptr.h" | |
9 #include "native_client/src/include/nacl_string.h" | |
10 #include "native_client/src/shared/platform/nacl_threads.h" | |
11 #include "native_client/src/shared/platform/nacl_sync_checked.h" | |
12 | |
13 #include "ppapi/cpp/completion_callback.h" | |
14 | |
15 namespace nacl { | |
16 class DescWrapper; | |
17 } | |
18 | |
19 | |
20 namespace plugin { | |
21 | |
22 class ErrorInfo; | |
23 class LocalTempFile; | |
24 class Manifest; | |
25 class NaClSubprocess; | |
26 class Plugin; | |
27 class PnaclResources; | |
28 | |
29 class PnaclTranslateThread { | |
30 public: | |
31 PnaclTranslateThread(); | |
32 virtual ~PnaclTranslateThread(); | |
33 // TODO(jvoung/dschuff): handle surfaway issues when coordinator/plugin | |
34 // goes away. This data may have to be refcounted not touched in that case. | |
35 void RunTranslate(pp::CompletionCallback finish_callback, | |
36 const Manifest* manifest, | |
37 const Manifest* ld_manifest, | |
38 LocalTempFile* obj_file, | |
39 LocalTempFile* nexe_file, | |
40 nacl::DescWrapper* pexe_wrapper, | |
41 ErrorInfo* error_info, | |
42 PnaclResources* resources, | |
43 Plugin* plugin); | |
44 bool SubprocessesShouldDie(); | |
45 // Signal the translate thread and subprocesses that they should stop. | |
46 void SetSubprocessesShouldDie(bool subprocesses_should_die); | |
47 | |
48 private: | |
sehr (please use chromium)
2012/05/16 17:19:56
DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread);
Derek Schuff
2012/05/16 17:48:09
Done.
| |
49 // Starts an individual llc or ld subprocess used for translation. | |
50 NaClSubprocess* StartSubprocess(const nacl::string& url, | |
51 const Manifest* manifest); | |
52 // Creates a helper thread to allow translations to be | |
53 // invoked via SRPC. This is the helper thread function for translation. | |
54 static void WINAPI DoTranslateThread(void* arg); | |
55 // Signal that Pnacl translation failed, from the translation thread only. | |
56 void TranslateFailed(const nacl::string& error_string); | |
57 // Returns true if a the translate thread and subprocesses should stop. | |
58 | |
59 // Callback to run when tasks are completed or an error has occurred. | |
60 pp::CompletionCallback report_translate_finished_; | |
61 // True if the translation thread and related subprocesses should exit. | |
62 bool subprocesses_should_die_; | |
63 // Used to guard and publish subprocesses_should_die_. | |
64 struct NaClMutex subprocess_mu_; | |
65 | |
66 nacl::scoped_ptr<NaClThread> translate_thread_; | |
67 | |
68 // Data about the translation files, owned by the coordinator | |
69 const Manifest* manifest_; | |
70 const Manifest* ld_manifest_; | |
71 LocalTempFile* obj_file_; | |
72 LocalTempFile* nexe_file_; | |
73 nacl::DescWrapper* pexe_wrapper_; | |
74 ErrorInfo *error_info_; | |
75 PnaclResources* resources_; | |
76 Plugin* plugin_; | |
77 }; | |
78 | |
79 } | |
80 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | |
OLD | NEW |