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

Unified Diff: components/offline_pages/background/request_coordinator.cc

Issue 2104393002: Adds UMA for PrerenderingOffliner request processing result status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds note about interim offliner status codes and performs DCHECK that offliner does not return the… Created 4 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: components/offline_pages/background/request_coordinator.cc
diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
index 6292aa8cc7b24ddb6fc7fe430d8529531f288589..e6ac73f55fc065eb4b25c8fee76eb8ad2f1f444c 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "components/offline_pages/background/offliner_factory.h"
#include "components/offline_pages/background/offliner_policy.h"
@@ -19,6 +20,15 @@
namespace offline_pages {
namespace {
+
+// Records the final request status UMA for an offlining request. This should
+// only be called once per Offliner::LoadAndSave request.
+void RecordOfflinerResultUMA(Offliner::RequestStatus request_status) {
+ UMA_HISTOGRAM_ENUMERATION("OfflinePages.Background.OfflinerRequestStatus",
+ request_status,
+ Offliner::RequestStatus::STATUS_COUNT);
+}
+
// TODO(dougarnett/petewil): Move to Policy object. Also consider lower minimum
// battery percentage once there is some processing time limits in place.
const Scheduler::TriggerConditions kUserRequestTriggerConditions(
@@ -92,6 +102,11 @@ void RequestCoordinator::StopProcessing() {
if (offliner_ && is_busy_)
offliner_->Cancel();
+ // Stopping offliner means it will not call callback.
+ last_offlining_status_ =
+ Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED;
+ RecordOfflinerResultUMA(last_offlining_status_);
+
// Let the scheduler know we are done processing.
scheduler_callback_.Run(true);
}
@@ -167,11 +182,14 @@ void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
DVLOG(2) << "offliner finished, saved: "
<< (status == Offliner::RequestStatus::SAVED) << ", status: "
<< (int) status << ", " << __FUNCTION__;
+ DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN);
+ DCHECK_NE(status, Offliner::RequestStatus::LOADED);
event_logger_.RecordSavePageRequestUpdated(
request.client_id().name_space,
"Saved",
request.request_id());
last_offlining_status_ = status;
+ RecordOfflinerResultUMA(last_offlining_status_);
watchdog_timer_.Stop();
is_busy_ = false;
« no previous file with comments | « components/offline_pages/background/offliner.h ('k') | components/offline_pages/background/request_coordinator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698