| 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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 TranslateFailed("could not create thread."); | 55 TranslateFailed("could not create thread."); |
| 56 translate_thread_.reset(NULL); | 56 translate_thread_.reset(NULL); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Called from main thread to send bytes to the translator. | 60 // Called from main thread to send bytes to the translator. |
| 61 void PnaclStreamingTranslateThread::PutBytes(std::vector<char>* bytes, | 61 void PnaclStreamingTranslateThread::PutBytes(std::vector<char>* bytes, |
| 62 int count) { | 62 int count) { |
| 63 PLUGIN_PRINTF(("PutBytes, this %p bytes %p, size %d, count %d\n", this, bytes, | 63 PLUGIN_PRINTF(("PutBytes, this %p bytes %p, size %d, count %d\n", this, bytes, |
| 64 bytes ? bytes->size(): 0, count)); | 64 bytes ? bytes->size(): 0, count)); |
| 65 int buffer_size = 0; | 65 size_t buffer_size = 0; |
| 66 // Ensure that the buffer we send to the translation thread is the right size | 66 // Ensure that the buffer we send to the translation thread is the right size |
| 67 // (count can be < the buffer size). This can be done without the lock. | 67 // (count can be < the buffer size). This can be done without the lock. |
| 68 if (bytes != NULL && count >= 0) { | 68 if (bytes != NULL && count >= 0) { |
| 69 buffer_size = bytes->size(); | 69 buffer_size = bytes->size(); |
| 70 bytes->resize(count); | 70 bytes->resize(count); |
| 71 } | 71 } |
| 72 NaClXMutexLock(&cond_mu_); | 72 NaClXMutexLock(&cond_mu_); |
| 73 if (count == PP_OK || count < 0) { | 73 if (count == PP_OK || count < 0) { |
| 74 done_ = true; | 74 done_ = true; |
| 75 } else { | 75 } else { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { | 176 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { |
| 177 PnaclTranslateThread::SetSubprocessesShouldDie(); | 177 PnaclTranslateThread::SetSubprocessesShouldDie(); |
| 178 nacl::MutexLocker ml(&cond_mu_); | 178 nacl::MutexLocker ml(&cond_mu_); |
| 179 done_ = true; | 179 done_ = true; |
| 180 NaClXCondVarSignal(&buffer_cond_); | 180 NaClXCondVarSignal(&buffer_cond_); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace plugin | 183 } // namespace plugin |
| OLD | NEW |