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..132f912d428459290173137428ab7ec6bafea131 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 previews_enabling = 0; |
|
chili
2017/06/02 01:38:07
alternate names: preview_state_numeration? preview
Pete Williamson
2017/06/02 21:40:32
picked "is_previews_enabled"
|
| + if (previews_state != content::PreviewsTypes::PREVIEWS_OFF) |
| + previews_enabling = 1; |
| + |
| + UMA_HISTOGRAM_ENUMERATION( |
| + AddHistogramSuffix(client_id, |
| + "OfflinePages.Background.OffliningPreviewStatus"), |
|
RyanSturm
2017/06/02 20:50:33
As a note, if you care about offline previews (whi
Pete Williamson
2017/06/02 21:40:32
Noted. I don't think we care about it.
|
| + previews_enabling, 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. |
| + // TODO(petewil): Today ChromeNavigationData is the only subclass of |
| + // NavigationData. What can I do to make sure new subclasses don't break |
| + // this cast someday? Move previews_state() to the NavigationData interface? |
| + // Use some form of RTTI to know what I have before I cast it? |
|
Pete Williamson
2017/06/02 00:47:37
Reviewers: What is your preference here? I'm thi
chili
2017/06/02 01:38:07
I would make a function called IsAnyPreviewsEnable
RyanSturm
2017/06/02 20:50:33
So the basic idea is that Chrome will only ever im
RyanSturm
2017/06/02 20:56:29
Also, if you like, I would not be opposed to addin
RyanSturm
2017/06/02 20:57:56
Ooops: typo above:
s/"ChromeNavigationData* Chrom
Pete Williamson
2017/06/02 21:40:32
Changed to static cast. Decided not to move the c
|
| + ChromeNavigationData* navigation_data = |
| + reinterpret_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( |