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 "components/nacl/renderer/plugin/plugin.h" | 5 #include "components/nacl/renderer/plugin/plugin.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace { | 21 namespace { |
22 | 22 |
23 void NoOpCallback(void* user_data, int32_t result) { | 23 void NoOpCallback(void* user_data, int32_t result) { |
24 } | 24 } |
25 | 25 |
26 } | 26 } |
27 | 27 |
28 namespace plugin { | 28 namespace plugin { |
29 | 29 |
30 void Plugin::ShutDownSubprocesses() { | 30 void Plugin::ShutDownSubprocesses() { |
31 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", | |
32 static_cast<void*>(this))); | |
33 | |
34 // Shut down service runtime. This must be done before all other calls so | 31 // Shut down service runtime. This must be done before all other calls so |
35 // they don't block forever when waiting for the upcall thread to exit. | 32 // they don't block forever when waiting for the upcall thread to exit. |
36 main_subprocess_.Shutdown(); | 33 main_subprocess_.Shutdown(); |
37 | |
38 PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n", | |
39 static_cast<void*>(this))); | |
40 } | 34 } |
41 | 35 |
42 void Plugin::StartSelLdr(ServiceRuntime* service_runtime, | 36 void Plugin::StartSelLdr(ServiceRuntime* service_runtime, |
43 const SelLdrStartParams& params, | 37 const SelLdrStartParams& params, |
44 pp::CompletionCallback callback) { | 38 pp::CompletionCallback callback) { |
45 service_runtime->StartSelLdr(params, callback); | 39 service_runtime->StartSelLdr(params, callback); |
46 } | 40 } |
47 | 41 |
48 void Plugin::LoadNaClModule(PP_NaClFileInfo file_info, | 42 void Plugin::LoadNaClModule(PP_NaClFileInfo file_info, |
49 bool uses_nonsfi_mode, | 43 bool uses_nonsfi_mode, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void Plugin::NexeFileDidOpen(int32_t pp_error) { | 151 void Plugin::NexeFileDidOpen(int32_t pp_error) { |
158 if (pp_error != PP_OK) | 152 if (pp_error != PP_OK) |
159 return; | 153 return; |
160 LoadNaClModule( | 154 LoadNaClModule( |
161 nexe_file_info_, | 155 nexe_file_info_, |
162 uses_nonsfi_mode_, | 156 uses_nonsfi_mode_, |
163 PP_NATIVE_NACL_PROCESS_TYPE); | 157 PP_NATIVE_NACL_PROCESS_TYPE); |
164 } | 158 } |
165 | 159 |
166 void Plugin::BitcodeDidTranslate(int32_t pp_error) { | 160 void Plugin::BitcodeDidTranslate(int32_t pp_error) { |
167 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", | |
168 pp_error)); | |
169 if (pp_error != PP_OK) { | 161 if (pp_error != PP_OK) { |
170 // Error should have been reported by pnacl. Just return. | 162 // Error should have been reported by pnacl. Just return. |
171 return; | 163 return; |
172 } | 164 } |
173 | 165 |
174 // Inform JavaScript that we successfully translated the bitcode to a nexe. | 166 // Inform JavaScript that we successfully translated the bitcode to a nexe. |
175 PP_FileHandle handle = pnacl_coordinator_->TakeTranslatedFileHandle(); | 167 PP_FileHandle handle = pnacl_coordinator_->TakeTranslatedFileHandle(); |
176 | 168 |
177 PP_NaClFileInfo info; | 169 PP_NaClFileInfo info; |
178 info.handle = handle; | 170 info.handle = handle; |
179 info.token_lo = 0; | 171 info.token_lo = 0; |
180 info.token_hi = 0; | 172 info.token_hi = 0; |
181 LoadNaClModule( | 173 LoadNaClModule( |
182 info, | 174 info, |
183 false, /* uses_nonsfi_mode */ | 175 false, /* uses_nonsfi_mode */ |
184 PP_PNACL_PROCESS_TYPE); | 176 PP_PNACL_PROCESS_TYPE); |
185 } | 177 } |
186 | 178 |
187 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { | 179 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { |
188 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" | |
189 NACL_PRId32 ")\n", pp_error)); | |
190 if (pp_error != PP_OK) | 180 if (pp_error != PP_OK) |
191 return; | 181 return; |
192 | 182 |
193 PP_Var pp_program_url; | 183 PP_Var pp_program_url; |
194 PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, PP_FALSE, 2}; | 184 PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, PP_FALSE, 2}; |
195 PP_Bool uses_nonsfi_mode; | 185 PP_Bool uses_nonsfi_mode; |
196 if (nacl_interface_->GetManifestProgramURL( | 186 if (nacl_interface_->GetManifestProgramURL( |
197 pp_instance(), &pp_program_url, &pnacl_options, &uses_nonsfi_mode)) { | 187 pp_instance(), &pp_program_url, &pnacl_options, &uses_nonsfi_mode)) { |
198 std::string program_url = pp::Var(pp::PASS_REF, pp_program_url).AsString(); | 188 std::string program_url = pp::Var(pp::PASS_REF, pp_program_url).AsString(); |
199 // TODO(teravest): Make ProcessNaClManifest take responsibility for more of | 189 // TODO(teravest): Make ProcessNaClManifest take responsibility for more of |
(...skipping 22 matching lines...) Expand all Loading... |
222 } | 212 } |
223 } | 213 } |
224 | 214 |
225 void Plugin::ReportLoadError(const ErrorInfo& error_info) { | 215 void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
226 nacl_interface_->ReportLoadError(pp_instance(), | 216 nacl_interface_->ReportLoadError(pp_instance(), |
227 error_info.error_code(), | 217 error_info.error_code(), |
228 error_info.message().c_str()); | 218 error_info.message().c_str()); |
229 } | 219 } |
230 | 220 |
231 } // namespace plugin | 221 } // namespace plugin |
OLD | NEW |