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

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: adjust expectations for other UMA test 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 size_t replace_pos; 537 size_t replace_pos;
538 static const char* white_list = "abcdefghijklmnopqrstuvwxyz0123456789_"; 538 static const char* white_list = "abcdefghijklmnopqrstuvwxyz0123456789_";
539 replace_pos = r.find_first_not_of(white_list); 539 replace_pos = r.find_first_not_of(white_list);
540 while(replace_pos != std::string::npos) { 540 while(replace_pos != std::string::npos) {
541 r = r.replace(replace_pos, 1, "_"); 541 r = r.replace(replace_pos, 1, "_");
542 replace_pos = r.find_first_not_of(white_list); 542 replace_pos = r.find_first_not_of(white_list);
543 } 543 }
544 return r; 544 return r;
545 } 545 }
546 546
547 PP_FileHandle GetReadonlyPnaclFd(const char* url) { 547 PP_FileHandle GetReadonlyPnaclFd(const char* url, bool is_executable,
548 uint64_t *nonce_lo, uint64_t *nonce_hi) {
teravest 2014/06/26 21:19:24 Chromium style is "uint64_t* nonce_lo". It trips m
jvoung (off chromium) 2014/06/26 22:48:39 oops -- done.
548 std::string filename = PnaclComponentURLToFilename(url); 549 std::string filename = PnaclComponentURLToFilename(url);
549 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); 550 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
550 IPC::Sender* sender = content::RenderThread::Get(); 551 IPC::Sender* sender = content::RenderThread::Get();
551 DCHECK(sender); 552 DCHECK(sender);
552 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( 553 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD(
553 std::string(filename), 554 std::string(filename), is_executable,
554 &out_fd))) { 555 &out_fd, nonce_lo, nonce_hi))) {
555 return PP_kInvalidFileHandle; 556 return PP_kInvalidFileHandle;
556 } 557 }
557 if (out_fd == IPC::InvalidPlatformFileForTransit()) { 558 if (out_fd == IPC::InvalidPlatformFileForTransit()) {
558 return PP_kInvalidFileHandle; 559 return PP_kInvalidFileHandle;
559 } 560 }
560 return IPC::PlatformFileForTransitToPlatformFile(out_fd); 561 return IPC::PlatformFileForTransitToPlatformFile(out_fd);
561 } 562 }
562 563
564 void GetReadExecPnaclFd(const char* url,
565 PP_NaClFileInfo* out_file_info) {
566 *out_file_info = kInvalidNaClFileInfo;
567 out_file_info->handle = GetReadonlyPnaclFd(url, true /* is_executable */,
568 &out_file_info->token_lo,
569 &out_file_info->token_hi);
570 }
571
563 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { 572 PP_FileHandle CreateTemporaryFile(PP_Instance instance) {
564 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); 573 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit();
565 IPC::Sender* sender = content::RenderThread::Get(); 574 IPC::Sender* sender = content::RenderThread::Get();
566 DCHECK(sender); 575 DCHECK(sender);
567 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( 576 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile(
568 &transit_fd))) { 577 &transit_fd))) {
569 return PP_kInvalidFileHandle; 578 return PP_kInvalidFileHandle;
570 } 579 }
571 580
572 if (transit_fd == IPC::InvalidPlatformFileForTransit()) { 581 if (transit_fd == IPC::InvalidPlatformFileForTransit()) {
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1120
1112 PP_Bool GetPNaClResourceInfo(PP_Instance instance, 1121 PP_Bool GetPNaClResourceInfo(PP_Instance instance,
1113 const char* filename, 1122 const char* filename,
1114 PP_Var* llc_tool_name, 1123 PP_Var* llc_tool_name,
1115 PP_Var* ld_tool_name) { 1124 PP_Var* ld_tool_name) {
1116 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1125 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1117 DCHECK(load_manager); 1126 DCHECK(load_manager);
1118 if (!load_manager) 1127 if (!load_manager)
1119 return PP_FALSE; 1128 return PP_FALSE;
1120 1129
1121 base::File file(GetReadonlyPnaclFd(filename)); 1130 uint64_t nonce_lo = 0;
1131 uint64_t nonce_hi = 0;
1132 base::File file(GetReadonlyPnaclFd(filename, false /* is_executable */,
1133 &nonce_lo, &nonce_hi));
1122 if (!file.IsValid()) { 1134 if (!file.IsValid()) {
1123 load_manager->ReportLoadError( 1135 load_manager->ReportLoadError(
1124 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, 1136 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1125 "The Portable Native Client (pnacl) component is not " 1137 "The Portable Native Client (pnacl) component is not "
1126 "installed. Please consult chrome://components for more " 1138 "installed. Please consult chrome://components for more "
1127 "information."); 1139 "information.");
1128 return PP_FALSE; 1140 return PP_FALSE;
1129 } 1141 }
1130 1142
1131 base::File::Info file_info; 1143 base::File::Info file_info;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 FROM_HERE, 1449 FROM_HERE,
1438 base::Bind(callback, 1450 base::Bind(callback,
1439 static_cast<int32_t>(PP_ERROR_FAILED), 1451 static_cast<int32_t>(PP_ERROR_FAILED),
1440 kInvalidNaClFileInfo)); 1452 kInvalidNaClFileInfo));
1441 return; 1453 return;
1442 } 1454 }
1443 1455
1444 // Handle special PNaCl support files which are installed on the user's 1456 // Handle special PNaCl support files which are installed on the user's
1445 // machine. 1457 // machine.
1446 if (url.find(kPNaClTranslatorBaseUrl, 0) == 0) { 1458 if (url.find(kPNaClTranslatorBaseUrl, 0) == 0) {
1447 PP_FileHandle handle = GetReadonlyPnaclFd(url.c_str()); 1459 PP_NaClFileInfo file_info = kInvalidNaClFileInfo;
1460 PP_FileHandle handle = GetReadonlyPnaclFd(url.c_str(),
1461 false /* executable*/,
1462 &file_info.token_lo,
1463 &file_info.token_hi);
1448 if (handle == PP_kInvalidFileHandle) { 1464 if (handle == PP_kInvalidFileHandle) {
1449 base::MessageLoop::current()->PostTask( 1465 base::MessageLoop::current()->PostTask(
1450 FROM_HERE, 1466 FROM_HERE,
1451 base::Bind(callback, 1467 base::Bind(callback,
1452 static_cast<int32_t>(PP_ERROR_FAILED), 1468 static_cast<int32_t>(PP_ERROR_FAILED),
1453 kInvalidNaClFileInfo)); 1469 kInvalidNaClFileInfo));
1454 return; 1470 return;
1455 } 1471 }
1456 // TODO(ncbray): enable the fast loading and validation paths for this type
1457 // of file.
1458 PP_NaClFileInfo file_info;
1459 file_info.handle = handle; 1472 file_info.handle = handle;
1460 file_info.token_lo = 0;
1461 file_info.token_hi = 0;
1462 base::MessageLoop::current()->PostTask( 1473 base::MessageLoop::current()->PostTask(
1463 FROM_HERE, 1474 FROM_HERE,
1464 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); 1475 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info));
1465 return; 1476 return;
1466 } 1477 }
1467 1478
1468 // We have to ensure that this url resolves relative to the plugin base url 1479 // We have to ensure that this url resolves relative to the plugin base url
1469 // before downloading it. 1480 // before downloading it.
1470 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); 1481 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url);
1471 if (!test_gurl.is_valid()) { 1482 if (!test_gurl.is_valid()) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 DownloadFile(instance, url, 1595 DownloadFile(instance, url,
1585 base::Bind(&DidOpenManifestEntry, out_file_info, callback)); 1596 base::Bind(&DidOpenManifestEntry, out_file_info, callback));
1586 } 1597 }
1587 1598
1588 const PPB_NaCl_Private nacl_interface = { 1599 const PPB_NaCl_Private nacl_interface = {
1589 &LaunchSelLdr, 1600 &LaunchSelLdr,
1590 &StartPpapiProxy, 1601 &StartPpapiProxy,
1591 &UrandomFD, 1602 &UrandomFD,
1592 &Are3DInterfacesDisabled, 1603 &Are3DInterfacesDisabled,
1593 &BrokerDuplicateHandle, 1604 &BrokerDuplicateHandle,
1594 &GetReadonlyPnaclFd, 1605 &GetReadExecPnaclFd,
1595 &CreateTemporaryFile, 1606 &CreateTemporaryFile,
1596 &GetNumberOfProcessors, 1607 &GetNumberOfProcessors,
1597 &PPIsNonSFIModeEnabled, 1608 &PPIsNonSFIModeEnabled,
1598 &GetNexeFd, 1609 &GetNexeFd,
1599 &ReportTranslationFinished, 1610 &ReportTranslationFinished,
1600 &DispatchEvent, 1611 &DispatchEvent,
1601 &ReportLoadSuccess, 1612 &ReportLoadSuccess,
1602 &ReportLoadError, 1613 &ReportLoadError,
1603 &ReportLoadAbort, 1614 &ReportLoadAbort,
1604 &NexeDidCrash, 1615 &NexeDidCrash,
(...skipping 22 matching lines...) Expand all
1627 &OpenManifestEntry 1638 &OpenManifestEntry
1628 }; 1639 };
1629 1640
1630 } // namespace 1641 } // namespace
1631 1642
1632 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1643 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1633 return &nacl_interface; 1644 return &nacl_interface;
1634 } 1645 }
1635 1646
1636 } // namespace nacl 1647 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698