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

Side by Side Diff: trunk/src/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc

Issue 406383002: Revert 284766 "Pepper: Simplify TempFile 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/src/ppapi/native_client/src/trusted/plugin/temporary_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) { 331 void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) {
332 HistogramEnumerateTranslationCache(plugin_->uma_interface(), true); 332 HistogramEnumerateTranslationCache(plugin_->uma_interface(), true);
333 if (handle == PP_kInvalidFileHandle) { 333 if (handle == PP_kInvalidFileHandle) {
334 ReportNonPpapiError( 334 ReportNonPpapiError(
335 PP_NACL_ERROR_PNACL_CREATE_TEMP, 335 PP_NACL_ERROR_PNACL_CREATE_TEMP,
336 nacl::string( 336 nacl::string(
337 "PnaclCoordinator: Got bad temp file handle from GetNexeFd")); 337 "PnaclCoordinator: Got bad temp file handle from GetNexeFd"));
338 BitcodeStreamDidFinish(PP_ERROR_FAILED); 338 BitcodeStreamDidFinish(PP_ERROR_FAILED);
339 return; 339 return;
340 } 340 }
341 temp_nexe_file_.reset(new TempFile(plugin_, handle)); 341 *temp_nexe_file_->internal_handle() = handle;
342 // Open it for reading as the cached nexe file.
342 NexeReadDidOpen(temp_nexe_file_->Open(false)); 343 NexeReadDidOpen(temp_nexe_file_->Open(false));
343 } 344 }
344 345
345 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { 346 void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) {
346 HistogramEnumerateTranslationCache(plugin_->uma_interface(), false); 347 HistogramEnumerateTranslationCache(plugin_->uma_interface(), false);
347 expected_pexe_size_ = expected_pexe_size; 348 expected_pexe_size_ = expected_pexe_size;
348 349
350 // Open an object file first so the translator can start writing to it
351 // during streaming translation.
352 temp_nexe_file_.reset(new TempFile(plugin_));
353
349 for (int i = 0; i < split_module_count_; i++) { 354 for (int i = 0; i < split_module_count_; i++) {
350 PP_FileHandle obj_handle = 355 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_));
351 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
352 nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle));
353 int32_t pp_error = temp_file->Open(true); 356 int32_t pp_error = temp_file->Open(true);
354 if (pp_error != PP_OK) { 357 if (pp_error != PP_OK) {
355 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, 358 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
356 pp_error, 359 pp_error,
357 "Failed to open scratch object file."); 360 "Failed to open scratch object file.");
358 return; 361 return;
359 } else { 362 } else {
360 obj_files_.push_back(temp_file.release()); 363 obj_files_.push_back(temp_file.release());
361 } 364 }
362 } 365 }
363 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); 366 invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid());
364 367
365 // Open the nexe file for connecting ld and sel_ldr. 368 // Open the nexe file for connecting ld and sel_ldr.
366 // Start translation when done with this last step of setup! 369 // Start translation when done with this last step of setup!
367 PP_FileHandle nexe_handle =
368 plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
369 temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle));
370 RunTranslate(temp_nexe_file_->Open(true)); 370 RunTranslate(temp_nexe_file_->Open(true));
371 } 371 }
372 372
373 void PnaclCoordinator::BitcodeStreamGotData(const void* data, int32_t length) { 373 void PnaclCoordinator::BitcodeStreamGotData(const void* data, int32_t length) {
374 DCHECK(translate_thread_.get()); 374 DCHECK(translate_thread_.get());
375 375
376 translate_thread_->PutBytes(data, length); 376 translate_thread_->PutBytes(data, length);
377 if (data && length > 0) 377 if (data && length > 0)
378 pexe_size_ += length; 378 pexe_size_ += length;
379 } 379 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 invalid_desc_wrapper_.get(), 465 invalid_desc_wrapper_.get(),
466 &error_info_, 466 &error_info_,
467 resources_.get(), 467 resources_.get(),
468 &pnacl_options_, 468 &pnacl_options_,
469 architecture_attributes_, 469 architecture_attributes_,
470 this, 470 this,
471 plugin_); 471 plugin_);
472 } 472 }
473 473
474 } // namespace plugin 474 } // namespace plugin
OLDNEW
« no previous file with comments | « no previous file | trunk/src/ppapi/native_client/src/trusted/plugin/temporary_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698