Commit 1090d2b8 authored by jvoung@chromium.org's avatar jvoung@chromium.org

Set file tokens for NaCl main nexe if available to enable validation caching.

Also enable mmap'ing the main nexe, which may help a bit
in subsequent runs as well (first run the validator needs
page in all of the text anyway).

pnacl-llc.nexe, etc will be handled separately:
https://codereview.chromium.org/224803002/

TEST=NaClBrowserTestVcacheExtension.ValidationCacheOfMainNexe

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3421

Review URL: https://codereview.chromium.org/263683002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272429 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b2f47cc
...@@ -44,6 +44,21 @@ void UMAHistogramHelper::ExpectUniqueSample( ...@@ -44,6 +44,21 @@ void UMAHistogramHelper::ExpectUniqueSample(
} }
} }
void UMAHistogramHelper::ExpectBucketCount(
const std::string& name,
base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count) {
base::HistogramBase* histogram =
base::StatisticsRecorder::FindHistogram(name);
EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
<< "Histogram \"" << name << "\" does not exist.";
if (histogram) {
scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
CheckBucketCount(name, sample, expected_count, *samples);
}
}
void UMAHistogramHelper::ExpectTotalCount( void UMAHistogramHelper::ExpectTotalCount(
const std::string& name, const std::string& name,
base::HistogramBase::Count count) { base::HistogramBase::Count count) {
......
...@@ -26,6 +26,12 @@ class UMAHistogramHelper { ...@@ -26,6 +26,12 @@ class UMAHistogramHelper {
base::HistogramBase::Sample sample, base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count); base::HistogramBase::Count expected_count);
// We know the exact number of samples in a bucket, but other buckets may
// have samples as well.
void ExpectBucketCount(const std::string& name,
base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count);
// We don't know the values of the samples, but we know how many there are. // We don't know the values of the samples, but we know how many there are.
void ExpectTotalCount(const std::string& name, void ExpectTotalCount(const std::string& name,
base::HistogramBase::Count count); base::HistogramBase::Count count);
......
<html>
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<script type="text/javascript" src="nacltest.js"></script>
<script type="text/javascript" src="load_util.js"></script>
<script type="text/javascript" src="extension_validation_cache.js"></script>
<title>NaCl Extension nexe-load validation cache test</title>
</head>
<body>
<h1>NaCl Extension nexe-load validation cache test</h1>
<!-- NaCl embed will be created by extension_validation_cache.js -->
</body>
</html>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function create(manifest_url) {
var embed = load_util.embed(manifest_url);
embed.addEventListener("load", function(evt) {
load_util.shutdown("1 test passed.", true);
}, true);
embed.addEventListener("error", function(evt) {
load_util.log("Load error: " + embed.lastError);
load_util.shutdown("1 test failed.", false);
}, true);
document.body.appendChild(embed);
}
function documentLoaded() {
create('extension_validation_cache.nmf');
}
document.addEventListener('DOMContentLoaded', documentLoaded);
{
"name": "NaCl_ValidationCacheNexeTest",
"version": "0.1",
"manifest_version": 2,
"description": "Tests NaCl validation caching for main nexe from extensions.",
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCoq+cJMuoIaoL2hx//QoIeHnNkXLAEu3IJGcLpM95qbmw9VnAplFI0tpSv4IpuJ1DPPsdsEMhONu1mPhK9xd3BHCtzqXRfRsnx/uOap4NTcUimxiUH3uuX9xkCNWO8EihdV0atnrKROhhnyIxmhgKmKfAYLheOrSGSXP0A4SqaBQIDAQAB"
}
...@@ -80,6 +80,40 @@ ...@@ -80,6 +80,40 @@
], ],
}, },
}, },
{
'target_name': 'extension_validation_cache',
'type': 'none',
'variables': {
'nexe_target': 'extension_validation_cache',
# The test currently only has the test expectations for the
# newlib case (# validation queries/settings), and has also
# hardcoded the newlib variant's directory path for the unpacked ext.
'build_newlib': 1,
'build_glibc': 0,
'build_pnacl_newlib': 0,
# Need a new directory to not clash with with other extension
# tests's files (e.g., manifest.json).
'nexe_destination_dir': 'nacl_test_data/extension_vcache_test',
'sources': [
'simple.cc',
],
'test_files': [
# TODO(ncbray) move into chrome/test/data/nacl when all tests are
# converted.
'<(DEPTH)/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js',
'extension_validation_cache/extension_validation_cache.html',
'extension_validation_cache/extension_validation_cache.js',
# Turns the test data directory into an extension.
# Use a different nexe_destination_dir to isolate the files.
# Note that the .nexe names are embedded in this file.
'extension_validation_cache/manifest.json',
'load_util.js',
],
},
'dependencies': [
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
],
},
{ {
'target_name': 'sysconf_nprocessors_onln_test', 'target_name': 'sysconf_nprocessors_onln_test',
'type': 'none', 'type': 'none',
......
...@@ -440,22 +440,6 @@ IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibStderrPM, RedirectBg1) { ...@@ -440,22 +440,6 @@ IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibStderrPM, RedirectBg1) {
"pm_redir_test.html?stream=stderr&thread=bg&delay_us=1000000")); "pm_redir_test.html?stream=stderr&thread=bg&delay_us=1000000"));
} }
class NaClBrowserTestNewlibExtension : public NaClBrowserTestNewlib {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
NaClBrowserTestNewlib::SetUpCommandLine(command_line);
base::FilePath src_root;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_root));
base::FilePath document_root;
ASSERT_TRUE(GetDocumentRoot(&document_root));
// Document root is relative to source root, and source root may not be CWD.
command_line->AppendSwitchPath(switches::kLoadExtension,
src_root.Append(document_root));
}
};
// TODO(ncbray) support glibc and PNaCl // TODO(ncbray) support glibc and PNaCl
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// crbug.com/375894 // crbug.com/375894
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/test/base/uma_histogram_helper.h" #include "chrome/test/base/uma_histogram_helper.h"
#include "chrome/test/nacl/nacl_browsertest_util.h" #include "chrome/test/nacl/nacl_browsertest_util.h"
#include "components/nacl/browser/nacl_browser.h"
#include "native_client/src/trusted/service_runtime/nacl_error_code.h" #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
#include "ppapi/c/private/ppb_nacl_private.h" #include "ppapi/c/private/ppb_nacl_private.h"
...@@ -26,6 +27,17 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { ...@@ -26,6 +27,17 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, {
histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr", histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr",
LOAD_OK, 1); LOAD_OK, 1);
// Check validation cache usage:
// For the open-web, only the IRT is considered a "safe" and
// identity-cachable file. The nexes and .so files are not.
// Should have one cache query for the IRT.
histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
nacl::NaClBrowser::CACHE_MISS, 1);
// TOTAL should then be 1 query so far.
histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 1);
// Should have received a cache setting afterwards for IRT.
histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 1);
// Make sure we have other important histograms. // Make sure we have other important histograms.
if (!IsAPnaclTest()) { if (!IsAPnaclTest()) {
histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1); histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1);
...@@ -52,6 +64,52 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, { ...@@ -52,6 +64,52 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, {
} }
}) })
class NaClBrowserTestVcacheExtension:
public NaClBrowserTestNewlibExtension {
public:
virtual base::FilePath::StringType Variant() OVERRIDE {
return FILE_PATH_LITERAL("extension_vcache_test/newlib");
}
};
IN_PROC_BROWSER_TEST_F(NaClBrowserTestVcacheExtension,
ValidationCacheOfMainNexe) {
// Hardcoded extension AppID that corresponds to the hardcoded
// public key in the manifest.json file. We need to load the extension
// nexe from the same origin, so we can't just try to load the extension
// nexe as a mime-type handler from a non-extension URL.
base::FilePath::StringType full_url =
FILE_PATH_LITERAL("chrome-extension://cbcdidchbppangcjoddlpdjlenngjldk/")
FILE_PATH_LITERAL("extension_validation_cache.html");
RunNaClIntegrationTest(full_url, true);
// Make sure histograms from child processes have been accumulated in the
// browser brocess.
UMAHistogramHelper histograms;
histograms.Fetch();
// Should have received 2 validation queries (one for IRT and one for NEXE),
// and responded with a miss.
histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
nacl::NaClBrowser::CACHE_MISS, 2);
// TOTAL should then be 2 queries so far.
histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 2);
// Should have received a cache setting afterwards for IRT and nexe.
histograms.ExpectBucketCount("NaCl.ValidationCache.Set",
nacl::NaClBrowser::CACHE_HIT, 2);
// Load it again to hit the cache.
RunNaClIntegrationTest(full_url, true);
histograms.Fetch();
// Should have received 2 more validation queries later (IRT and NEXE),
// and responded with a hit.
histograms.ExpectBucketCount("NaCl.ValidationCache.Query",
nacl::NaClBrowser::CACHE_HIT, 2);
// TOTAL should then be 4 queries now.
histograms.ExpectTotalCount("NaCl.ValidationCache.Query", 4);
// Still only 2 settings.
histograms.ExpectTotalCount("NaCl.ValidationCache.Set", 2);
}
// TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.) // TODO(ncbray) convert the rest of nacl_uma.py (currently in the NaCl repo.)
// Test validation failures and crashes. // Test validation failures and crashes.
......
...@@ -169,6 +169,7 @@ MessageResponse NaClIntegrationMessageHandler::HandleStructuredMessage( ...@@ -169,6 +169,7 @@ MessageResponse NaClIntegrationMessageHandler::HandleStructuredMessage(
// nacl_test_data/ // nacl_test_data/
// newlib/ // newlib/
// glibc/ // glibc/
// pnacl/
static bool GetNaClVariantRoot(const base::FilePath::StringType& variant, static bool GetNaClVariantRoot(const base::FilePath::StringType& variant,
base::FilePath* document_root) { base::FilePath* document_root) {
if (!ui_test_utils::GetRelativeBuildDirectory(document_root)) if (!ui_test_utils::GetRelativeBuildDirectory(document_root))
...@@ -261,7 +262,7 @@ void NaClBrowserTestBase::RunLoadTest( ...@@ -261,7 +262,7 @@ void NaClBrowserTestBase::RunLoadTest(
} }
void NaClBrowserTestBase::RunNaClIntegrationTest( void NaClBrowserTestBase::RunNaClIntegrationTest(
const base::FilePath::StringType& url_fragment) { const base::FilePath::StringType& url_fragment, bool full_url) {
NaClIntegrationMessageHandler handler; NaClIntegrationMessageHandler handler;
base::FilePath::StringType url_fragment_with_pnacl = url_fragment; base::FilePath::StringType url_fragment_with_pnacl = url_fragment;
if (IsAPnaclTest()) { if (IsAPnaclTest()) {
...@@ -271,7 +272,10 @@ void NaClBrowserTestBase::RunNaClIntegrationTest( ...@@ -271,7 +272,10 @@ void NaClBrowserTestBase::RunNaClIntegrationTest(
if (IsPnaclDisabled()) { if (IsPnaclDisabled()) {
AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both); AddPnaclDisabledParm(url_fragment_with_pnacl, &url_fragment_with_both);
} }
bool ok = RunJavascriptTest(TestURL(url_fragment_with_both), &handler); bool ok = RunJavascriptTest(full_url
? GURL(url_fragment_with_both)
: TestURL(url_fragment_with_both),
&handler);
ASSERT_TRUE(ok) << handler.error_message(); ASSERT_TRUE(ok) << handler.error_message();
ASSERT_TRUE(handler.test_passed()) << "Test failed."; ASSERT_TRUE(handler.test_passed()) << "Test failed.";
} }
...@@ -349,3 +353,21 @@ void NaClBrowserTestPnaclNonSfi::SetUpCommandLine( ...@@ -349,3 +353,21 @@ void NaClBrowserTestPnaclNonSfi::SetUpCommandLine(
NaClBrowserTestBase::SetUpCommandLine(command_line); NaClBrowserTestBase::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableNaClNonSfiMode); command_line->AppendSwitch(switches::kEnableNaClNonSfiMode);
} }
void NaClBrowserTestNewlibExtension::SetUpCommandLine(
CommandLine* command_line) {
NaClBrowserTestBase::SetUpCommandLine(command_line);
base::FilePath src_root;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_root));
// Extension-based tests should specialize the GetDocumentRoot() / Variant()
// to point at the isolated the test extension directory.
// Otherwise, multiple NaCl extensions tests will end up sharing the
// same directory when loading the extension files.
base::FilePath document_root;
ASSERT_TRUE(GetDocumentRoot(&document_root));
// Document root is relative to source root, and source root may not be CWD.
command_line->AppendSwitchPath(switches::kLoadExtension,
src_root.Append(document_root));
}
...@@ -98,7 +98,10 @@ class NaClBrowserTestBase : public InProcessBrowserTest { ...@@ -98,7 +98,10 @@ class NaClBrowserTestBase : public InProcessBrowserTest {
// these tests having a stronger affinity with the Chrome repo. This method // these tests having a stronger affinity with the Chrome repo. This method
// provides a compatibility layer to simplify turning nacl_integration tests // provides a compatibility layer to simplify turning nacl_integration tests
// into browser tests. // into browser tests.
void RunNaClIntegrationTest(const base::FilePath::StringType& url_fragment); // |full_url| is true if the full URL is given, otherwise it is a
// relative URL.
void RunNaClIntegrationTest(const base::FilePath::StringType& url,
bool full_url = false);
private: private:
bool StartTestServer(); bool StartTestServer();
...@@ -155,6 +158,14 @@ class NaClBrowserTestStatic : public NaClBrowserTestBase { ...@@ -155,6 +158,14 @@ class NaClBrowserTestStatic : public NaClBrowserTestBase {
virtual bool GetDocumentRoot(base::FilePath* document_root) OVERRIDE; virtual bool GetDocumentRoot(base::FilePath* document_root) OVERRIDE;
}; };
// A NaCl browser test that loads from an unpacked chrome extension.
// The directory of the unpacked extension files is determined by
// the tester's document root.
class NaClBrowserTestNewlibExtension : public NaClBrowserTestNewlib {
public:
virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
};
// PNaCl tests take a long time on windows debug builds // PNaCl tests take a long time on windows debug builds
// and sometimes time out. Disable until it is made faster: // and sometimes time out. Disable until it is made faster:
// https://code.google.com/p/chromium/issues/detail?id=177555 // https://code.google.com/p/chromium/issues/detail?id=177555
......
...@@ -28,12 +28,6 @@ const base::FilePath::CharType kValidationCacheFileName[] = ...@@ -28,12 +28,6 @@ const base::FilePath::CharType kValidationCacheFileName[] =
const bool kValidationCacheEnabledByDefault = true; const bool kValidationCacheEnabledByDefault = true;
enum ValidationCacheStatus {
CACHE_MISS = 0,
CACHE_HIT,
CACHE_MAX
};
// Keep the cache bounded to an arbitrary size. If it's too small, useful // Keep the cache bounded to an arbitrary size. If it's too small, useful
// entries could be evicted when multiple .nexes are loaded at once. On the // entries could be evicted when multiple .nexes are loaded at once. On the
// other hand, entries are not always claimed (and hence removed), so the size // other hand, entries are not always claimed (and hence removed), so the size
...@@ -100,13 +94,15 @@ void RemoveCache(const base::FilePath& filename, ...@@ -100,13 +94,15 @@ void RemoveCache(const base::FilePath& filename,
callback); callback);
} }
void LogCacheQuery(ValidationCacheStatus status) { void LogCacheQuery(nacl::NaClBrowser::ValidationCacheStatus status) {
UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Query", status, CACHE_MAX); UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Query", status,
nacl::NaClBrowser::CACHE_MAX);
} }
void LogCacheSet(ValidationCacheStatus status) { void LogCacheSet(nacl::NaClBrowser::ValidationCacheStatus status) {
// Bucket zero is reserved for future use. // Bucket zero is reserved for future use.
UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Set", status, CACHE_MAX); UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Set", status,
nacl::NaClBrowser::CACHE_MAX);
} }
// Crash throttling parameters. // Crash throttling parameters.
......
...@@ -74,6 +74,12 @@ class NaClBrowser { ...@@ -74,6 +74,12 @@ class NaClBrowser {
int GetProcessGdbDebugStubPort(int process_id); int GetProcessGdbDebugStubPort(int process_id);
enum ValidationCacheStatus {
CACHE_MISS = 0,
CACHE_HIT,
CACHE_MAX
};
bool ValidationCacheIsEnabled() const { bool ValidationCacheIsEnabled() const {
return validation_cache_is_enabled_; return validation_cache_is_enabled_;
} }
......
...@@ -1326,6 +1326,8 @@ void DownloadNexeCompletion(const DownloadNexeRequest& request, ...@@ -1326,6 +1326,8 @@ void DownloadNexeCompletion(const DownloadNexeRequest& request,
void DownloadNexe(PP_Instance instance, void DownloadNexe(PP_Instance instance,
const char* url, const char* url,
PP_FileHandle* out_handle, PP_FileHandle* out_handle,
uint64_t* file_token_lo,
uint64_t* file_token_hi,
PP_CompletionCallback callback) { PP_CompletionCallback callback) {
CHECK(url); CHECK(url);
CHECK(out_handle); CHECK(out_handle);
...@@ -1336,12 +1338,10 @@ void DownloadNexe(PP_Instance instance, ...@@ -1336,12 +1338,10 @@ void DownloadNexe(PP_Instance instance,
request.start_time = base::Time::Now(); request.start_time = base::Time::Now();
// Try the fast path for retrieving the file first. // Try the fast path for retrieving the file first.
uint64_t file_token_lo = 0;
uint64_t file_token_hi = 0;
PP_FileHandle file_handle = OpenNaClExecutable(instance, PP_FileHandle file_handle = OpenNaClExecutable(instance,
url, url,
&file_token_lo, file_token_lo,
&file_token_hi); file_token_hi);
if (file_handle != PP_kInvalidFileHandle) { if (file_handle != PP_kInvalidFileHandle) {
DownloadNexeCompletion(request, DownloadNexeCompletion(request,
file_handle, file_handle,
......
...@@ -426,9 +426,14 @@ interface PPB_NaCl_Private { ...@@ -426,9 +426,14 @@ interface PPB_NaCl_Private {
[in] str_t message); [in] str_t message);
/* Downloads the .nexe file at the given URL to a file, and sets |handle| /* Downloads the .nexe file at the given URL to a file, and sets |handle|
* to a handle to a file containing its contents. */ * to a handle to a file containing its contents.
* If metadata for identity-based validation caching is available
* then it sets file_token_lo and file_token_lo (otherwise left untouched).
*/
void DownloadNexe([in] PP_Instance instance, void DownloadNexe([in] PP_Instance instance,
[in] str_t url, [in] str_t url,
[out] PP_FileHandle handle, [out] PP_FileHandle handle,
[out] uint64_t file_token_lo,
[out] uint64_t file_token_hi,
[in] PP_CompletionCallback callback); [in] PP_CompletionCallback callback);
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From private/ppb_nacl_private.idl modified Mon May 19 11:12:19 2014. */ /* From private/ppb_nacl_private.idl modified Wed May 21 13:23:26 2014. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
...@@ -416,10 +416,15 @@ struct PPB_NaCl_Private_1_0 { ...@@ -416,10 +416,15 @@ struct PPB_NaCl_Private_1_0 {
*/ */
void (*PostMessageToJavaScript)(PP_Instance instance, const char* message); void (*PostMessageToJavaScript)(PP_Instance instance, const char* message);
/* Downloads the .nexe file at the given URL to a file, and sets |handle| /* Downloads the .nexe file at the given URL to a file, and sets |handle|
* to a handle to a file containing its contents. */ * to a handle to a file containing its contents.
* If metadata for identity-based validation caching is available
* then it sets file_token_lo and file_token_lo (otherwise left untouched).
*/
void (*DownloadNexe)(PP_Instance instance, void (*DownloadNexe)(PP_Instance instance,
const char* url, const char* url,
PP_FileHandle* handle, PP_FileHandle* handle,
uint64_t* file_token_lo,
uint64_t* file_token_hi,
struct PP_CompletionCallback callback); struct PP_CompletionCallback callback);
}; };
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "native_client/src/include/portability.h" #include "native_client/src/include/portability.h"
#include "native_client/src/include/portability_io.h" #include "native_client/src/include/portability_io.h"
#include "native_client/src/include/portability_string.h" #include "native_client/src/include/portability_string.h"
#include "native_client/src/public/nacl_file_info.h"
#include "native_client/src/shared/platform/nacl_check.h" #include "native_client/src/shared/platform/nacl_check.h"
#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
...@@ -330,6 +331,8 @@ Plugin::Plugin(PP_Instance pp_instance) ...@@ -330,6 +331,8 @@ Plugin::Plugin(PP_Instance pp_instance)
time_of_last_progress_event_(0), time_of_last_progress_event_(0),
manifest_id_(-1), manifest_id_(-1),
nexe_handle_(PP_kInvalidFileHandle), nexe_handle_(PP_kInvalidFileHandle),
nexe_token_lo_(0),
nexe_token_hi_(0),
nacl_interface_(NULL), nacl_interface_(NULL),
uma_interface_(this) { uma_interface_(this) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
...@@ -411,11 +414,23 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) { ...@@ -411,11 +414,23 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
if (pp_error != PP_OK) if (pp_error != PP_OK)
return; return;
int32_t desc = ConvertFileDescriptor(nexe_handle_, true); NaClFileInfo nexe_file_info;
nexe_file_info.desc = ConvertFileDescriptor(nexe_handle_, true);
nexe_file_info.file_token.lo = nexe_token_lo_;
nexe_file_info.file_token.hi = nexe_token_hi_;
nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle. nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle.
nexe_token_lo_ = 0;
nexe_token_hi_ = 0;
NaClDesc *desc = NaClDescIoFromFileInfo(nexe_file_info, O_RDONLY);
if (desc == NULL)
return;
// nexe_file_info_ is handed to desc, clear out old copy.
memset(&nexe_file_info, 0, sizeof nexe_file_info);
nexe_file_info.desc = -1;
nacl::scoped_ptr<nacl::DescWrapper> nacl::scoped_ptr<nacl::DescWrapper>
wrapper(wrapper_factory()->MakeFileDesc(desc, O_RDONLY)); wrapper(wrapper_factory()->MakeGenericCleanup(desc));
NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n"); NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n");
LoadNaClModule( LoadNaClModule(
wrapper.release(), wrapper.release(),
...@@ -526,6 +541,8 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { ...@@ -526,6 +541,8 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
nacl_interface_->DownloadNexe(pp_instance(), nacl_interface_->DownloadNexe(pp_instance(),
program_url_.c_str(), program_url_.c_str(),
&nexe_handle_, &nexe_handle_,
&nexe_token_lo_,
&nexe_token_hi_,
open_callback.pp_completion_callback()); open_callback.pp_completion_callback());
return; return;
} }
......
...@@ -297,6 +297,8 @@ class Plugin : public pp::Instance { ...@@ -297,6 +297,8 @@ class Plugin : public pp::Instance {
int32_t manifest_id_; int32_t manifest_id_;
PP_FileHandle nexe_handle_; PP_FileHandle nexe_handle_;
uint64_t nexe_token_lo_;
uint64_t nexe_token_hi_;
const PPB_NaCl_Private* nacl_interface_; const PPB_NaCl_Private* nacl_interface_;
pp::UMAPrivate uma_interface_; pp::UMAPrivate uma_interface_;
......
...@@ -3402,9 +3402,9 @@ static void Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript(PP_Instance insta ...@@ -3402,9 +3402,9 @@ static void Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript(PP_Instance insta
iface->PostMessageToJavaScript(instance, message); iface->PostMessageToJavaScript(instance, message);
} }
static void Pnacl_M25_PPB_NaCl_Private_DownloadNexe(PP_Instance instance, const char* url, PP_FileHandle* handle, struct PP_CompletionCallback* callback) { static void Pnacl_M25_PPB_NaCl_Private_DownloadNexe(PP_Instance instance, const char* url, PP_FileHandle* handle, uint64_t* file_token_lo, uint64_t* file_token_hi, struct PP_CompletionCallback* callback) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
iface->DownloadNexe(instance, url, handle, *callback); iface->DownloadNexe(instance, url, handle, file_token_lo, file_token_hi, *callback);
} }
/* End wrapper methods for PPB_NaCl_Private_1_0 */ /* End wrapper methods for PPB_NaCl_Private_1_0 */
...@@ -5167,7 +5167,7 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { ...@@ -5167,7 +5167,7 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
.GetPnaclResourceInfo = (PP_Bool (*)(PP_Instance instance, const char* filename, struct PP_Var* llc_tool_name, struct PP_Var* ld_tool_name))&Pnacl_M25_PPB_NaCl_Private_GetPnaclResourceInfo, .GetPnaclResourceInfo = (PP_Bool (*)(PP_Instance instance, const char* filename, struct PP_Var* llc_tool_name, struct PP_Var* ld_tool_name))&Pnacl_M25_PPB_NaCl_Private_GetPnaclResourceInfo,
.GetCpuFeatureAttrs = (struct PP_Var (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs, .GetCpuFeatureAttrs = (struct PP_Var (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs,
.PostMessageToJavaScript = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript, .PostMessageToJavaScript = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript,
.DownloadNexe = (void (*)(PP_Instance instance, const char* url, PP_FileHandle* handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe .DownloadNexe = (void (*)(PP_Instance instance, const char* url, PP_FileHandle* handle, uint64_t* file_token_lo, uint64_t* file_token_hi, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe
}; };
static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment