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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_tab_helper.cc

Issue 2452593003: Fix incorrectly reported UMA OfflinePages.AggregatedRequestResult (Closed)
Patch Set: Address feedback Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" 5 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/android/offline_pages/offline_page_request_job.h" 10 #include "chrome/browser/android/offline_pages/offline_page_request_job.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 DCHECK(!provisional_offline_info_.offline_page || 89 DCHECK(!provisional_offline_info_.offline_page ||
90 navigated_url == provisional_offline_info_.offline_page->url); 90 navigated_url == provisional_offline_info_.offline_page->url);
91 offline_info_.offline_page = 91 offline_info_.offline_page =
92 std::move(provisional_offline_info_.offline_page); 92 std::move(provisional_offline_info_.offline_page);
93 offline_info_.offline_header = provisional_offline_info_.offline_header; 93 offline_info_.offline_header = provisional_offline_info_.offline_header;
94 offline_info_.is_offline_preview = 94 offline_info_.is_offline_preview =
95 provisional_offline_info_.is_offline_preview; 95 provisional_offline_info_.is_offline_preview;
96 } 96 }
97 provisional_offline_info_.Clear(); 97 provisional_offline_info_.Clear();
98 98
99 // If the offline page has been loaded successfully, nothing more to do.
100 net::Error error_code = navigation_handle->GetNetErrorCode();
101 if (error_code == net::OK)
102 return;
103
99 // We might be reloading the URL in order to fetch the offline page. 104 // We might be reloading the URL in order to fetch the offline page.
100 // * If successful, nothing to do. 105 // * If successful, nothing to do.
101 // * Otherwise, we're hitting error again. Bail out to avoid loop. 106 // * Otherwise, we're hitting error again. Bail out to avoid loop.
102 if (reloading_url_on_net_error_) 107 if (reloading_url_on_net_error_)
103 return; 108 return;
104 109
105 // When the navigation starts, the request might be intercepted to serve the 110 // When the navigation starts, the request might be intercepted to serve the
106 // offline content if the network is detected to be in disconnected or poor 111 // offline content if the network is detected to be in disconnected or poor
107 // conditions. This detection might not work for some cases, i.e., connected 112 // conditions. This detection might not work for some cases, i.e., connected
108 // to a hotspot or proxy that does not have network, and the navigation will 113 // to a hotspot or proxy that does not have network, and the navigation will
109 // eventually fail. To handle this, we will reload the page to force the 114 // eventually fail. To handle this, we will reload the page to force the
110 // offline interception if the error code matches the following list. 115 // offline interception if the error code matches the following list.
111 // Otherwise, the error page will be shown. 116 // Otherwise, the error page will be shown.
112 net::Error error_code = navigation_handle->GetNetErrorCode();
113 if (error_code != net::ERR_INTERNET_DISCONNECTED && 117 if (error_code != net::ERR_INTERNET_DISCONNECTED &&
114 error_code != net::ERR_NAME_NOT_RESOLVED && 118 error_code != net::ERR_NAME_NOT_RESOLVED &&
115 error_code != net::ERR_ADDRESS_UNREACHABLE && 119 error_code != net::ERR_ADDRESS_UNREACHABLE &&
116 error_code != net::ERR_PROXY_CONNECTION_FAILED) { 120 error_code != net::ERR_PROXY_CONNECTION_FAILED) {
117 // Do not report aborted error since the error page is not shown on this 121 // Do not report aborted error since the error page is not shown on this
118 // error. 122 // error.
119 if (error_code != net::ERR_ABORTED) { 123 if (error_code != net::ERR_ABORTED) {
120 OfflinePageRequestJob::ReportAggregatedRequestResult( 124 OfflinePageRequestJob::ReportAggregatedRequestResult(
121 OfflinePageRequestJob::AggregatedRequestResult::SHOW_NET_ERROR_PAGE); 125 OfflinePageRequestJob::AggregatedRequestResult::SHOW_NET_ERROR_PAGE);
122 } 126 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 base::MakeUnique<OfflinePageItem>(offline_page); 175 base::MakeUnique<OfflinePageItem>(offline_page);
172 provisional_offline_info_.offline_header = offline_header; 176 provisional_offline_info_.offline_header = offline_header;
173 provisional_offline_info_.is_offline_preview = is_offline_preview; 177 provisional_offline_info_.is_offline_preview = is_offline_preview;
174 } 178 }
175 179
176 const OfflinePageItem* OfflinePageTabHelper::GetOfflinePageForTest() const { 180 const OfflinePageItem* OfflinePageTabHelper::GetOfflinePageForTest() const {
177 return provisional_offline_info_.offline_page.get(); 181 return provisional_offline_info_.offline_page.get();
178 } 182 }
179 183
180 } // namespace offline_pages 184 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698