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_translate_thread.h" | 5 #include "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 "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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 core->CallOnMainThread(0, report_translate_finished_, PP_ERROR_FAILED); | 112 core->CallOnMainThread(0, report_translate_finished_, PP_ERROR_FAILED); |
113 } | 113 } |
114 | 114 |
115 // This synchronization method (using the pointer directly in the | 115 // This synchronization method (using the pointer directly in the |
116 // translation thread, setting a copy here, and calling shutdown on the | 116 // translation thread, setting a copy here, and calling shutdown on the |
117 // main thread) is safe only because only the translation thread sets | 117 // main thread) is safe only because only the translation thread sets |
118 // the copy, and the shutdown method is thread-safe. This method must be | 118 // the copy, and the shutdown method is thread-safe. This method must be |
119 // called on the translation thread before any RPCs are called, and called | 119 // called on the translation thread before any RPCs are called, and called |
120 // again with NULL before the object is destroyed. | 120 // again with NULL before the object is destroyed. |
121 void PnaclTranslateThread::RegisterReverseInterface( | 121 void PnaclTranslateThread::RegisterReverseInterface( |
122 PluginReverseInterface *interface) { | 122 PluginReverseInterface *iface) { |
123 nacl::MutexLocker ml(&subprocess_mu_); | 123 nacl::MutexLocker ml(&subprocess_mu_); |
124 current_rev_interface_ = interface; | 124 current_rev_interface_ = iface; |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 bool PnaclTranslateThread::SubprocessesShouldDie() { | 128 bool PnaclTranslateThread::SubprocessesShouldDie() { |
129 nacl::MutexLocker ml(&subprocess_mu_); | 129 nacl::MutexLocker ml(&subprocess_mu_); |
130 return subprocesses_should_die_; | 130 return subprocesses_should_die_; |
131 } | 131 } |
132 | 132 |
133 void PnaclTranslateThread::SetSubprocessesShouldDie() { | 133 void PnaclTranslateThread::SetSubprocessesShouldDie() { |
134 PLUGIN_PRINTF(("PnaclTranslateThread::SetSubprocessesShouldDie\n")); | 134 PLUGIN_PRINTF(("PnaclTranslateThread::SetSubprocessesShouldDie\n")); |
135 nacl::MutexLocker ml(&subprocess_mu_); | 135 nacl::MutexLocker ml(&subprocess_mu_); |
136 subprocesses_should_die_ = true; | 136 subprocesses_should_die_ = true; |
137 if (current_rev_interface_) { | 137 if (current_rev_interface_) { |
138 current_rev_interface_->ShutDown(); | 138 current_rev_interface_->ShutDown(); |
139 current_rev_interface_ = NULL; | 139 current_rev_interface_ = NULL; |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 PnaclTranslateThread::~PnaclTranslateThread() { | 143 PnaclTranslateThread::~PnaclTranslateThread() { |
144 NaClMutexDtor(&subprocess_mu_); | 144 NaClMutexDtor(&subprocess_mu_); |
145 } | 145 } |
146 | 146 |
147 } // namespace plugin | 147 } // namespace plugin |
OLD | NEW |