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

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2884753002: [PageLoadMetrics] Relax invariants and log the exceptions (Closed)
Patch Set: Reduce histogram calls Created 3 years, 7 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/page_load_metrics/observers/ads_page_load_metrics_observer.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 auto it = provisional_loads_.find(navigation_handle); 208 auto it = provisional_loads_.find(navigation_handle);
209 if (it == provisional_loads_.end()) 209 if (it == provisional_loads_.end())
210 return; 210 return;
211 it->second->WillProcessNavigationResponse(navigation_handle); 211 it->second->WillProcessNavigationResponse(navigation_handle);
212 } 212 }
213 213
214 PageLoadTracker* MetricsWebContentsObserver::GetTrackerOrNullForRequest( 214 PageLoadTracker* MetricsWebContentsObserver::GetTrackerOrNullForRequest(
215 const content::GlobalRequestID& request_id, 215 const content::GlobalRequestID& request_id,
216 content::ResourceType resource_type, 216 content::ResourceType resource_type,
217 base::TimeTicks creation_time) { 217 base::TimeTicks creation_time) {
218 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { 218 // TODO(jkarlin): The WebContentsTester framework doesn't provide a default
219 // GlobalRequestID to its NavigationHandles. Once the test framework
220 // supports real ids, remove the request_id != content::GlobalRequestID()
221 // condition. See https://crbug.com/711352.
222 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME &&
223 request_id != content::GlobalRequestID()) {
219 // The main frame request can complete either before or after commit, so we 224 // The main frame request can complete either before or after commit, so we
220 // look at both provisional loads and the committed load to find a 225 // look at both provisional loads and the committed load to find a
221 // PageLoadTracker with a matching request id. See https://goo.gl/6TzCYN for 226 // PageLoadTracker with a matching request id. See https://goo.gl/6TzCYN for
222 // more details. 227 // more details.
223 for (const auto& kv : provisional_loads_) { 228 for (const auto& kv : provisional_loads_) {
224 PageLoadTracker* candidate = kv.second.get(); 229 PageLoadTracker* candidate = kv.second.get();
225 if (candidate->HasMatchingNavigationRequestID(request_id)) { 230 if (candidate->HasMatchingNavigationRequestID(request_id)) {
226 return candidate; 231 return candidate;
227 } 232 }
228 } 233 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 observer_->RemoveTestingObserver(this); 647 observer_->RemoveTestingObserver(this);
643 observer_ = nullptr; 648 observer_ = nullptr;
644 } 649 }
645 } 650 }
646 651
647 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { 652 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() {
648 observer_ = nullptr; 653 observer_ = nullptr;
649 } 654 }
650 655
651 } // namespace page_load_metrics 656 } // namespace page_load_metrics
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/ads_page_load_metrics_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698