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/pnacl_coordinator.h" | 5 #include "components/nacl/renderer/plugin/pnacl_coordinator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (handle == PP_kInvalidFileHandle) { | 263 if (handle == PP_kInvalidFileHandle) { |
264 ReportNonPpapiError( | 264 ReportNonPpapiError( |
265 PP_NACL_ERROR_PNACL_CREATE_TEMP, | 265 PP_NACL_ERROR_PNACL_CREATE_TEMP, |
266 std::string( | 266 std::string( |
267 "PnaclCoordinator: Got bad temp file handle from GetNexeFd")); | 267 "PnaclCoordinator: Got bad temp file handle from GetNexeFd")); |
268 BitcodeStreamDidFinish(PP_ERROR_FAILED); | 268 BitcodeStreamDidFinish(PP_ERROR_FAILED); |
269 return; | 269 return; |
270 } | 270 } |
271 temp_nexe_file_.reset(new TempFile(plugin_, handle)); | 271 temp_nexe_file_.reset(new TempFile(plugin_, handle)); |
272 // Open it for reading as the cached nexe file. | 272 // Open it for reading as the cached nexe file. |
273 NexeReadDidOpen(temp_nexe_file_->Open(false)); | 273 NexeReadDidOpen(temp_nexe_file_->CheckValidity()); |
274 } | 274 } |
275 | 275 |
276 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size, | 276 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size, |
277 PP_FileHandle nexe_handle) { | 277 PP_FileHandle nexe_handle) { |
278 // IMPORTANT: Make sure that PnaclResources::StartLoad() is only | 278 // IMPORTANT: Make sure that PnaclResources::StartLoad() is only |
279 // called after you receive a response to a request for a .pexe file. | 279 // called after you receive a response to a request for a .pexe file. |
280 // | 280 // |
281 // The component updater's resource throttles + OnDemand update/install | 281 // The component updater's resource throttles + OnDemand update/install |
282 // should block the URL request until the compiler is present. Now we | 282 // should block the URL request until the compiler is present. Now we |
283 // can load the resources (e.g. llc and ld nexes). | 283 // can load the resources (e.g. llc and ld nexes). |
(...skipping 17 matching lines...) Expand all Loading... |
301 "information.")); | 301 "information.")); |
302 return; | 302 return; |
303 } | 303 } |
304 | 304 |
305 expected_pexe_size_ = expected_pexe_size; | 305 expected_pexe_size_ = expected_pexe_size; |
306 | 306 |
307 for (int i = 0; i < split_module_count_; i++) { | 307 for (int i = 0; i < split_module_count_; i++) { |
308 PP_FileHandle obj_handle = | 308 PP_FileHandle obj_handle = |
309 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); | 309 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); |
310 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); | 310 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); |
311 int32_t pp_error = temp_file->Open(true); | 311 int32_t pp_error = temp_file->CheckValidity(); |
312 if (pp_error != PP_OK) { | 312 if (pp_error != PP_OK) { |
313 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, | 313 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, |
314 pp_error, | 314 pp_error, |
315 "Failed to open scratch object file."); | 315 "Failed to open scratch object file."); |
316 return; | 316 return; |
317 } else { | 317 } else { |
318 obj_files_.push_back(temp_file.release()); | 318 obj_files_.push_back(temp_file.release()); |
319 } | 319 } |
320 } | 320 } |
321 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); | 321 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); |
322 | 322 |
323 temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); | 323 temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); |
324 // Open the nexe file for connecting ld and sel_ldr. | 324 // Open the nexe file for connecting ld and sel_ldr. |
325 // Start translation when done with this last step of setup! | 325 // Start translation when done with this last step of setup! |
326 int32_t pp_error = temp_nexe_file_->Open(true); | 326 int32_t pp_error = temp_nexe_file_->CheckValidity(); |
327 if (pp_error != PP_OK) { | 327 if (pp_error != PP_OK) { |
328 ReportNonPpapiError( | 328 ReportNonPpapiError( |
329 PP_NACL_ERROR_PNACL_CREATE_TEMP, | 329 PP_NACL_ERROR_PNACL_CREATE_TEMP, |
330 std::string( | 330 std::string( |
331 "PnaclCoordinator: Got bad temp file handle from writing nexe")); | 331 "PnaclCoordinator: Got bad temp file handle from writing nexe")); |
332 return; | 332 return; |
333 } | 333 } |
334 LoadCompiler(); | 334 LoadCompiler(); |
335 } | 335 } |
336 | 336 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 "PnaclCoordinator: Linker process could not be created."); | 485 "PnaclCoordinator: Linker process could not be created."); |
486 return; | 486 return; |
487 } | 487 } |
488 GetNaClInterface()->LogTranslateTime( | 488 GetNaClInterface()->LogTranslateTime( |
489 "NaCl.Perf.PNaClLoadTime.LoadLinker", | 489 "NaCl.Perf.PNaClLoadTime.LoadLinker", |
490 NaClGetTimeOfDayMicroseconds() - ld_load_start_time); | 490 NaClGetTimeOfDayMicroseconds() - ld_load_start_time); |
491 translate_thread_->RunLink(); | 491 translate_thread_->RunLink(); |
492 } | 492 } |
493 | 493 |
494 } // namespace plugin | 494 } // namespace plugin |
OLD | NEW |