| 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 "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" |
| 6 | 6 |
| 7 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 7 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 8 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 8 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
| 9 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 9 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" |
| 10 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" | 10 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 kArbitraryStackSize)) { | 66 kArbitraryStackSize)) { |
| 67 TranslateFailed(ERROR_PNACL_THREAD_CREATE, | 67 TranslateFailed(ERROR_PNACL_THREAD_CREATE, |
| 68 "could not create thread."); | 68 "could not create thread."); |
| 69 translate_thread_.reset(NULL); | 69 translate_thread_.reset(NULL); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Called from main thread to send bytes to the translator. | 73 // Called from main thread to send bytes to the translator. |
| 74 void PnaclTranslateThread::PutBytes(std::vector<char>* bytes, | 74 void PnaclTranslateThread::PutBytes(std::vector<char>* bytes, |
| 75 int count) { | 75 int count) { |
| 76 PLUGIN_PRINTF(("PutBytes (this=%p, bytes=%p, size=%"NACL_PRIuS", count=%d)\n", | 76 PLUGIN_PRINTF(("PutBytes (this=%p, bytes=%p, size=%" NACL_PRIuS |
| 77 ", count=%d)\n", |
| 77 this, bytes, bytes ? bytes->size() : 0, count)); | 78 this, bytes, bytes ? bytes->size() : 0, count)); |
| 78 size_t buffer_size = 0; | 79 size_t buffer_size = 0; |
| 79 // If we are done (error or not), Signal the translation thread to stop. | 80 // If we are done (error or not), Signal the translation thread to stop. |
| 80 if (count <= PP_OK) { | 81 if (count <= PP_OK) { |
| 81 NaClXMutexLock(&cond_mu_); | 82 NaClXMutexLock(&cond_mu_); |
| 82 done_ = true; | 83 done_ = true; |
| 83 NaClXCondVarSignal(&buffer_cond_); | 84 NaClXCondVarSignal(&buffer_cond_); |
| 84 NaClXMutexUnlock(&cond_mu_); | 85 NaClXMutexUnlock(&cond_mu_); |
| 85 return; | 86 return; |
| 86 } | 87 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 179 |
| 179 PLUGIN_PRINTF(("PnaclCoordinator: StreamInit successful\n")); | 180 PLUGIN_PRINTF(("PnaclCoordinator: StreamInit successful\n")); |
| 180 pp::Core* core = pp::Module::Get()->core(); | 181 pp::Core* core = pp::Module::Get()->core(); |
| 181 | 182 |
| 182 // llc process is started. | 183 // llc process is started. |
| 183 while(!done_ || data_buffers_.size() > 0) { | 184 while(!done_ || data_buffers_.size() > 0) { |
| 184 NaClXMutexLock(&cond_mu_); | 185 NaClXMutexLock(&cond_mu_); |
| 185 while(!done_ && data_buffers_.size() == 0) { | 186 while(!done_ && data_buffers_.size() == 0) { |
| 186 NaClXCondVarWait(&buffer_cond_, &cond_mu_); | 187 NaClXCondVarWait(&buffer_cond_, &cond_mu_); |
| 187 } | 188 } |
| 188 PLUGIN_PRINTF(("PnaclTranslateThread awake (done=%d, size=%"NACL_PRIuS")\n", | 189 PLUGIN_PRINTF(("PnaclTranslateThread awake (done=%d, size=%" NACL_PRIuS |
| 190 ")\n", |
| 189 done_, data_buffers_.size())); | 191 done_, data_buffers_.size())); |
| 190 if (data_buffers_.size() > 0) { | 192 if (data_buffers_.size() > 0) { |
| 191 std::vector<char> data; | 193 std::vector<char> data; |
| 192 data.swap(data_buffers_.front()); | 194 data.swap(data_buffers_.front()); |
| 193 data_buffers_.pop_front(); | 195 data_buffers_.pop_front(); |
| 194 NaClXMutexUnlock(&cond_mu_); | 196 NaClXMutexUnlock(&cond_mu_); |
| 195 PLUGIN_PRINTF(("StreamChunk\n")); | 197 PLUGIN_PRINTF(("StreamChunk\n")); |
| 196 if (!llc_subprocess_->InvokeSrpcMethod("StreamChunk", | 198 if (!llc_subprocess_->InvokeSrpcMethod("StreamChunk", |
| 197 "C", | 199 "C", |
| 198 ¶ms, | 200 ¶ms, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 AbortSubprocesses(); | 353 AbortSubprocesses(); |
| 352 if (translate_thread_ != NULL) | 354 if (translate_thread_ != NULL) |
| 353 NaClThreadJoin(translate_thread_.get()); | 355 NaClThreadJoin(translate_thread_.get()); |
| 354 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 356 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
| 355 NaClCondVarDtor(&buffer_cond_); | 357 NaClCondVarDtor(&buffer_cond_); |
| 356 NaClMutexDtor(&cond_mu_); | 358 NaClMutexDtor(&cond_mu_); |
| 357 NaClMutexDtor(&subprocess_mu_); | 359 NaClMutexDtor(&subprocess_mu_); |
| 358 } | 360 } |
| 359 | 361 |
| 360 } // namespace plugin | 362 } // namespace plugin |
| OLD | NEW |