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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 356923004: Enable mmap and identity-based validation caching on pnacl-{llc,ld}.nexe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 size_t replace_pos; 523 size_t replace_pos;
524 static const char* white_list = "abcdefghijklmnopqrstuvwxyz0123456789_"; 524 static const char* white_list = "abcdefghijklmnopqrstuvwxyz0123456789_";
525 replace_pos = r.find_first_not_of(white_list); 525 replace_pos = r.find_first_not_of(white_list);
526 while(replace_pos != std::string::npos) { 526 while(replace_pos != std::string::npos) {
527 r = r.replace(replace_pos, 1, "_"); 527 r = r.replace(replace_pos, 1, "_");
528 replace_pos = r.find_first_not_of(white_list); 528 replace_pos = r.find_first_not_of(white_list);
529 } 529 }
530 return r; 530 return r;
531 } 531 }
532 532
533 PP_FileHandle GetReadonlyPnaclFd(const char* url) { 533 PP_FileHandle GetReadonlyPnaclFd(const char* url,
534 bool is_executable,
535 uint64_t* nonce_lo,
536 uint64_t* nonce_hi) {
534 std::string filename = PnaclComponentURLToFilename(url); 537 std::string filename = PnaclComponentURLToFilename(url);
535 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); 538 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
536 IPC::Sender* sender = content::RenderThread::Get(); 539 IPC::Sender* sender = content::RenderThread::Get();
537 DCHECK(sender); 540 DCHECK(sender);
538 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( 541 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD(
539 std::string(filename), 542 std::string(filename), is_executable,
540 &out_fd))) { 543 &out_fd, nonce_lo, nonce_hi))) {
541 return PP_kInvalidFileHandle; 544 return PP_kInvalidFileHandle;
542 } 545 }
543 if (out_fd == IPC::InvalidPlatformFileForTransit()) { 546 if (out_fd == IPC::InvalidPlatformFileForTransit()) {
544 return PP_kInvalidFileHandle; 547 return PP_kInvalidFileHandle;
545 } 548 }
546 return IPC::PlatformFileForTransitToPlatformFile(out_fd); 549 return IPC::PlatformFileForTransitToPlatformFile(out_fd);
547 } 550 }
548 551
552 void GetReadExecPnaclFd(const char* url,
553 PP_NaClFileInfo* out_file_info) {
554 *out_file_info = kInvalidNaClFileInfo;
555 out_file_info->handle = GetReadonlyPnaclFd(url, true /* is_executable */,
556 &out_file_info->token_lo,
557 &out_file_info->token_hi);
558 }
559
549 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { 560 PP_FileHandle CreateTemporaryFile(PP_Instance instance) {
550 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); 561 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit();
551 IPC::Sender* sender = content::RenderThread::Get(); 562 IPC::Sender* sender = content::RenderThread::Get();
552 DCHECK(sender); 563 DCHECK(sender);
553 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( 564 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile(
554 &transit_fd))) { 565 &transit_fd))) {
555 return PP_kInvalidFileHandle; 566 return PP_kInvalidFileHandle;
556 } 567 }
557 568
558 if (transit_fd == IPC::InvalidPlatformFileForTransit()) { 569 if (transit_fd == IPC::InvalidPlatformFileForTransit()) {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1112
1102 PP_Bool GetPNaClResourceInfo(PP_Instance instance, 1113 PP_Bool GetPNaClResourceInfo(PP_Instance instance,
1103 const char* filename, 1114 const char* filename,
1104 PP_Var* llc_tool_name, 1115 PP_Var* llc_tool_name,
1105 PP_Var* ld_tool_name) { 1116 PP_Var* ld_tool_name) {
1106 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1117 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1107 DCHECK(load_manager); 1118 DCHECK(load_manager);
1108 if (!load_manager) 1119 if (!load_manager)
1109 return PP_FALSE; 1120 return PP_FALSE;
1110 1121
1111 base::File file(GetReadonlyPnaclFd(filename)); 1122 uint64_t nonce_lo = 0;
1123 uint64_t nonce_hi = 0;
1124 base::File file(GetReadonlyPnaclFd(filename, false /* is_executable */,
1125 &nonce_lo, &nonce_hi));
1112 if (!file.IsValid()) { 1126 if (!file.IsValid()) {
1113 load_manager->ReportLoadError( 1127 load_manager->ReportLoadError(
1114 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, 1128 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1115 "The Portable Native Client (pnacl) component is not " 1129 "The Portable Native Client (pnacl) component is not "
1116 "installed. Please consult chrome://components for more " 1130 "installed. Please consult chrome://components for more "
1117 "information."); 1131 "information.");
1118 return PP_FALSE; 1132 return PP_FALSE;
1119 } 1133 }
1120 1134
1121 base::File::Info file_info; 1135 base::File::Info file_info;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 FROM_HERE, 1441 FROM_HERE,
1428 base::Bind(callback, 1442 base::Bind(callback,
1429 static_cast<int32_t>(PP_ERROR_FAILED), 1443 static_cast<int32_t>(PP_ERROR_FAILED),
1430 kInvalidNaClFileInfo)); 1444 kInvalidNaClFileInfo));
1431 return; 1445 return;
1432 } 1446 }
1433 1447
1434 // Handle special PNaCl support files which are installed on the user's 1448 // Handle special PNaCl support files which are installed on the user's
1435 // machine. 1449 // machine.
1436 if (url.find(kPNaClTranslatorBaseUrl, 0) == 0) { 1450 if (url.find(kPNaClTranslatorBaseUrl, 0) == 0) {
1437 PP_FileHandle handle = GetReadonlyPnaclFd(url.c_str()); 1451 PP_NaClFileInfo file_info = kInvalidNaClFileInfo;
1452 PP_FileHandle handle = GetReadonlyPnaclFd(url.c_str(),
1453 false /* is_executable */,
1454 &file_info.token_lo,
1455 &file_info.token_hi);
1438 if (handle == PP_kInvalidFileHandle) { 1456 if (handle == PP_kInvalidFileHandle) {
1439 base::MessageLoop::current()->PostTask( 1457 base::MessageLoop::current()->PostTask(
1440 FROM_HERE, 1458 FROM_HERE,
1441 base::Bind(callback, 1459 base::Bind(callback,
1442 static_cast<int32_t>(PP_ERROR_FAILED), 1460 static_cast<int32_t>(PP_ERROR_FAILED),
1443 kInvalidNaClFileInfo)); 1461 kInvalidNaClFileInfo));
1444 return; 1462 return;
1445 } 1463 }
1446 // TODO(ncbray): enable the fast loading and validation paths for this type
1447 // of file.
1448 PP_NaClFileInfo file_info;
1449 file_info.handle = handle; 1464 file_info.handle = handle;
1450 file_info.token_lo = 0;
1451 file_info.token_hi = 0;
1452 base::MessageLoop::current()->PostTask( 1465 base::MessageLoop::current()->PostTask(
1453 FROM_HERE, 1466 FROM_HERE,
1454 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); 1467 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info));
1455 return; 1468 return;
1456 } 1469 }
1457 1470
1458 // We have to ensure that this url resolves relative to the plugin base url 1471 // We have to ensure that this url resolves relative to the plugin base url
1459 // before downloading it. 1472 // before downloading it.
1460 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); 1473 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url);
1461 if (!test_gurl.is_valid()) { 1474 if (!test_gurl.is_valid()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 if (load_manager) 1593 if (load_manager)
1581 load_manager->set_pnacl_start_time(base::Time::Now()); 1594 load_manager->set_pnacl_start_time(base::Time::Now());
1582 } 1595 }
1583 1596
1584 const PPB_NaCl_Private nacl_interface = { 1597 const PPB_NaCl_Private nacl_interface = {
1585 &LaunchSelLdr, 1598 &LaunchSelLdr,
1586 &StartPpapiProxy, 1599 &StartPpapiProxy,
1587 &UrandomFD, 1600 &UrandomFD,
1588 &Are3DInterfacesDisabled, 1601 &Are3DInterfacesDisabled,
1589 &BrokerDuplicateHandle, 1602 &BrokerDuplicateHandle,
1590 &GetReadonlyPnaclFd, 1603 &GetReadExecPnaclFd,
1591 &CreateTemporaryFile, 1604 &CreateTemporaryFile,
1592 &GetNumberOfProcessors, 1605 &GetNumberOfProcessors,
1593 &PPIsNonSFIModeEnabled, 1606 &PPIsNonSFIModeEnabled,
1594 &GetNexeFd, 1607 &GetNexeFd,
1595 &ReportTranslationFinished, 1608 &ReportTranslationFinished,
1596 &DispatchEvent, 1609 &DispatchEvent,
1597 &ReportLoadSuccess, 1610 &ReportLoadSuccess,
1598 &ReportLoadError, 1611 &ReportLoadError,
1599 &ReportLoadAbort, 1612 &ReportLoadAbort,
1600 &NexeDidCrash, 1613 &NexeDidCrash,
(...skipping 23 matching lines...) Expand all
1624 &SetPNaClStartTime 1637 &SetPNaClStartTime
1625 }; 1638 };
1626 1639
1627 } // namespace 1640 } // namespace
1628 1641
1629 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1642 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1630 return &nacl_interface; 1643 return &nacl_interface;
1631 } 1644 }
1632 1645
1633 } // namespace nacl 1646 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698