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

Unified Diff: chrome/browser/component_updater/pnacl/pnacl_component_installer.cc

Issue 12054003: Add an API to component_updater that asks to do an update check "now". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not use NextCheckDelay for non-running timer case (sideeffects). Created 7 years, 11 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
Index: chrome/browser/component_updater/pnacl/pnacl_component_installer.cc
diff --git a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc
index e33c21b43754956d9aa1bc4c2acbfad00a5ca236..f884374b1b86c22709b7208386a5c760f0b07d2a 100644
--- a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc
+++ b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc
@@ -26,6 +26,11 @@ using content::BrowserThread;
namespace {
+// If PNaCl isn't installed yet, but a user is running chrome with
+// --enable-pnacl, this is the amount of time to wait before starting
+// a background install.
+const int kInitialDelaySeconds = 10;
+
// CRX hash. This corresponds to AppId: emkhcgigkicgidendmffimilfehocheg
const uint8 sha256_hash[] = {
0x4c, 0xa7, 0x26, 0x86, 0xa8, 0x26, 0x83, 0x4d, 0x3c, 0x55,
@@ -69,10 +74,6 @@ const char* PnaclArch() {
}
// If we don't have Pnacl installed, this is the version we claim.
-// TODO(jvoung): Is there a way to trick the configurator to ping the server
-// earlier if there are components that are not yet installed (version 0.0.0.0),
-// So that they will be available ASAP? Be careful not to hurt startup speed.
-// Make kNullVersion part of ComponentUpdater in that case, to avoid skew?
const char kNullVersion[] = "0.0.0.0";
// Pnacl components have the version encoded in the path itself:
@@ -249,6 +250,13 @@ bool PnaclComponentInstaller::Install(base::DictionaryValue* manifest,
namespace {
+void DoPingUpdater(ComponentUpdateService* cus,
+ const CrxComponent& pnacl) {
+ if (cus->PingUpdateCheck(pnacl) != ComponentUpdateService::kOk) {
+ NOTREACHED() << "Pnacl ping update failed.";
+ }
+}
+
// Finally, do the registration with the right version number.
void FinishPnaclUpdateRegistration(ComponentUpdateService* cus,
const Version& version) {
@@ -261,6 +269,16 @@ void FinishPnaclUpdateRegistration(ComponentUpdateService* cus,
if (cus->RegisterComponent(pnacl) != ComponentUpdateService::kOk) {
NOTREACHED() << "Pnacl component registration failed.";
}
+
+ // If Pnacl is not yet installed, but it is requested by --enable-pnacl,
+ // we want it to be available "soon", so kick off an update check.
+ Version null_version(kNullVersion);
+ if (version.Equals(null_version)) {
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(DoPingUpdater, cus, pnacl),
+ base::TimeDelta::FromSeconds(kInitialDelaySeconds));
+ }
}
// Check if there is an existing version on disk first to know when

Powered by Google App Engine
This is Rietveld 408576698