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

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: Fix copying of previews_state with the ChromeNavigationData object Created 3 years, 6 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..1efa38158720e56c87fff6a23fdc788d026fb521 100644
--- a/chrome/browser/offline_pages/background_loader_offliner.cc
+++ b/chrome/browser/offline_pages/background_loader_offliner.cc
@@ -12,7 +12,9 @@
#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/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
#include "components/offline_pages/core/background/offliner_policy.h"
#include "components/offline_pages/core/background/save_page_request.h"
#include "components/offline_pages/core/client_namespace_constants.h"
@@ -24,6 +26,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 +76,29 @@ void RecordErrorCauseUMA(const ClientId& client_id, net::Error error_code) {
std::abs(error_code));
}
+void RecordOffliningPreviewsUMA(const ClientId& client_id,
+ ChromeNavigationData* navigation_data,
+ content::PreviewsState previews_state) {
RyanSturm 2017/06/06 20:49:52 nit: it's a little weird that you are pulling prev
Pete Williamson 2017/06/06 21:39:47 Good point, moved the check for previews_state ins
+ int is_previews_enabled = 0;
+ bool lite_page_received = false;
+ data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data =
+ nullptr;
+ if (navigation_data)
+ data_reduction_proxy_data = navigation_data->GetDataReductionProxyData();
+ if (data_reduction_proxy_data)
+ lite_page_received = data_reduction_proxy_data->lite_page_received();
+
+ if ((previews_state != content::PreviewsTypes::PREVIEWS_OFF &&
+ previews_state != content::PreviewsTypes::PREVIEWS_NO_TRANSFORM) ||
+ lite_page_received)
+ is_previews_enabled = 1;
+
+ UMA_HISTOGRAM_ENUMERATION(
RyanSturm 2017/06/06 20:49:52 Any reason this isn't UMA_HISTOGRAM_BOOLEAN?
Pete Williamson 2017/06/06 21:39:47 Done.
+ AddHistogramSuffix(client_id,
+ "OfflinePages.Background.OffliningPreviewStatus"),
+ is_previews_enabled, 2);
+}
+
void HandleLoadTerminationCancel(
const Offliner::CompletionCallback& completion_callback,
const SavePageRequest& canceled_request) {
@@ -311,6 +337,22 @@ 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(), navigation_data,
+ previews_state);
}
void BackgroundLoaderOffliner::SetSnapshotControllerForTest(

Powered by Google App Engine
This is Rietveld 408576698