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

Unified Diff: chrome/renderer/net/net_error_helper_core.cc

Issue 259613003: Fix auto-reload histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 8 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/renderer/net/net_error_helper_core.cc
diff --git a/chrome/renderer/net/net_error_helper_core.cc b/chrome/renderer/net/net_error_helper_core.cc
index fb14be734505dfa833e68d67a1dcd76618d5b9a8..1734c82e990f12a545e5472465108baefdd5e225 100644
--- a/chrome/renderer/net/net_error_helper_core.cc
+++ b/chrome/renderer/net/net_error_helper_core.cc
@@ -256,7 +256,8 @@ struct NetErrorHelperCore::ErrorPageInfo {
needs_dns_updates(false),
reload_button_in_page(false),
load_stale_button_in_page(false),
- is_finished_loading(false) {
+ is_finished_loading(false),
+ is_auto_reloading(false) {
}
// Information about the failed page load.
@@ -288,6 +289,9 @@ struct NetErrorHelperCore::ErrorPageInfo {
// True if a page has completed loading, at which point it can receive
// updates.
bool is_finished_loading;
+
+ // True if the page is being auto-reloaded.
+ bool is_auto_reloading;
mmenke 2014/04/25 14:57:42 Think triggered_auto_reload would be clearer (Make
Elly Fong-Jones 2014/04/25 20:01:26 Done.
};
bool NetErrorHelperCore::IsReloadableError(
@@ -322,12 +326,6 @@ void NetErrorHelperCore::CancelPendingFetches() {
// Cancel loading the alternate error page, and prevent any pending error page
// load from starting a new error page load. Swapping in the error page when
// it's finished loading could abort the navigation, otherwise.
- if (committed_error_page_info_ && can_auto_reload_page_) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop",
- -committed_error_page_info_->error.reason,
- net::GetAllErrorCodesForUma());
- UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop", auto_reload_count_);
- }
if (committed_error_page_info_) {
committed_error_page_info_->navigation_correction_url = GURL();
committed_error_page_info_->navigation_correction_request_body.clear();
@@ -342,6 +340,12 @@ void NetErrorHelperCore::CancelPendingFetches() {
}
void NetErrorHelperCore::OnStop() {
+ if (committed_error_page_info_ &&
+ (committed_error_page_info_->is_auto_reloading ||
+ auto_reload_timer_->IsRunning())) {
mmenke 2014/04/25 14:57:42 So if a user presses stop while the autoreload tim
Elly Fong-Jones 2014/04/25 20:01:26 If they trigger a new navigation while it's runnin
mmenke 2014/04/25 20:08:03 But autoreload won't have been triggered. We reco
+ ReportAutoReloadFailure(committed_error_page_info_->error.reason,
+ auto_reload_count_);
+ }
CancelPendingFetches();
auto_reload_count_ = 0;
}
@@ -360,7 +364,7 @@ void NetErrorHelperCore::OnStartLoad(FrameType frame_type, PageType page_type) {
}
}
-void NetErrorHelperCore::OnCommitLoad(FrameType frame_type) {
+void NetErrorHelperCore::OnCommitLoad(FrameType frame_type, const GURL& url) {
if (frame_type != MAIN_FRAME)
return;
@@ -383,22 +387,37 @@ void NetErrorHelperCore::OnCommitLoad(FrameType frame_type) {
navigation_from_button_ = NO_BUTTON;
if (committed_error_page_info_ && !pending_error_page_info_ &&
- can_auto_reload_page_) {
+ committed_error_page_info_->is_auto_reloading) {
+ const GURL& error_url = committed_error_page_info_->error.unreachableURL;
int reason = committed_error_page_info_->error.reason;
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtSuccess",
- -reason,
- net::GetAllErrorCodesForUma());
- UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtSuccess", auto_reload_count_);
- if (auto_reload_count_ == 1) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtFirstSuccess",
- -reason,
- net::GetAllErrorCodesForUma());
- }
+ if (url == error_url)
+ ReportAutoReloadSuccess(reason, auto_reload_count_);
+ else
+ ReportAutoReloadFailure(reason, auto_reload_count_);
}
committed_error_page_info_.reset(pending_error_page_info_.release());
}
+void NetErrorHelperCore::ReportAutoReloadSuccess(int error, size_t count) {
mmenke 2014/04/25 14:57:42 These should either be in a private anonymous name
Elly Fong-Jones 2014/04/25 20:01:26 Done.
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtSuccess",
+ -error,
+ net::GetAllErrorCodesForUma());
+ UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtSuccess", count);
+ if (count == 1) {
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtFirstSuccess",
+ -error,
+ net::GetAllErrorCodesForUma());
+ }
+}
+
+void NetErrorHelperCore::ReportAutoReloadFailure(int error, size_t count) {
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.AutoReload.ErrorAtStop",
+ -error,
+ net::GetAllErrorCodesForUma());
+ UMA_HISTOGRAM_COUNTS("Net.AutoReload.CountAtStop", count);
+}
+
void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) {
if (frame_type != MAIN_FRAME)
return;
@@ -646,13 +665,18 @@ void NetErrorHelperCore::StartAutoReloadTimer() {
DCHECK(committed_error_page_info_);
DCHECK(can_auto_reload_page_);
base::TimeDelta delay = GetAutoReloadTime(auto_reload_count_);
- auto_reload_count_++;
auto_reload_timer_->Stop();
auto_reload_timer_->Start(FROM_HERE, delay,
- base::Bind(&NetErrorHelperCore::Reload,
+ base::Bind(&NetErrorHelperCore::AutoReloadTimerFired,
base::Unretained(this)));
}
+void NetErrorHelperCore::AutoReloadTimerFired() {
+ auto_reload_count_++;
+ committed_error_page_info_->is_auto_reloading = true;
+ Reload();
+}
+
void NetErrorHelperCore::NetworkStateChanged(bool online) {
online_ = online;
if (auto_reload_timer_->IsRunning()) {

Powered by Google App Engine
This is Rietveld 408576698