Index: components/component_updater/component_updater_service.cc |
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc |
index fce7e996b2ea86761e9856805d49a2e52c34d571..8f0515bda3760619c54dea4cdda42e0b50419804 100644 |
--- a/components/component_updater/component_updater_service.cc |
+++ b/components/component_updater/component_updater_service.cc |
@@ -18,11 +18,13 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/sequenced_task_runner.h" |
#include "base/single_thread_task_runner.h" |
#include "base/thread_task_runner_handle.h" |
#include "base/threading/sequenced_worker_pool.h" |
#include "base/threading/thread_checker.h" |
+#include "base/time/time.h" |
#include "base/timer/timer.h" |
#include "components/component_updater/component_updater_service_internal.h" |
#include "components/component_updater/timer.h" |
@@ -35,6 +37,16 @@ |
using CrxInstaller = update_client::CrxInstaller; |
using UpdateClient = update_client::UpdateClient; |
+namespace { |
+ |
+enum UpdateType { |
+ UPDATE_TYPE_MANUAL = 0, |
+ UPDATE_TYPE_AUTOMATIC, |
+ UPDATE_TYPE_COUNT, |
+}; |
+ |
+} // namespace |
+ |
namespace component_updater { |
CrxUpdateService::CrxUpdateService( |
@@ -235,15 +247,23 @@ bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) { |
bool CrxUpdateService::OnDemandUpdateInternal(const std::string& id) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_MANUAL, |
+ UPDATE_TYPE_COUNT); |
+ |
update_client_->Install( |
id, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
- base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this))); |
+ base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this), |
+ base::TimeTicks::Now())); |
return true; |
} |
bool CrxUpdateService::CheckForUpdates() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.Calls", UPDATE_TYPE_AUTOMATIC, |
+ UPDATE_TYPE_COUNT); |
+ |
std::vector<std::string> ids; |
for (const auto id : components_order_) { |
DCHECK(components_.find(id) != components_.end()); |
@@ -252,7 +272,8 @@ bool CrxUpdateService::CheckForUpdates() { |
update_client_->Update( |
ids, base::Bind(&CrxUpdateService::OnUpdate, base::Unretained(this)), |
- base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this))); |
+ base::Bind(&CrxUpdateService::OnUpdateComplete, base::Unretained(this), |
+ base::TimeTicks::Now())); |
return true; |
} |
@@ -296,10 +317,15 @@ void CrxUpdateService::OnUpdate(const std::vector<std::string>& ids, |
} |
} |
-void CrxUpdateService::OnUpdateComplete(int error) { |
+void CrxUpdateService::OnUpdateComplete(const base::TimeTicks& start_time, |
+ int error) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
VLOG(1) << "Update completed with error " << error; |
+ UMA_HISTOGRAM_BOOLEAN("ComponentUpdater.UpdateCompleteResult", error != 0); |
+ UMA_HISTOGRAM_LONG_TIMES_100("ComponentUpdater.UpdateCompleteTime", |
+ base::TimeTicks::Now() - start_time); |
+ |
for (const auto id : components_pending_unregistration_) { |
if (!update_client_->IsUpdating(id)) { |
const auto component = GetComponent(id); |