OLD | NEW |
---|---|
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 Loading... | |
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 test frameworks don't provide a default |
219 // GlobalRequestID to their NavigationHandles. Once the test frameworks | |
220 // support real ids, remove the request_id != content::GlobalRequestID() | |
221 // condition. See https://crbug.com/711352. | |
Bryan McQuade
2017/05/16 16:22:36
Does csharrison's https://codereview.chromium.org/
jkarlin
2017/05/16 17:16:08
It addresses it for tests that use Navigation Simu
| |
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 Loading... | |
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 |
OLD | NEW |