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

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

Issue 8525014: Get all the resources relative to a single base. Currently the same base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_coordinator.h" 5 #include "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/portability_io.h" 10 #include "native_client/src/include/portability_io.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // Helper functions for loading native libs. 341 // Helper functions for loading native libs.
342 // Done here to avoid hacking on the manifest parser further... 342 // Done here to avoid hacking on the manifest parser further...
343 343
344 namespace { 344 namespace {
345 345
346 // Fake filename for the object file generated by llvm. 346 // Fake filename for the object file generated by llvm.
347 nacl::string GeneratedObjectFileName() { 347 nacl::string GeneratedObjectFileName() {
348 return nacl::string("___PNACL_GENERATED"); 348 return nacl::string("___PNACL_GENERATED");
349 } 349 }
350 350
351 string_vector LinkResources(const nacl::string& sandbox_isa, 351 nacl::string ResourceBaseUrl() {
352 bool withGenerated) { 352 nacl::string sandbox_isa = GetSandboxISA();
353 nacl::string base_url = "pnacl_support/" + sandbox_isa + "/";
354 return base_url;
355 }
356
357 string_vector LinkResources(bool withGenerated) {
353 string_vector results; 358 string_vector results;
354 nacl::string base_dir = "pnacl_support/" + sandbox_isa;
355
356 // NOTE: order of items == link order. 359 // NOTE: order of items == link order.
357 results.push_back(base_dir + "/crtbegin.o"); 360 results.push_back("crtbegin.o");
358 if (withGenerated) { 361 if (withGenerated) {
359 results.push_back(GeneratedObjectFileName()); 362 results.push_back(GeneratedObjectFileName());
360 } 363 }
361 results.push_back(base_dir + "/libcrt_platform.a"); 364 results.push_back("libcrt_platform.a");
362 results.push_back(base_dir + "/libgcc.a"); 365 results.push_back("libgcc.a");
363 results.push_back(base_dir + "/libgcc_eh.a"); 366 results.push_back("libgcc_eh.a");
364 results.push_back(base_dir + "/crtend.o"); 367 results.push_back("crtend.o");
365 return results; 368 return results;
366 } 369 }
367 370
368 } // namespace 371 } // namespace
369 372
370 ////////////////////////////////////////////////////////////////////// 373 //////////////////////////////////////////////////////////////////////
371 // Final link callbacks. 374 // Final link callbacks.
372 375
373 namespace { 376 namespace {
374 377
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 "C", 425 "C",
423 &dummy_params, 426 &dummy_params,
424 flag.c_str())) { 427 flag.c_str())) {
425 AbortLinkThread(p, 428 AbortLinkThread(p,
426 "PnaclCoordinator linker AddArg(" + flag + 429 "PnaclCoordinator linker AddArg(" + flag +
427 ") failed."); 430 ") failed.");
428 } 431 }
429 } 432 }
430 433
431 //// Files. 434 //// Files.
432 string_vector files = LinkResources(sandbox_isa, true); 435 string_vector files = LinkResources(true);
433 PnaclResources* resources = coordinator->resources(); 436 PnaclResources* resources = coordinator->resources();
434 for (string_vector::iterator i = files.begin(), e = files.end(); 437 for (string_vector::iterator i = files.begin(), e = files.end();
435 i != e; ++i) { 438 i != e; ++i) {
436 const nacl::string& link_file = *i; 439 const nacl::string& link_file = *i;
437 if (coordinator->SubprocessesShouldDie()) { 440 if (coordinator->SubprocessesShouldDie()) {
438 NaClThreadExit(1); 441 NaClThreadExit(1);
439 } 442 }
440 // Add as argument. 443 // Add as argument.
441 SrpcParams dummy_params; 444 SrpcParams dummy_params;
442 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface, 445 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 error_info.SetReport(ERROR_UNKNOWN, 581 error_info.SetReport(ERROR_UNKNOWN,
579 "PnaclCoordinator: Failed to download file: " + 582 "PnaclCoordinator: Failed to download file: " +
580 pexe_url + "\n"); 583 pexe_url + "\n");
581 ReportLoadError(error_info); 584 ReportLoadError(error_info);
582 PnaclNonPpapiError(); 585 PnaclNonPpapiError();
583 } 586 }
584 } 587 }
585 588
586 void PnaclCoordinator::BitcodeToNative( 589 void PnaclCoordinator::BitcodeToNative(
587 const nacl::string& pexe_url, 590 const nacl::string& pexe_url,
588 const nacl::string& llc_url,
589 const nacl::string& ld_url,
590 const pp::CompletionCallback& finish_callback) { 591 const pp::CompletionCallback& finish_callback) {
591 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (pexe=%s, llc=%s, ld=%s)\n", 592 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (pexe=%s)\n",
592 pexe_url.c_str(), 593 pexe_url.c_str()));
593 llc_url.c_str(), 594 // The base URL for finding all the resources will be obtained from the
594 ld_url.c_str())); 595 // PNaCl manifest file.
595 llc_url_ = llc_url; 596 // Also, the llc and ld pathnames should be read from the manifest.
596 ld_url_ = ld_url; 597 // TODO(sehr): change to use the manifest file when ready.
598 resource_base_url_ = ResourceBaseUrl();
599 llc_url_ = "llc";
600 ld_url_ = "ld";
597 translate_notify_callback_ = finish_callback; 601 translate_notify_callback_ = finish_callback;
598 602
599 // Steps: 603 // Steps:
600 // (1) Schedule downloads for llc, ld nexes, and native libraries (resources). 604 // (1) Schedule downloads for llc, ld nexes, and native libraries (resources).
601 // (2) When resources have been downloaded, download pexe. 605 // (2) When resources have been downloaded, download pexe.
602 // (3) When pexe download has completed, start translation. 606 // (3) When pexe download has completed, start translation.
603 // (4) When llc translation has finished do the link. 607 // (4) When llc translation has finished do the link.
604 // (5) When the link is done, we are done, call the finish_callback. 608 // (5) When the link is done, we are done, call the finish_callback.
605 // Hand off the SHM file descriptor returned by link. 609 // Hand off the SHM file descriptor returned by link.
606 610
607 // Set up async callbacks for these steps in reverse order. 611 // Set up async callbacks for these steps in reverse order.
608 612
609 translation_unit_.reset(new PnaclTranslationUnit(this)); 613 translation_unit_.reset(new PnaclTranslationUnit(this));
610 614
611 // When resources loading completes, this causes the pexe download. 615 // When resources loading completes, this causes the pexe download.
612 pp::CompletionCallback resources_cb = 616 pp::CompletionCallback resources_cb =
613 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad, 617 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad,
614 pexe_url, 618 pexe_url,
615 translation_unit_.get()); 619 translation_unit_.get());
616 resources_->AddResourceUrl(llc_url); 620 resources_->AddResourceUrl(llc_url_);
617 resources_->AddResourceUrl(ld_url); 621 resources_->AddResourceUrl(ld_url_);
618 string_vector link_resources = LinkResources(GetSandboxISA(), false); 622 string_vector link_resources = LinkResources(false);
619 for (string_vector::iterator 623 for (string_vector::iterator
620 i = link_resources.begin(), e = link_resources.end(); 624 i = link_resources.begin(), e = link_resources.end();
621 i != e; 625 i != e;
622 ++i) { 626 ++i) {
623 resources_->AddResourceUrl(*i); 627 resources_->AddResourceUrl(*i);
624 } 628 }
625 resources_->RunWhenAllLoaded(resources_cb); 629 resources_->RunWhenAllLoaded(resources_cb);
626 resources_->StartDownloads(); 630 resources_->StartDownloads();
627 } 631 }
628 632
629 } // namespace plugin 633 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h ('k') | ppapi/native_client/src/trusted/plugin/pnacl_resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698