| OLD | NEW |
| 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/page_load_metrics/page_load_tracker.h" | 5 #include "chrome/browser/page_load_metrics/page_load_tracker.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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/user_metrics.h" | 15 #include "base/metrics/user_metrics.h" |
| 16 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface.
h" | 16 #include "chrome/browser/page_load_metrics/page_load_metrics_embedder_interface.
h" |
| 17 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 17 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
| 18 #include "chrome/common/page_load_metrics/page_load_timing.h" | 18 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| 19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
| 20 #include "content/public/browser/navigation_handle.h" | 20 #include "content/public/browser/navigation_handle.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/common/browser_side_navigation_policy.h" | 23 #include "content/public/common/browser_side_navigation_policy.h" |
| 23 #include "ui/base/page_transition_types.h" | 24 #include "ui/base/page_transition_types.h" |
| 24 | 25 |
| 25 // This macro invokes the specified method on each observer, passing the | 26 // This macro invokes the specified method on each observer, passing the |
| 26 // variable length arguments as the method's arguments, and removes the observer | 27 // variable length arguments as the method's arguments, and removes the observer |
| 27 // from the list of observers if the given method returns STOP_OBSERVING. | 28 // from the list of observers if the given method returns STOP_OBSERVING. |
| 28 #define INVOKE_AND_PRUNE_OBSERVERS(observers, Method, ...) \ | 29 #define INVOKE_AND_PRUNE_OBSERVERS(observers, Method, ...) \ |
| 29 for (auto it = observers.begin(); it != observers.end();) { \ | 30 for (auto it = observers.begin(); it != observers.end();) { \ |
| 30 if ((*it)->Method(__VA_ARGS__) == \ | 31 if ((*it)->Method(__VA_ARGS__) == \ |
| 31 PageLoadMetricsObserver::STOP_OBSERVING) { \ | 32 PageLoadMetricsObserver::STOP_OBSERVING) { \ |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // explicitly filter these types of aborts out when deciding if the abort was | 726 // explicitly filter these types of aborts out when deciding if the abort was |
| 726 // user initiated. | 727 // user initiated. |
| 727 if (page_end_reason != END_CLIENT_REDIRECT) | 728 if (page_end_reason != END_CLIENT_REDIRECT) |
| 728 page_end_user_initiated_info_ = user_initiated_info; | 729 page_end_user_initiated_info_ = user_initiated_info; |
| 729 | 730 |
| 730 if (is_certainly_browser_timestamp) { | 731 if (is_certainly_browser_timestamp) { |
| 731 ClampBrowserTimestampIfInterProcessTimeTickSkew(&page_end_time_); | 732 ClampBrowserTimestampIfInterProcessTimeTickSkew(&page_end_time_); |
| 732 } | 733 } |
| 733 } | 734 } |
| 734 | 735 |
| 736 void PageLoadTracker::MediaStartedPlaying( |
| 737 const content::WebContentsObserver::MediaPlayerInfo& video_type, |
| 738 bool is_in_main_frame) { |
| 739 for (const auto& observer : observers_) |
| 740 observer->MediaStartedPlaying(video_type, is_in_main_frame); |
| 741 } |
| 742 |
| 735 } // namespace page_load_metrics | 743 } // namespace page_load_metrics |
| OLD | NEW |