| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 PLUGIN_PRINTF(("PutBytes, this %p bytes %p, size %d, count %d\n", this, bytes, | 60 PLUGIN_PRINTF(("PutBytes, this %p bytes %p, size %d, count %d\n", this, bytes, |
| 61 bytes ? bytes->size(): 0, count)); | 61 bytes ? bytes->size(): 0, count)); |
| 62 size_t buffer_size = 0; | 62 size_t buffer_size = 0; |
| 63 // Ensure that the buffer we send to the translation thread is the right size | 63 // Ensure that the buffer we send to the translation thread is the right size |
| 64 // (count can be < the buffer size). This can be done without the lock. | 64 // (count can be < the buffer size). This can be done without the lock. |
| 65 if (bytes != NULL && count >= 0) { | 65 if (bytes != NULL && count >= 0) { |
| 66 buffer_size = bytes->size(); | 66 buffer_size = bytes->size(); |
| 67 bytes->resize(count); | 67 bytes->resize(count); |
| 68 } | 68 } |
| 69 NaClXMutexLock(&cond_mu_); | 69 NaClXMutexLock(&cond_mu_); |
| 70 if (count == PP_OK || count < 0) { | 70 if (count == PP_OK || count < 0 || bytes == NULL) { |
| 71 done_ = true; | 71 done_ = true; |
| 72 } else { | 72 } else { |
| 73 data_buffers_.push_back(std::vector<char>()); | 73 data_buffers_.push_back(std::vector<char>()); |
| 74 bytes->swap(data_buffers_.back()); // Avoid copying the buffer data. | 74 bytes->swap(data_buffers_.back()); // Avoid copying the buffer data. |
| 75 } | 75 } |
| 76 NaClXCondVarSignal(&buffer_cond_); | 76 NaClXCondVarSignal(&buffer_cond_); |
| 77 NaClXMutexUnlock(&cond_mu_); | 77 NaClXMutexUnlock(&cond_mu_); |
| 78 // Ensure the buffer we send back to the coordinator is the expected size | 78 // Ensure the buffer we send back to the coordinator is the expected size |
| 79 if (bytes != NULL) bytes->resize(buffer_size); | 79 if (bytes != NULL) bytes->resize(buffer_size); |
| 80 } | 80 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { | 170 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { |
| 171 PnaclTranslateThread::SetSubprocessesShouldDie(); | 171 PnaclTranslateThread::SetSubprocessesShouldDie(); |
| 172 nacl::MutexLocker ml(&cond_mu_); | 172 nacl::MutexLocker ml(&cond_mu_); |
| 173 done_ = true; | 173 done_ = true; |
| 174 NaClXCondVarSignal(&buffer_cond_); | 174 NaClXCondVarSignal(&buffer_cond_); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace plugin | 177 } // namespace plugin |
| OLD | NEW |