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

Unified Diff: chrome/browser/offline_pages/background_loader_offliner.cc

Issue 2916253002: Add UMA to determine how often we offline a page with previews. (Closed)
Patch Set: Add a unit test, and a bit more detail to an existing test. Created 3 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
Index: chrome/browser/offline_pages/background_loader_offliner.cc
diff --git a/chrome/browser/offline_pages/background_loader_offliner.cc b/chrome/browser/offline_pages/background_loader_offliner.cc
index 7860f5ead47813c7344b9f438ac634b6232ec01b..15dc7dda7c9fb3962c4e3c083a016d637ac95b69 100644
--- a/chrome/browser/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/offline_pages/background_loader_offliner.cc
@@ -12,6 +12,7 @@
#include "base/time/time.h"
#include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
#include "chrome/browser/android/offline_pages/offliner_helper.h"
+#include "chrome/browser/loader/chrome_navigation_data.h"
#include "chrome/browser/profiles/profile.h"
#include "components/offline_pages/core/background/offliner_policy.h"
#include "components/offline_pages/core/background/save_page_request.h"
@@ -24,6 +25,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "content/public/common/previews_state.h"
namespace offline_pages {
@@ -73,6 +75,18 @@ void RecordErrorCauseUMA(const ClientId& client_id, net::Error error_code) {
std::abs(error_code));
}
+void RecordOffliningPreviewsUMA(const ClientId& client_id,
+ content::PreviewsState previews_state) {
+ int is_previews_enabled = 0;
+ if (previews_state != content::PreviewsTypes::PREVIEWS_OFF)
RyanSturm 2017/06/05 20:43:59 There is some subtlety with PREVIEWS_OFF vs PREVIE
Pete Williamson 2017/06/05 21:40:47 Added checks as you suggest (but worded slightly d
+ is_previews_enabled = 1;
+
+ UMA_HISTOGRAM_ENUMERATION(
+ AddHistogramSuffix(client_id,
+ "OfflinePages.Background.OffliningPreviewStatus"),
+ is_previews_enabled, 2);
+}
+
void HandleLoadTerminationCancel(
const Offliner::CompletionCallback& completion_callback,
const SavePageRequest& canceled_request) {
@@ -311,6 +325,21 @@ void BackgroundLoaderOffliner::DidFinishNavigation(
page_load_state_ = RETRIABLE;
}
}
+
+ // Record UMA if we are offlining a previvew instead of an unmodified page.
+ // As documented in content/public/browser/navigation_handle.h, this
+ // NavigationData is a clone of the NavigationData instance returned from
+ // ResourceDispatcherHostDelegate::GetNavigationData during commit.
+ // Because ChromeResourceDispatcherHostDelegate always returns a
+ // ChromeNavigationData, it is safe to static_cast here.
+ ChromeNavigationData* navigation_data = static_cast<ChromeNavigationData*>(
+ navigation_handle->GetNavigationData());
+
+ content::PreviewsState previews_state = content::PreviewsTypes::PREVIEWS_OFF;
+ if (navigation_data)
+ previews_state = navigation_data->previews_state();
+
+ RecordOffliningPreviewsUMA(pending_request_->client_id(), previews_state);
}
void BackgroundLoaderOffliner::SetSnapshotControllerForTest(

Powered by Google App Engine
This is Rietveld 408576698