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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 EndReasonForPageTransition(new_navigation->GetPageTransition()), | 565 EndReasonForPageTransition(new_navigation->GetPageTransition()), |
566 user_initiated_info, timestamp, false); | 566 user_initiated_info, timestamp, false); |
567 } | 567 } |
568 | 568 |
569 aborted_provisional_loads_.clear(); | 569 aborted_provisional_loads_.clear(); |
570 return last_aborted_load; | 570 return last_aborted_load; |
571 } | 571 } |
572 | 572 |
573 void MetricsWebContentsObserver::OnTimingUpdated( | 573 void MetricsWebContentsObserver::OnTimingUpdated( |
574 content::RenderFrameHost* render_frame_host, | 574 content::RenderFrameHost* render_frame_host, |
575 const PageLoadTiming& timing, | 575 const mojom::PageLoadTiming& timing, |
576 const PageLoadMetadata& metadata) { | 576 const mojom::PageLoadMetadata& metadata) { |
577 // We may receive notifications from frames that have been navigated away | 577 // We may receive notifications from frames that have been navigated away |
578 // from. We simply ignore them. | 578 // from. We simply ignore them. |
579 if (GetMainFrame(render_frame_host) != web_contents()->GetMainFrame()) { | 579 if (GetMainFrame(render_frame_host) != web_contents()->GetMainFrame()) { |
580 RecordInternalError(ERR_IPC_FROM_WRONG_FRAME); | 580 RecordInternalError(ERR_IPC_FROM_WRONG_FRAME); |
581 return; | 581 return; |
582 } | 582 } |
583 | 583 |
584 // While timings arriving for the wrong frame are expected, we do not expect | 584 // While timings arriving for the wrong frame are expected, we do not expect |
585 // any of the errors below. Thus, we track occurrences of all errors below, | 585 // any of the errors below. Thus, we track occurrences of all errors below, |
586 // rather than returning early after encountering an error. | 586 // rather than returning early after encountering an error. |
587 | 587 |
588 bool error = false; | 588 bool error = false; |
589 if (!committed_load_) { | 589 if (!committed_load_) { |
590 RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD); | 590 RecordInternalError(ERR_IPC_WITH_NO_RELEVANT_LOAD); |
591 error = true; | 591 error = true; |
592 } | 592 } |
593 | 593 |
594 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { | 594 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { |
595 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); | 595 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); |
596 error = true; | 596 error = true; |
597 } | 597 } |
598 | 598 |
599 if (error) | 599 if (error) |
600 return; | 600 return; |
601 | 601 |
602 if (render_frame_host->GetParent() != nullptr) { | 602 if (render_frame_host->GetParent() != nullptr) { |
603 // Child frames may send PageLoadMetadata updates, but not PageLoadTiming | 603 // Child frames may send PageLoadMetadata updates, but not PageLoadTiming |
604 // updates. | 604 // updates. |
605 if (!timing.IsEmpty()) | 605 if (!IsEmpty(timing)) |
606 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME); | 606 RecordInternalError(ERR_TIMING_IPC_FROM_SUBFRAME); |
607 committed_load_->UpdateChildFrameMetadata(metadata); | 607 committed_load_->UpdateChildFrameMetadata(metadata); |
608 return; | 608 return; |
609 } | 609 } |
610 | 610 |
611 committed_load_->UpdateTiming(timing, metadata); | 611 committed_load_->UpdateTiming(timing, metadata); |
612 | 612 |
613 for (auto& observer : testing_observers_) | 613 for (auto& observer : testing_observers_) |
614 observer.OnTimingUpdated(true /* is_main_frame */, timing, metadata); | 614 observer.OnTimingUpdated(true /* is_main_frame */, timing, metadata); |
615 } | 615 } |
(...skipping 30 matching lines...) Expand all Loading... |
646 observer_->RemoveTestingObserver(this); | 646 observer_->RemoveTestingObserver(this); |
647 observer_ = nullptr; | 647 observer_ = nullptr; |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { | 651 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { |
652 observer_ = nullptr; | 652 observer_ = nullptr; |
653 } | 653 } |
654 | 654 |
655 } // namespace page_load_metrics | 655 } // namespace page_load_metrics |
OLD | NEW |