Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc

Issue 406323003: Revert 284684 "Pepper: Delete FileDownloader in trusted plugin." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
===================================================================
--- trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc (revision 284790)
+++ trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc (working copy)
@@ -111,16 +111,27 @@
}
// Called from main thread to send bytes to the translator.
-void PnaclTranslateThread::PutBytes(const void* bytes, int32_t count) {
+void PnaclTranslateThread::PutBytes(std::vector<char>* bytes, int count) {
+ PLUGIN_PRINTF(("PutBytes (this=%p, bytes=%p, size=%" NACL_PRIuS
+ ", count=%d)\n",
+ this, bytes, bytes ? bytes->size() : 0, count));
+ size_t buffer_size = 0;
CHECK(bytes != NULL);
+ // Ensure that the buffer we send to the translation thread is the right size
+ // (count can be < the buffer size). This can be done without the lock.
+ buffer_size = bytes->size();
+ bytes->resize(count);
+
NaClXMutexLock(&cond_mu_);
- std::vector<char> v;
- data_buffers_.push_back(v);
- data_buffers_.back().insert(v.end(),
- static_cast<const char*>(bytes),
- static_cast<const char*>(bytes) + count);
+
+ data_buffers_.push_back(std::vector<char>());
+ bytes->swap(data_buffers_.back()); // Avoid copying the buffer data.
+
NaClXCondVarSignal(&buffer_cond_);
NaClXMutexUnlock(&cond_mu_);
+
+ // Ensure the buffer we send back to the coordinator is the expected size
+ bytes->resize(buffer_size);
}
void PnaclTranslateThread::EndStream() {

Powered by Google App Engine
This is Rietveld 408576698