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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_resources.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 (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_resources.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h"
6 6
7 #include "native_client/src/include/portability_io.h" 7 #include "native_client/src/include/portability_io.h"
8 #include "native_client/src/shared/platform/nacl_check.h" 8 #include "native_client/src/shared/platform/nacl_check.h"
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 11 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
12 #include "ppapi/native_client/src/trusted/plugin/utility.h" 12 #include "ppapi/native_client/src/trusted/plugin/utility.h"
13 13
14 namespace plugin { 14 namespace plugin {
15 15
16 namespace { 16 namespace {
17 17
18 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; 18 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/";
19 19
20 nacl::string GetFullUrl(const nacl::string& partial_url) { 20 nacl::string GetFullUrl(const nacl::string& partial_url) {
21 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() + 21 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() +
22 "/" + partial_url; 22 "/" + partial_url;
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 PnaclResources::PnaclResources(Plugin* plugin)
28 : plugin_(plugin) {
29 llc_file_info_ = kInvalidNaClFileInfo;
30 ld_file_info_ = kInvalidNaClFileInfo;
31 }
32
27 PnaclResources::~PnaclResources() { 33 PnaclResources::~PnaclResources() {
28 if (llc_file_handle_ != PP_kInvalidFileHandle) 34 if (llc_file_info_.handle != PP_kInvalidFileHandle)
29 CloseFileHandle(llc_file_handle_); 35 CloseFileHandle(llc_file_info_.handle);
30 if (ld_file_handle_ != PP_kInvalidFileHandle) 36 if (ld_file_info_.handle != PP_kInvalidFileHandle)
31 CloseFileHandle(ld_file_handle_); 37 CloseFileHandle(ld_file_info_.handle);
32 } 38 }
33 39
34 bool PnaclResources::ReadResourceInfo() { 40 bool PnaclResources::ReadResourceInfo() {
35 PP_Var pp_llc_tool_name_var; 41 PP_Var pp_llc_tool_name_var;
36 PP_Var pp_ld_tool_name_var; 42 PP_Var pp_ld_tool_name_var;
37 if (!plugin_->nacl_interface()->GetPnaclResourceInfo( 43 if (!plugin_->nacl_interface()->GetPnaclResourceInfo(
38 plugin_->pp_instance(), 44 plugin_->pp_instance(),
39 "chrome://pnacl-translator/pnacl.json", 45 "chrome://pnacl-translator/pnacl.json",
40 &pp_llc_tool_name_var, 46 &pp_llc_tool_name_var,
41 &pp_ld_tool_name_var)) { 47 &pp_ld_tool_name_var)) {
42 return false; 48 return false;
43 } 49 }
44 pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var); 50 pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var);
45 pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var); 51 pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var);
46 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString()); 52 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString());
47 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString()); 53 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString());
48 return true; 54 return true;
49 } 55 }
50 56
51 PP_FileHandle PnaclResources::TakeLlcFileHandle() { 57 PP_NaClFileInfo PnaclResources::TakeLlcFileInfo() {
52 PP_FileHandle to_return = llc_file_handle_; 58 PP_NaClFileInfo to_return = llc_file_info_;
53 llc_file_handle_ = PP_kInvalidFileHandle; 59 llc_file_info_ = kInvalidNaClFileInfo;
54 return to_return; 60 return to_return;
55 } 61 }
56 62
57 PP_FileHandle PnaclResources::TakeLdFileHandle() { 63 PP_NaClFileInfo PnaclResources::TakeLdFileInfo() {
58 PP_FileHandle to_return = ld_file_handle_; 64 PP_NaClFileInfo to_return = ld_file_info_;
59 ld_file_handle_ = PP_kInvalidFileHandle; 65 ld_file_info_ = kInvalidNaClFileInfo;
60 return to_return; 66 return to_return;
61 } 67 }
62 68
63 bool PnaclResources::StartLoad() { 69 bool PnaclResources::StartLoad() {
64 PLUGIN_PRINTF(("PnaclResources::StartLoad\n")); 70 PLUGIN_PRINTF(("PnaclResources::StartLoad\n"));
65 71
66 // Do a blocking load of each of the resources. 72 // Do a blocking load of each of the resources.
67 llc_file_handle_ = 73 plugin_->nacl_interface()->GetReadExecPnaclFd(llc_tool_name_.c_str(),
68 plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str()); 74 &llc_file_info_);
69 ld_file_handle_ = 75 plugin_->nacl_interface()->GetReadExecPnaclFd(ld_tool_name_.c_str(),
70 plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str()); 76 &ld_file_info_);
71 return (llc_file_handle_ != PP_kInvalidFileHandle && 77 return (llc_file_info_.handle != PP_kInvalidFileHandle &&
72 ld_file_handle_ != PP_kInvalidFileHandle); 78 ld_file_info_.handle != PP_kInvalidFileHandle);
73 } 79 }
74 80
75 } // namespace plugin 81 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698