summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/base/uma_histogram_helper.cc15
-rw-r--r--chrome/test/base/uma_histogram_helper.h6
-rw-r--r--chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html17
-rw-r--r--chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js24
-rw-r--r--chrome/test/data/nacl/extension_validation_cache/manifest.json7
-rw-r--r--chrome/test/data/nacl/nacl_test_data.gyp34
-rw-r--r--chrome/test/nacl/nacl_browsertest.cc16
-rw-r--r--chrome/test/nacl/nacl_browsertest_uma.cc58
-rw-r--r--chrome/test/nacl/nacl_browsertest_util.cc26
-rw-r--r--chrome/test/nacl/nacl_browsertest_util.h13
-rw-r--r--components/nacl/browser/nacl_browser.cc16
-rw-r--r--components/nacl/browser/nacl_browser.h6
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc8
-rw-r--r--ppapi/api/private/ppb_nacl_private.idl7
-rw-r--r--ppapi/c/private/ppb_nacl_private.h9
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc21
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h2
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c6
18 files changed, 250 insertions, 41 deletions
diff --git a/chrome/test/base/uma_histogram_helper.cc b/chrome/test/base/uma_histogram_helper.cc
index e65bf0582..9b51229 100644
--- a/chrome/test/base/uma_histogram_helper.cc
+++ b/chrome/test/base/uma_histogram_helper.cc
@@ -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(
const std::string& name,
base::HistogramBase::Count count) {
diff --git a/chrome/test/base/uma_histogram_helper.h b/chrome/test/base/uma_histogram_helper.h
index b04178c..76e841f 100644
--- a/chrome/test/base/uma_histogram_helper.h
+++ b/chrome/test/base/uma_histogram_helper.h
@@ -26,6 +26,12 @@ class UMAHistogramHelper {
base::HistogramBase::Sample sample,
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.
void ExpectTotalCount(const std::string& name,
base::HistogramBase::Count count);
diff --git a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html
new file mode 100644
index 0000000..ab8d08e
--- /dev/null
+++ b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.html
@@ -0,0 +1,17 @@
+<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>
diff --git a/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js
new file mode 100644
index 0000000..1913f22
--- /dev/null
+++ b/chrome/test/data/nacl/extension_validation_cache/extension_validation_cache.js
@@ -0,0 +1,24 @@
+// 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);
diff --git a/chrome/test/data/nacl/extension_validation_cache/manifest.json b/chrome/test/data/nacl/extension_validation_cache/manifest.json
new file mode 100644
index 0000000..7a1edca
--- /dev/null
+++ b/chrome/test/data/nacl/extension_validation_cache/manifest.json
@@ -0,0 +1,7 @@
+{
+ "name": "NaCl_ValidationCacheNexeTest",
+ "version": "0.1",
+ "manifest_version": 2,
+ "description": "Tests NaCl validation caching for main nexe from extensions.",
+ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCoq+cJMuoIaoL2hx//QoIeHnNkXLAEu3IJGcLpM95qbmw9VnAplFI0tpSv4IpuJ1DPPsdsEMhONu1mPhK9xd3BHCtzqXRfRsnx/uOap4NTcUimxiUH3uuX9xkCNWO8EihdV0atnrKROhhnyIxmhgKmKfAYLheOrSGSXP0A4SqaBQIDAQAB"
+}
diff --git a/chrome/test/data/nacl/nacl_test_data.gyp b/chrome/test/data/nacl/nacl_test_data.gyp
index bacbecc..8ee3033 100644
--- a/chrome/test/data/nacl/nacl_test_data.gyp
+++ b/chrome/test/data/nacl/nacl_test_data.gyp
@@ -81,6 +81,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',
'type': 'none',
'variables': {
diff --git a/chrome/test/nacl/nacl_browsertest.cc b/chrome/test/nacl/nacl_browsertest.cc
index c3ec838..bdaa551 100644
--- a/chrome/test/nacl/nacl_browsertest.cc
+++ b/chrome/test/nacl/nacl_browsertest.cc
@@ -440,22 +440,6 @@ IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibStderrPM, RedirectBg1) {
"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
#if defined(OS_MACOSX)
// crbug.com/375894
diff --git a/chrome/test/nacl/nacl_browsertest_uma.cc b/chrome/test/nacl/nacl_browsertest_uma.cc
index c6a3fba..0f91ca4 100644
--- a/chrome/test/nacl/nacl_browsertest_uma.cc
+++ b/chrome/test/nacl/nacl_browsertest_uma.cc
@@ -4,6 +4,7 @@
#include "chrome/test/base/uma_histogram_helper.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 "ppapi/c/private/ppb_nacl_private.h"
@@ -26,6 +27,17 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, SuccessfulLoadUMA, {
histograms.ExpectUniqueSample("NaCl.LoadStatus.SelLdr",
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.
if (!IsAPnaclTest()) {
histograms.ExpectTotalCount("NaCl.Perf.StartupTime.LoadModule", 1);
@@ -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.)
// Test validation failures and crashes.
diff --git a/chrome/test/nacl/nacl_browsertest_util.cc b/chrome/test/nacl/nacl_browsertest_util.cc
index 19758e1..9c1d57d 100644
--- a/chrome/test/nacl/nacl_browsertest_util.cc
+++ b/chrome/test/nacl/nacl_browsertest_util.cc
@@ -169,6 +169,7 @@ MessageResponse NaClIntegrationMessageHandler::HandleStructuredMessage(
// nacl_test_data/
// newlib/
// glibc/
+// pnacl/
static bool GetNaClVariantRoot(const base::FilePath::StringType& variant,
base::FilePath* document_root) {
if (!ui_test_utils::GetRelativeBuildDirectory(document_root))
@@ -261,7 +262,7 @@ void NaClBrowserTestBase::RunLoadTest(
}
void NaClBrowserTestBase::RunNaClIntegrationTest(
- const base::FilePath::StringType& url_fragment) {
+ const base::FilePath::StringType& url_fragment, bool full_url) {
NaClIntegrationMessageHandler handler;
base::FilePath::StringType url_fragment_with_pnacl = url_fragment;
if (IsAPnaclTest()) {
@@ -271,7 +272,10 @@ void NaClBrowserTestBase::RunNaClIntegrationTest(
if (IsPnaclDisabled()) {
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(handler.test_passed()) << "Test failed.";
}
@@ -349,3 +353,21 @@ void NaClBrowserTestPnaclNonSfi::SetUpCommandLine(
NaClBrowserTestBase::SetUpCommandLine(command_line);
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));
+}
diff --git a/chrome/test/nacl/nacl_browsertest_util.h b/chrome/test/nacl/nacl_browsertest_util.h
index d72a6d7..7f74379 100644
--- a/chrome/test/nacl/nacl_browsertest_util.h
+++ b/chrome/test/nacl/nacl_browsertest_util.h
@@ -98,7 +98,10 @@ class NaClBrowserTestBase : public InProcessBrowserTest {
// these tests having a stronger affinity with the Chrome repo. This method
// provides a compatibility layer to simplify turning nacl_integration 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:
bool StartTestServer();
@@ -155,6 +158,14 @@ class NaClBrowserTestStatic : public NaClBrowserTestBase {
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
// and sometimes time out. Disable until it is made faster:
// https://code.google.com/p/chromium/issues/detail?id=177555
diff --git a/components/nacl/browser/nacl_browser.cc b/components/nacl/browser/nacl_browser.cc
index b10e2e1..45c7648 100644
--- a/components/nacl/browser/nacl_browser.cc
+++ b/components/nacl/browser/nacl_browser.cc
@@ -28,12 +28,6 @@ const base::FilePath::CharType kValidationCacheFileName[] =
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
// 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
@@ -100,13 +94,15 @@ void RemoveCache(const base::FilePath& filename,
callback);
}
-void LogCacheQuery(ValidationCacheStatus status) {
- UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Query", status, CACHE_MAX);
+void LogCacheQuery(nacl::NaClBrowser::ValidationCacheStatus status) {
+ 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.
- UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Set", status, CACHE_MAX);
+ UMA_HISTOGRAM_ENUMERATION("NaCl.ValidationCache.Set", status,
+ nacl::NaClBrowser::CACHE_MAX);
}
// Crash throttling parameters.
diff --git a/components/nacl/browser/nacl_browser.h b/components/nacl/browser/nacl_browser.h
index 51d19e4..93dcb42 100644
--- a/components/nacl/browser/nacl_browser.h
+++ b/components/nacl/browser/nacl_browser.h
@@ -74,6 +74,12 @@ class NaClBrowser {
int GetProcessGdbDebugStubPort(int process_id);
+ enum ValidationCacheStatus {
+ CACHE_MISS = 0,
+ CACHE_HIT,
+ CACHE_MAX
+ };
+
bool ValidationCacheIsEnabled() const {
return validation_cache_is_enabled_;
}
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 634bb81..3e4304e 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -1326,6 +1326,8 @@ void DownloadNexeCompletion(const DownloadNexeRequest& request,
void DownloadNexe(PP_Instance instance,
const char* url,
PP_FileHandle* out_handle,
+ uint64_t* file_token_lo,
+ uint64_t* file_token_hi,
PP_CompletionCallback callback) {
CHECK(url);
CHECK(out_handle);
@@ -1336,12 +1338,10 @@ void DownloadNexe(PP_Instance instance,
request.start_time = base::Time::Now();
// 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,
url,
- &file_token_lo,
- &file_token_hi);
+ file_token_lo,
+ file_token_hi);
if (file_handle != PP_kInvalidFileHandle) {
DownloadNexeCompletion(request,
file_handle,
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl
index 8bdcc07..530132d 100644
--- a/ppapi/api/private/ppb_nacl_private.idl
+++ b/ppapi/api/private/ppb_nacl_private.idl
@@ -426,9 +426,14 @@ interface PPB_NaCl_Private {
[in] str_t message);
/* 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,
[in] str_t url,
[out] PP_FileHandle handle,
+ [out] uint64_t file_token_lo,
+ [out] uint64_t file_token_hi,
[in] PP_CompletionCallback callback);
};
diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h
index ec26a17..fbf57cd 100644
--- a/ppapi/c/private/ppb_nacl_private.h
+++ b/ppapi/c/private/ppb_nacl_private.h
@@ -3,7 +3,7 @@
* 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_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
@@ -416,10 +416,15 @@ struct PPB_NaCl_Private_1_0 {
*/
void (*PostMessageToJavaScript)(PP_Instance instance, const char* message);
/* 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,
const char* url,
PP_FileHandle* handle,
+ uint64_t* file_token_lo,
+ uint64_t* file_token_hi,
struct PP_CompletionCallback callback);
};
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index f88c754..d53e6e2 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -23,6 +23,7 @@
#include "native_client/src/include/portability.h"
#include "native_client/src/include/portability_io.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/trusted/desc/nacl_desc_wrapper.h"
#include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
@@ -330,6 +331,8 @@ Plugin::Plugin(PP_Instance pp_instance)
time_of_last_progress_event_(0),
manifest_id_(-1),
nexe_handle_(PP_kInvalidFileHandle),
+ nexe_token_lo_(0),
+ nexe_token_hi_(0),
nacl_interface_(NULL),
uma_interface_(this) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
@@ -411,11 +414,23 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
if (pp_error != PP_OK)
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_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>
- wrapper(wrapper_factory()->MakeFileDesc(desc, O_RDONLY));
+ wrapper(wrapper_factory()->MakeGenericCleanup(desc));
NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n");
LoadNaClModule(
wrapper.release(),
@@ -526,6 +541,8 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
nacl_interface_->DownloadNexe(pp_instance(),
program_url_.c_str(),
&nexe_handle_,
+ &nexe_token_lo_,
+ &nexe_token_hi_,
open_callback.pp_completion_callback());
return;
}
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index 244c824..a2e0c02 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -297,6 +297,8 @@ class Plugin : public pp::Instance {
int32_t manifest_id_;
PP_FileHandle nexe_handle_;
+ uint64_t nexe_token_lo_;
+ uint64_t nexe_token_hi_;
const PPB_NaCl_Private* nacl_interface_;
pp::UMAPrivate uma_interface_;
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 911380b..0ac1cae 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -3402,9 +3402,9 @@ static void Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript(PP_Instance insta
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;
- 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 */
@@ -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,
.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,
- .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 = {