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..3e70e11602fd10b4cc19a809b2219dbcb6bef08c 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,32 @@ 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 = content::PreviewsTypes::PREVIEWS_OFF; |
| + if (navigation_data) |
| + previews_state = navigation_data->previews_state(); |
| + |
| + 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_BOOLEAN( |
|
Steven Holte
2017/06/07 22:24:46
Actually, you probably need to change this to not
Pete Williamson
2017/06/08 00:11:09
Done. Thanks for catching this!
|
| + AddHistogramSuffix(client_id, |
| + "OfflinePages.Background.OffliningPreviewStatus"), |
| + is_previews_enabled); |
| +} |
| + |
| void HandleLoadTerminationCancel( |
| const Offliner::CompletionCallback& completion_callback, |
| const SavePageRequest& canceled_request) { |
| @@ -311,6 +340,17 @@ 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()); |
| + |
| + RecordOffliningPreviewsUMA(pending_request_->client_id(), navigation_data); |
| } |
| void BackgroundLoaderOffliner::SetSnapshotControllerForTest( |