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 #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 #include "native_client/src/trusted/plugin/temporary_file.h" | |
| 11 | 12 |
| 12 namespace plugin { | 13 namespace plugin { |
| 13 | 14 |
| 14 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { | 15 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { |
| 15 NaClXMutexCtor(&cond_mu_); | 16 NaClXMutexCtor(&cond_mu_); |
| 16 NaClXCondVarCtor(&buffer_cond_); | 17 NaClXCondVarCtor(&buffer_cond_); |
| 17 } | 18 } |
| 18 | 19 |
| 19 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} | 20 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} |
| 20 | 21 |
| 21 void PnaclStreamingTranslateThread::RunTranslate( | 22 void PnaclStreamingTranslateThread::RunTranslate( |
| 22 const pp::CompletionCallback& finish_callback, | 23 const pp::CompletionCallback& finish_callback, |
| 23 const Manifest* manifest, | 24 const Manifest* manifest, |
| 24 const Manifest* ld_manifest, | 25 const Manifest* ld_manifest, |
| 25 LocalTempFile* obj_file, | 26 TempFile* obj_file, |
| 26 LocalTempFile* nexe_file, | 27 LocalTempFile* nexe_file, |
| 27 ErrorInfo* error_info, | 28 ErrorInfo* error_info, |
| 28 PnaclResources* resources, | 29 PnaclResources* resources, |
| 29 Plugin* plugin) { | 30 Plugin* plugin) { |
| 30 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); | 31 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); |
| 31 manifest_ = manifest; | 32 manifest_ = manifest; |
| 32 ld_manifest_ = ld_manifest; | 33 ld_manifest_ = ld_manifest; |
| 33 obj_file_ = obj_file; | 34 obj_file_ = obj_file; |
| 34 nexe_file_ = nexe_file; | 35 nexe_file_ = nexe_file; |
| 35 coordinator_error_info_ = error_info; | 36 coordinator_error_info_ = error_info; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 ErrorInfo error_info; | 84 ErrorInfo error_info; |
| 84 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( | 85 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( |
| 85 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); | 86 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); |
| 86 if (llc_subprocess == NULL) { | 87 if (llc_subprocess == NULL) { |
| 87 TranslateFailed("Compile process could not be created: " + | 88 TranslateFailed("Compile process could not be created: " + |
| 88 error_info.message()); | 89 error_info.message()); |
| 89 return; | 90 return; |
| 90 } | 91 } |
| 91 // Run LLC. | 92 // Run LLC. |
| 92 SrpcParams params; | 93 SrpcParams params; |
| 93 nacl::DescWrapper* llc_out_file = obj_file_->write_wrapper(); | 94 nacl::DescWrapper* llc_out_file = obj_file_->get_wrapper(); |
| 94 PluginReverseInterface* llc_reverse = | 95 // Temporarily disable quota. |
| 95 llc_subprocess->service_runtime()->rev_interface(); | 96 PluginReverseInterface* llc_reverse = |
|
brettw
2012/07/27 22:38:17
Check indenting.
jvoung - send to chromium...
2012/07/28 01:30:05
Done.
| |
| 96 llc_reverse->AddQuotaManagedFile(obj_file_->identifier(), | 97 llc_subprocess->service_runtime()->rev_interface(); |
| 97 obj_file_->write_file_io()); | 98 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); |
| 98 | 99 |
| 99 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", | 100 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", |
| 100 "h", | 101 "h", |
| 101 ¶ms, | 102 ¶ms, |
| 102 llc_out_file->desc())) { | 103 llc_out_file->desc())) { |
| 103 // StreamInit returns an error message if the RPC fails. | 104 // StreamInit returns an error message if the RPC fails. |
| 104 TranslateFailed(nacl::string("Stream init failed: ") + | 105 TranslateFailed(nacl::string("Stream init failed: ") + |
| 105 nacl::string(params.outs()[0]->arrays.str)); | 106 nacl::string(params.outs()[0]->arrays.str)); |
| 106 return; | 107 return; |
| 107 } | 108 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 } | 169 } |
| 169 | 170 |
| 170 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { | 171 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { |
| 171 PnaclTranslateThread::SetSubprocessesShouldDie(); | 172 PnaclTranslateThread::SetSubprocessesShouldDie(); |
| 172 nacl::MutexLocker ml(&cond_mu_); | 173 nacl::MutexLocker ml(&cond_mu_); |
| 173 done_ = true; | 174 done_ = true; |
| 174 NaClXCondVarSignal(&buffer_cond_); | 175 NaClXCondVarSignal(&buffer_cond_); |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace plugin | 178 } // namespace plugin |
| OLD | NEW |