Chromium Code Reviews| 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( |