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

Unified Diff: chrome/browser/component_updater/component_updater_configurator.cc

Issue 18516010: Implemented completion pings for component updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ChromeConfigurator owns the ping manager. Created 7 years, 5 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/component_updater_configurator.cc
diff --git a/chrome/browser/component_updater/component_updater_configurator.cc b/chrome/browser/component_updater/component_updater_configurator.cc
index d211e5eef4b7bc6fe387bc258ba453e31749cd21..cf0baebe2e14e456044bfe4d934a132dc58d615a 100644
--- a/chrome/browser/component_updater/component_updater_configurator.cc
+++ b/chrome/browser/component_updater/component_updater_configurator.cc
@@ -10,11 +10,13 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
-#include "base/metrics/histogram.h"
+#include "base/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/win/windows_version.h"
#include "build/build_config.h"
#include "chrome/browser/component_updater/component_patcher.h"
+#include "chrome/browser/component_updater/component_updater_ping_manager.h"
+#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/omaha_query_params/omaha_query_params.h"
#include "net/url_request/url_request_context_getter.h"
@@ -38,6 +40,10 @@ const char kSwitchOutOfProcess[] = "out-of-process";
const char kSwitchRequestParam[] = "test-request";
// Disables differential updates.
const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
+// Disables pings. Pings are the requests sent to the update server that report
+// the success or the failure of component install or update attempts.
+extern const char kSwitchDisablePings[] = "disable-pings";
+
// Sets the URL for updates.
const char kSwitchUrlSource[] = "url-source";
@@ -46,6 +52,9 @@ const char kSwitchUrlSource[] = "url-source";
const char kDefaultUrlSource[] =
"http://clients2.google.com/service/update2/crx";
+// The url to send the pings to.
+const char kPingUrl[] = "http://tools.google.com/service/update2";
+
// Returns true if and only if |test| is contained in |vec|.
bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
if (vec.empty())
@@ -81,19 +90,20 @@ class ChromeConfigurator : public ComponentUpdateService::Configurator {
ChromeConfigurator(const CommandLine* cmdline,
net::URLRequestContextGetter* url_request_getter);
- virtual ~ChromeConfigurator() {}
+ virtual ~ChromeConfigurator();
+ virtual void Init(ComponentUpdateService* cus) OVERRIDE;
virtual int InitialDelay() OVERRIDE;
virtual int NextCheckDelay() OVERRIDE;
virtual int StepDelay() OVERRIDE;
virtual int MinimumReCheckWait() OVERRIDE;
virtual int OnDemandDelay() OVERRIDE;
virtual GURL UpdateUrl() OVERRIDE;
+ virtual GURL PingUrl() OVERRIDE;
virtual const char* ExtraRequestParams() OVERRIDE;
virtual size_t UrlSizeLimit() OVERRIDE;
virtual net::URLRequestContextGetter* RequestContext() OVERRIDE;
virtual bool InProcess() OVERRIDE;
- virtual void OnEvent(Events event, int val) OVERRIDE;
virtual ComponentPatcher* CreateComponentPatcher() OVERRIDE;
virtual bool DeltasEnabled() const OVERRIDE;
@@ -103,7 +113,10 @@ class ChromeConfigurator : public ComponentUpdateService::Configurator {
std::string url_source_;
bool fast_update_;
bool out_of_process_;
+ bool pings_enabled_;
bool deltas_enabled_;
+ scoped_ptr<component_updater::PingManager> ping_manager_;
+ ComponentUpdateService* cus_; // Not owned by this class.
};
ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
@@ -113,6 +126,7 @@ ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
chrome::OmahaQueryParams::CHROME)),
fast_update_(false),
out_of_process_(false),
+ pings_enabled_(false),
deltas_enabled_(false) {
// Parse comma-delimited debug flags.
std::vector<std::string> switch_values;
@@ -120,6 +134,7 @@ ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
",", &switch_values);
fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
out_of_process_ = HasSwitchValue(switch_values, kSwitchOutOfProcess);
+ pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
#if defined(OS_WIN)
deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
#else
@@ -142,6 +157,18 @@ ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
extra_info_ += "&testrequest=1";
}
+ChromeConfigurator::~ChromeConfigurator() {
+ if (cus_)
+ cus_->RemoveObserver(ping_manager_.get());
+}
+
+void ChromeConfigurator::Init(ComponentUpdateService* cus) {
+ cus_ = cus;
+ ping_manager_.reset(new component_updater::PingManager(PingUrl(),
+ RequestContext()));
+ cus_->AddObserver(ping_manager_.get());
+}
+
int ChromeConfigurator::InitialDelay() {
return fast_update_ ? 1 : (6 * kDelayOneMinute);
}
@@ -166,6 +193,10 @@ GURL ChromeConfigurator::UpdateUrl() {
return GURL(url_source_);
}
+GURL ChromeConfigurator::PingUrl() {
+ return pings_enabled_ ? GURL(kPingUrl) : GURL();
+}
+
const char* ChromeConfigurator::ExtraRequestParams() {
return extra_info_.c_str();
}
@@ -182,32 +213,6 @@ bool ChromeConfigurator::InProcess() {
return !out_of_process_;
}
-void ChromeConfigurator::OnEvent(Events event, int val) {
- switch (event) {
- case kManifestCheck:
- UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.ManifestCheck", val, 100);
- break;
- case kComponentUpdated:
- UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.ComponentUpdated", val, 100);
- break;
- case kManifestError:
- UMA_HISTOGRAM_COUNTS_100("ComponentUpdater.ManifestError", val);
- break;
- case kNetworkError:
- UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.NetworkError", val, 100);
- break;
- case kUnpackError:
- UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.UnpackError", val, 100);
- break;
- case kInstallerError:
- UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.InstallError", val, 100);
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
ComponentPatcher* ChromeConfigurator::CreateComponentPatcher() {
#if defined(OS_WIN)
return new ComponentPatcherWin();

Powered by Google App Engine
This is Rietveld 408576698