summaryrefslogtreecommitdiffstats
path: root/components/nacl/common
diff options
context:
space:
mode:
authoryusukes <yusukes@chromium.org>2015-03-10 11:51:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-10 18:52:23 +0000
commit67e8acdac9e043dd710058ef2e01ca7ad2b29825 (patch)
treeb5d78e0812e8be26779a803bfc53fa69b986e969 /components/nacl/common
parentefe950c2db75b0cfd043e068a4cfc68ab393dac4 (diff)
downloadchromium_src-67e8acdac9e043dd710058ef2e01ca7ad2b29825.zip
chromium_src-67e8acdac9e043dd710058ef2e01ca7ad2b29825.tar.gz
chromium_src-67e8acdac9e043dd710058ef2e01ca7ad2b29825.tar.bz2
Non-SFI NaCl: Batch-open resource files
* Let the renderer pass URLs and manifest keys of the resource files when it asks the browser to start a new plugin process. * The browser opens all the URLs and passes file handlers to the plugin process if the process is for non-SFI mode. * Modify the non-SFI loader so that it can return a pre-opened handle without doing a renderer IPC when open_resource IRT is called. This CL does not change the current behavior of SFI NaCl. SFI NaCl support will be added in a separate CL: https://codereview.chromium.org/728113002/ Note that this CL is primarily for ARC (App Runtime for Chrome) which has 70+ DSO files. With this CL, the loading time of arc.nexe gets ~40% shorter. This CL should not affect NaCl applications other than ARC because most of them do not have that many DSO files, and even if they have some, opening one DSO file in the browser process takes only about 0.4ms (on Z620) which is usually negligible. TEST=PackagedAppTest.SuccessfulLoad TEST=manually checked that SFI-NaCl and PNaCl are still working. BUG=nativeclient:3802 BUG=348232 Review URL: https://codereview.chromium.org/649603004 Cr-Commit-Position: refs/heads/master@{#319931}
Diffstat (limited to 'components/nacl/common')
-rw-r--r--components/nacl/common/nacl_host_messages.h1
-rw-r--r--components/nacl/common/nacl_messages.h7
-rw-r--r--components/nacl/common/nacl_types.cc17
-rw-r--r--components/nacl/common/nacl_types.h37
4 files changed, 54 insertions, 8 deletions
diff --git a/components/nacl/common/nacl_host_messages.h b/components/nacl/common/nacl_host_messages.h
index b57ff1d..21cdd6d 100644
--- a/components/nacl/common/nacl_host_messages.h
+++ b/components/nacl/common/nacl_host_messages.h
@@ -25,6 +25,7 @@ IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams)
IPC_STRUCT_TRAITS_MEMBER(nexe_file)
IPC_STRUCT_TRAITS_MEMBER(nexe_token_lo)
IPC_STRUCT_TRAITS_MEMBER(nexe_token_hi)
+ IPC_STRUCT_TRAITS_MEMBER(resource_files_to_prefetch)
IPC_STRUCT_TRAITS_MEMBER(render_view_id)
IPC_STRUCT_TRAITS_MEMBER(permission_bits)
IPC_STRUCT_TRAITS_MEMBER(uses_nonsfi_mode)
diff --git a/components/nacl/common/nacl_messages.h b/components/nacl/common/nacl_messages.h
index 51a73f8..191d5b9 100644
--- a/components/nacl/common/nacl_messages.h
+++ b/components/nacl/common/nacl_messages.h
@@ -17,6 +17,7 @@
IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams)
IPC_STRUCT_TRAITS_MEMBER(nexe_file)
IPC_STRUCT_TRAITS_MEMBER(nexe_file_path_metadata)
+ IPC_STRUCT_TRAITS_MEMBER(prefetched_resource_files)
IPC_STRUCT_TRAITS_MEMBER(handles)
IPC_STRUCT_TRAITS_MEMBER(debug_stub_server_bound_socket)
IPC_STRUCT_TRAITS_MEMBER(validation_cache_enabled)
@@ -29,6 +30,12 @@ IPC_STRUCT_TRAITS_BEGIN(nacl::NaClStartParams)
IPC_STRUCT_TRAITS_MEMBER(crash_info_shmem_handle)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(nacl::NaClResourceFileInfo)
+ IPC_STRUCT_TRAITS_MEMBER(file)
+ IPC_STRUCT_TRAITS_MEMBER(file_path_metadata)
+ IPC_STRUCT_TRAITS_MEMBER(file_key)
+IPC_STRUCT_TRAITS_END()
+
//-----------------------------------------------------------------------------
// NaClProcess messages
// These are messages sent between the browser and the NaCl process.
diff --git a/components/nacl/common/nacl_types.cc b/components/nacl/common/nacl_types.cc
index fec4a02..4abb828 100644
--- a/components/nacl/common/nacl_types.cc
+++ b/components/nacl/common/nacl_types.cc
@@ -20,6 +20,20 @@ NaClStartParams::NaClStartParams()
NaClStartParams::~NaClStartParams() {
}
+NaClResourceFileInfo::NaClResourceFileInfo()
+ : file(IPC::InvalidPlatformFileForTransit()) {
+}
+
+NaClResourceFileInfo::NaClResourceFileInfo(
+ IPC::PlatformFileForTransit file,
+ const base::FilePath& file_path_metadata,
+ const std::string& file_key)
+ : file(file), file_path_metadata(file_path_metadata), file_key(file_key) {
+}
+
+NaClResourceFileInfo::~NaClResourceFileInfo() {
+}
+
NaClLaunchParams::NaClLaunchParams()
: nexe_file(IPC::InvalidPlatformFileForTransit()),
nexe_token_lo(0),
@@ -34,6 +48,8 @@ NaClLaunchParams::NaClLaunchParams(
const IPC::PlatformFileForTransit& nexe_file,
uint64_t nexe_token_lo,
uint64_t nexe_token_hi,
+ const std::vector<
+ std::pair<std::string, std::string> >& resource_files_to_prefetch,
int render_view_id,
uint32 permission_bits,
bool uses_nonsfi_mode,
@@ -42,6 +58,7 @@ NaClLaunchParams::NaClLaunchParams(
nexe_file(nexe_file),
nexe_token_lo(nexe_token_lo),
nexe_token_hi(nexe_token_hi),
+ resource_files_to_prefetch(resource_files_to_prefetch),
render_view_id(render_view_id),
permission_bits(permission_bits),
uses_nonsfi_mode(uses_nonsfi_mode),
diff --git a/components/nacl/common/nacl_types.h b/components/nacl/common/nacl_types.h
index 11aaeb9..f691edf 100644
--- a/components/nacl/common/nacl_types.h
+++ b/components/nacl/common/nacl_types.h
@@ -6,6 +6,7 @@
#define COMPONENTS_NACL_COMMON_NACL_TYPES_H_
#include <string>
+#include <utility>
#include <vector>
#include "base/basictypes.h"
@@ -57,6 +58,20 @@ enum NaClAppProcessType {
kNumNaClProcessTypes
};
+// Represents a single prefetched file that's listed in the "files" section of
+// a NaCl manifest file.
+struct NaClResourceFileInfo {
+ NaClResourceFileInfo();
+ NaClResourceFileInfo(IPC::PlatformFileForTransit file,
+ const base::FilePath& file_path,
+ const std::string& file_key);
+ ~NaClResourceFileInfo();
+
+ IPC::PlatformFileForTransit file;
+ base::FilePath file_path_metadata; // a key for validation caching
+ std::string file_key; // a key for open_resource
+};
+
// Parameters sent to the NaCl process when we start it.
struct NaClStartParams {
NaClStartParams();
@@ -66,6 +81,7 @@ struct NaClStartParams {
// Used only as a key for validation caching.
base::FilePath nexe_file_path_metadata;
+ std::vector<NaClResourceFileInfo> prefetched_resource_files;
std::vector<FileDescriptor> handles;
FileDescriptor debug_stub_server_bound_socket;
@@ -98,14 +114,18 @@ struct NaClStartParams {
// nacl_host_messages.h.
struct NaClLaunchParams {
NaClLaunchParams();
- NaClLaunchParams(const std::string& manifest_url,
- const IPC::PlatformFileForTransit& nexe_file,
- uint64_t nexe_token_lo,
- uint64_t nexe_token_hi,
- int render_view_id,
- uint32 permission_bits,
- bool uses_nonsfi_mode,
- NaClAppProcessType process_type);
+ NaClLaunchParams(
+ const std::string& manifest_url,
+ const IPC::PlatformFileForTransit& nexe_file,
+ uint64_t nexe_token_lo,
+ uint64_t nexe_token_hi,
+ // A pair of a manifest key and its resource URL.
+ const std::vector<
+ std::pair<std::string, std::string> >& resource_files_to_prefetch,
+ int render_view_id,
+ uint32 permission_bits,
+ bool uses_nonsfi_mode,
+ NaClAppProcessType process_type);
~NaClLaunchParams();
std::string manifest_url;
@@ -115,6 +135,7 @@ struct NaClLaunchParams {
IPC::PlatformFileForTransit nexe_file;
uint64_t nexe_token_lo;
uint64_t nexe_token_hi;
+ std::vector<std::pair<std::string, std::string> > resource_files_to_prefetch;
int render_view_id;
uint32 permission_bits;