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

Unified Diff: chrome/test/nacl/nacl_browsertest_uma.cc

Issue 263683002: Set file tokens for NaCl main nexe if available to enable validation caching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: concat filepath literal Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/nacl/nacl_browsertest.cc ('k') | chrome/test/nacl/nacl_browsertest_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/nacl/nacl_browsertest_uma.cc
diff --git a/chrome/test/nacl/nacl_browsertest_uma.cc b/chrome/test/nacl/nacl_browsertest_uma.cc
index c6a3fba6a24f899c7f8eb64a96b6b212e97c1795..0f91ca4d2dc0253fd86fc227fd4192f332618a3e 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.
« no previous file with comments | « chrome/test/nacl/nacl_browsertest.cc ('k') | chrome/test/nacl/nacl_browsertest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698