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

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

Issue 2779783002: [Offline Pages] Add UMA to record final offline request status and loading failed error code. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/background_loader_offliner.h" 5 #include "chrome/browser/android/offline_pages/background_loader_offliner.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
10 #include "chrome/browser/android/offline_pages/offliner_helper.h" 10 #include "chrome/browser/android/offline_pages/offliner_helper.h"
(...skipping 26 matching lines...) Expand all
37 BackgroundLoaderOffliner* offliner() { return offliner_; } 37 BackgroundLoaderOffliner* offliner() { return offliner_; }
38 38
39 private: 39 private:
40 // The offliner that the WebContents is attached to. The offliner owns the 40 // The offliner that the WebContents is attached to. The offliner owns the
41 // Delegate which owns the WebContents that this data is attached to. 41 // Delegate which owns the WebContents that this data is attached to.
42 // Therefore, its lifetime should exceed that of the WebContents, so this 42 // Therefore, its lifetime should exceed that of the WebContents, so this
43 // should always be non-null. 43 // should always be non-null.
44 BackgroundLoaderOffliner* offliner_; 44 BackgroundLoaderOffliner* offliner_;
45 }; 45 };
46 46
47 std::string AddHistogramSuffix(const ClientId& client_id,
48 const char* histogram_name) {
49 if (client_id.name_space.empty()) {
50 NOTREACHED();
51 return histogram_name;
52 }
53 std::string adjusted_histogram_name(histogram_name);
54 adjusted_histogram_name += "." + client_id.name_space;
55 return adjusted_histogram_name;
56 }
57
58 void RecordErrorCauseUMA(const ClientId& client_id, net::Error error_code) {
59 UMA_HISTOGRAM_SPARSE_SLOWLY(
60 AddHistogramSuffix(client_id,
61 "OfflinePages.Background.BackgroundLoadingFailedCode"),
62 std::abs(error_code));
63 }
47 } // namespace 64 } // namespace
48 65
49 BackgroundLoaderOffliner::BackgroundLoaderOffliner( 66 BackgroundLoaderOffliner::BackgroundLoaderOffliner(
50 content::BrowserContext* browser_context, 67 content::BrowserContext* browser_context,
51 const OfflinerPolicy* policy, 68 const OfflinerPolicy* policy,
52 OfflinePageModel* offline_page_model) 69 OfflinePageModel* offline_page_model)
53 : browser_context_(browser_context), 70 : browser_context_(browser_context),
54 offline_page_model_(offline_page_model), 71 offline_page_model_(offline_page_model),
55 is_low_end_device_(base::SysInfo::IsLowEndDevice()), 72 is_low_end_device_(base::SysInfo::IsLowEndDevice()),
56 save_state_(NONE), 73 save_state_(NONE),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 243 }
227 } 244 }
228 245
229 void BackgroundLoaderOffliner::DidFinishNavigation( 246 void BackgroundLoaderOffliner::DidFinishNavigation(
230 content::NavigationHandle* navigation_handle) { 247 content::NavigationHandle* navigation_handle) {
231 if (!navigation_handle->IsInMainFrame()) 248 if (!navigation_handle->IsInMainFrame())
232 return; 249 return;
233 // If there was an error of any kind (certificate, client, DNS, etc), 250 // If there was an error of any kind (certificate, client, DNS, etc),
234 // Mark as error page. Resetting here causes RecordNavigationMetrics to crash. 251 // Mark as error page. Resetting here causes RecordNavigationMetrics to crash.
235 if (navigation_handle->IsErrorPage()) { 252 if (navigation_handle->IsErrorPage()) {
236 // TODO(chili): we need to UMA this. 253 RecordErrorCauseUMA(pending_request_->client_id(),
254 navigation_handle->GetNetErrorCode());
237 switch (navigation_handle->GetNetErrorCode()) { 255 switch (navigation_handle->GetNetErrorCode()) {
238 case net::ERR_ACCESS_DENIED: 256 case net::ERR_ACCESS_DENIED:
239 case net::ERR_ADDRESS_INVALID: 257 case net::ERR_ADDRESS_INVALID:
240 case net::ERR_ADDRESS_UNREACHABLE: 258 case net::ERR_ADDRESS_UNREACHABLE:
241 case net::ERR_CERT_COMMON_NAME_INVALID: 259 case net::ERR_CERT_COMMON_NAME_INVALID:
242 case net::ERR_CERT_AUTHORITY_INVALID: 260 case net::ERR_CERT_AUTHORITY_INVALID:
243 case net::ERR_CERT_CONTAINS_ERRORS: 261 case net::ERR_CERT_CONTAINS_ERRORS:
244 case net::ERR_CERT_INVALID: 262 case net::ERR_CERT_INVALID:
245 case net::ERR_CONNECTION_FAILED: 263 case net::ERR_CONNECTION_FAILED:
246 case net::ERR_DISALLOWED_URL_SCHEME: 264 case net::ERR_DISALLOWED_URL_SCHEME:
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 int64_t offline_id) { 411 int64_t offline_id) {
394 // If for some reason the request was reset during while waiting for callback 412 // If for some reason the request was reset during while waiting for callback
395 // ignore the completion callback. 413 // ignore the completion callback.
396 if (pending_request_ && pending_request_->request_id() != offline_id) 414 if (pending_request_ && pending_request_->request_id() != offline_id)
397 return; 415 return;
398 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); 416 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED);
399 } 417 }
400 } // namespace offline_pages 418 } // namespace offline_pages
401 419
402 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); 420 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698