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 #include "native_client/src/trusted/plugin/pnacl_streaming_translate_thread.h" | 5 #include "native_client/src/trusted/plugin/pnacl_streaming_translate_thread.h" |
6 | 6 |
7 #include "native_client/src/include/nacl_scoped_ptr.h" | 7 #include "native_client/src/include/nacl_scoped_ptr.h" |
8 #include "native_client/src/trusted/plugin/plugin.h" | 8 #include "native_client/src/trusted/plugin/plugin.h" |
9 #include "native_client/src/trusted/plugin/pnacl_resources.h" | 9 #include "native_client/src/trusted/plugin/pnacl_resources.h" |
10 #include "native_client/src/trusted/plugin/srpc_params.h" | 10 #include "native_client/src/trusted/plugin/srpc_params.h" |
11 | 11 |
12 namespace plugin { | 12 namespace plugin { |
13 | 13 |
14 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { | 14 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { |
15 NaClXMutexCtor(&cond_mu_); | 15 NaClXMutexCtor(&cond_mu_); |
16 NaClXCondVarCtor(&buffer_cond_); | 16 NaClXCondVarCtor(&buffer_cond_); |
17 } | 17 } |
18 | 18 |
19 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} | 19 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} |
20 | 20 |
21 void PnaclStreamingTranslateThread::RunTranslate( | 21 void PnaclStreamingTranslateThread::RunTranslate( |
22 const pp::CompletionCallback& finish_callback, | 22 const pp::CompletionCallback& finish_callback, |
23 const Manifest* manifest, | 23 const Manifest* manifest, |
24 const Manifest* ld_manifest, | 24 const Manifest* ld_manifest, |
25 LocalTempFile* obj_file, | 25 LocalTempFile* obj_file, |
26 LocalTempFile* nexe_file, | 26 LocalTempFile* nexe_file, |
27 nacl::DescWrapper* pexe_wrapper, | |
28 ErrorInfo* error_info, | 27 ErrorInfo* error_info, |
29 PnaclResources* resources, | 28 PnaclResources* resources, |
30 Plugin* plugin) { | 29 Plugin* plugin) { |
31 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); | 30 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); |
32 manifest_ = manifest; | 31 manifest_ = manifest; |
33 ld_manifest_ = ld_manifest; | 32 ld_manifest_ = ld_manifest; |
34 obj_file_ = obj_file; | 33 obj_file_ = obj_file; |
35 nexe_file_ = nexe_file; | 34 nexe_file_ = nexe_file; |
36 pexe_wrapper_ = NULL; // The streaming translator doesn't use a pexe desc. | |
37 DCHECK(pexe_wrapper == NULL); | |
38 coordinator_error_info_ = error_info; | 35 coordinator_error_info_ = error_info; |
39 resources_ = resources; | 36 resources_ = resources; |
40 plugin_ = plugin; | 37 plugin_ = plugin; |
41 | 38 |
42 // Invoke llc followed by ld off the main thread. This allows use of | 39 // Invoke llc followed by ld off the main thread. This allows use of |
43 // blocking RPCs that would otherwise block the JavaScript main thread. | 40 // blocking RPCs that would otherwise block the JavaScript main thread. |
44 report_translate_finished_ = finish_callback; | 41 report_translate_finished_ = finish_callback; |
45 translate_thread_.reset(new NaClThread); | 42 translate_thread_.reset(new NaClThread); |
46 if (translate_thread_ == NULL) { | 43 if (translate_thread_ == NULL) { |
47 TranslateFailed("could not allocate thread struct."); | 44 TranslateFailed("could not allocate thread struct."); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 168 } |
172 | 169 |
173 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { | 170 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { |
174 PnaclTranslateThread::SetSubprocessesShouldDie(); | 171 PnaclTranslateThread::SetSubprocessesShouldDie(); |
175 nacl::MutexLocker ml(&cond_mu_); | 172 nacl::MutexLocker ml(&cond_mu_); |
176 done_ = true; | 173 done_ = true; |
177 NaClXCondVarSignal(&buffer_cond_); | 174 NaClXCondVarSignal(&buffer_cond_); |
178 } | 175 } |
179 | 176 |
180 } // namespace plugin | 177 } // namespace plugin |
OLD | NEW |