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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" | 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return; | 403 return; |
404 if (embedder_interface_->IsPrerendering(web_contents())) | 404 if (embedder_interface_->IsPrerendering(web_contents())) |
405 return; | 405 return; |
406 // We can have two provisional loads in some cases. E.g. a same-site | 406 // We can have two provisional loads in some cases. E.g. a same-site |
407 // navigation can have a concurrent cross-process navigation started | 407 // navigation can have a concurrent cross-process navigation started |
408 // from the omnibox. | 408 // from the omnibox. |
409 DCHECK_GT(2ul, provisional_loads_.size()); | 409 DCHECK_GT(2ul, provisional_loads_.size()); |
410 // Passing raw pointers to observers_ and embedder_interface_ is safe because | 410 // Passing raw pointers to observers_ and embedder_interface_ is safe because |
411 // the MetricsWebContentsObserver owns them both list and they are torn down | 411 // the MetricsWebContentsObserver owns them both list and they are torn down |
412 // after the PageLoadTracker. | 412 // after the PageLoadTracker. |
413 provisional_loads_.insert(navigation_handle, | 413 provisional_loads_.insert(std::make_pair( |
414 make_scoped_ptr(new PageLoadTracker( | 414 navigation_handle, make_scoped_ptr(new PageLoadTracker( |
415 in_foreground_, embedder_interface_.get(), | 415 in_foreground_, embedder_interface_.get(), |
416 navigation_handle, &observers_))); | 416 navigation_handle, &observers_)))); |
417 } | 417 } |
418 | 418 |
419 void MetricsWebContentsObserver::DidFinishNavigation( | 419 void MetricsWebContentsObserver::DidFinishNavigation( |
420 content::NavigationHandle* navigation_handle) { | 420 content::NavigationHandle* navigation_handle) { |
421 if (!navigation_handle->IsInMainFrame()) | 421 if (!navigation_handle->IsInMainFrame()) |
422 return; | 422 return; |
423 | 423 |
424 scoped_ptr<PageLoadTracker> finished_nav( | 424 scoped_ptr<PageLoadTracker> finished_nav( |
425 provisional_loads_.take_and_erase(navigation_handle)); | 425 std::move(provisional_loads_[navigation_handle])); |
| 426 provisional_loads_.erase(navigation_handle); |
| 427 |
426 // There's a chance a navigation could have started before we were added to a | 428 // There's a chance a navigation could have started before we were added to a |
427 // tab. Bail out early if this is the case. | 429 // tab. Bail out early if this is the case. |
428 if (!finished_nav) | 430 if (!finished_nav) |
429 return; | 431 return; |
430 | 432 |
431 // Handle a pre-commit error here. Navigations that result in an error page | 433 // Handle a pre-commit error here. Navigations that result in an error page |
432 // will be ignored. Note that downloads/204s will result in HasCommitted() | 434 // will be ignored. Note that downloads/204s will result in HasCommitted() |
433 // returning false. | 435 // returning false. |
434 if (!navigation_handle->HasCommitted()) { | 436 if (!navigation_handle->HasCommitted()) { |
435 net::Error error = navigation_handle->GetNetErrorCode(); | 437 net::Error error = navigation_handle->GetNetErrorCode(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 527 |
526 if (!committed_load_->UpdateTiming(timing)) { | 528 if (!committed_load_->UpdateTiming(timing)) { |
527 // If the page load tracker cannot update its timing, something is wrong | 529 // If the page load tracker cannot update its timing, something is wrong |
528 // with the IPC (it's from another load, or it's invalid in some other way). | 530 // with the IPC (it's from another load, or it's invalid in some other way). |
529 // We expect this to be a rare occurrence. | 531 // We expect this to be a rare occurrence. |
530 RecordInternalError(ERR_BAD_TIMING_IPC); | 532 RecordInternalError(ERR_BAD_TIMING_IPC); |
531 } | 533 } |
532 } | 534 } |
533 | 535 |
534 } // namespace page_load_metrics | 536 } // namespace page_load_metrics |
OLD | NEW |