Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/timer/timer.h" | |
|
Charlie Harrison
2017/05/26 19:31:34
Can just fwd declare I think
Bryan McQuade
2017/05/26 20:07:32
Done
| |
| 12 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h" | 13 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 class NavigationHandle; | 16 class NavigationHandle; |
| 16 class RenderFrameHost; | 17 class RenderFrameHost; |
| 17 } // namespace content | 18 } // namespace content |
| 18 | 19 |
| 19 namespace page_load_metrics { | 20 namespace page_load_metrics { |
| 20 | 21 |
| 21 class PageLoadMetricsEmbedderInterface; | 22 class PageLoadMetricsEmbedderInterface; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 INVALID_ORDER_FIRST_PAINT_FIRST_TEXT_PAINT, | 59 INVALID_ORDER_FIRST_PAINT_FIRST_TEXT_PAINT, |
| 59 INVALID_ORDER_FIRST_PAINT_FIRST_IMAGE_PAINT, | 60 INVALID_ORDER_FIRST_PAINT_FIRST_IMAGE_PAINT, |
| 60 INVALID_ORDER_FIRST_PAINT_FIRST_CONTENTFUL_PAINT, | 61 INVALID_ORDER_FIRST_PAINT_FIRST_CONTENTFUL_PAINT, |
| 61 INVALID_ORDER_FIRST_PAINT_FIRST_MEANINGFUL_PAINT, | 62 INVALID_ORDER_FIRST_PAINT_FIRST_MEANINGFUL_PAINT, |
| 62 | 63 |
| 63 // New values should be added before this final entry. | 64 // New values should be added before this final entry. |
| 64 LAST_PAGE_LOAD_TIMING_STATUS | 65 LAST_PAGE_LOAD_TIMING_STATUS |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 extern const char kPageLoadTimingStatus[]; | 68 extern const char kPageLoadTimingStatus[]; |
| 69 extern const char kHistogramOutOfOrderTiming[]; | |
| 70 extern const char kHistogramOutOfOrderTimingBuffered[]; | |
| 68 | 71 |
| 69 } // namespace internal | 72 } // namespace internal |
| 70 | 73 |
| 71 // PageLoadMetricsUpdateDispatcher manages updates to page load metrics data, | 74 // PageLoadMetricsUpdateDispatcher manages updates to page load metrics data, |
| 72 // and dispatches them to the Client. PageLoadMetricsUpdateDispatcher may delay | 75 // and dispatches them to the Client. PageLoadMetricsUpdateDispatcher may delay |
| 73 // dispatching metrics updates to the Client in cases where metrics state hasn't | 76 // dispatching metrics updates to the Client in cases where metrics state hasn't |
| 74 // stabilized. | 77 // stabilized. |
| 75 class PageLoadMetricsUpdateDispatcher { | 78 class PageLoadMetricsUpdateDispatcher { |
| 76 public: | 79 public: |
| 77 // The Client class is updated when metrics managed by the dispatcher have | 80 // The Client class is updated when metrics managed by the dispatcher have |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 private: | 118 private: |
| 116 using FrameTreeNodeId = int; | 119 using FrameTreeNodeId = int; |
| 117 | 120 |
| 118 void UpdateMainFrameTiming(const mojom::PageLoadTiming& new_timing); | 121 void UpdateMainFrameTiming(const mojom::PageLoadTiming& new_timing); |
| 119 void UpdateSubFrameTiming(content::RenderFrameHost* render_frame_host, | 122 void UpdateSubFrameTiming(content::RenderFrameHost* render_frame_host, |
| 120 const mojom::PageLoadTiming& new_timing); | 123 const mojom::PageLoadTiming& new_timing); |
| 121 | 124 |
| 122 void UpdateMainFrameMetadata(const mojom::PageLoadMetadata& new_metadata); | 125 void UpdateMainFrameMetadata(const mojom::PageLoadMetadata& new_metadata); |
| 123 void UpdateSubFrameMetadata(const mojom::PageLoadMetadata& subframe_metadata); | 126 void UpdateSubFrameMetadata(const mojom::PageLoadMetadata& subframe_metadata); |
| 124 | 127 |
| 125 // Merge values from |new_paint_timing| into |pending_merged_page_timing_|, | 128 void MaybeDispatchTimingUpdates(bool did_merge_new_timing_value); |
| 126 // offsetting any new timings by the |navigation_start_offset|. | |
| 127 void MergePaintTiming(base::TimeDelta navigation_start_offset, | |
| 128 const mojom::PaintTiming& new_paint_timing, | |
| 129 bool is_main_frame); | |
| 130 | |
| 131 void DispatchTimingUpdates(); | 129 void DispatchTimingUpdates(); |
| 132 | 130 |
| 133 // The client is guaranteed to outlive this object. | 131 // The client is guaranteed to outlive this object. |
| 134 Client* const client_; | 132 Client* const client_; |
| 135 | 133 |
| 136 // Interface to chrome features. Must outlive the class. | 134 // Interface to chrome features. Must outlive the class. |
| 137 PageLoadMetricsEmbedderInterface* const embedder_interface_; | 135 PageLoadMetricsEmbedderInterface* const embedder_interface_; |
| 138 | 136 |
| 137 std::unique_ptr<base::Timer> timer_; | |
| 138 | |
| 139 // Time the navigation for this page load was initiated. | 139 // Time the navigation for this page load was initiated. |
| 140 const base::TimeTicks navigation_start_; | 140 const base::TimeTicks navigation_start_; |
| 141 | 141 |
| 142 // PageLoadTiming for the currently tracked page. The fields in |paint_timing| | 142 // PageLoadTiming for the currently tracked page. The fields in |paint_timing| |
| 143 // are merged across all frames in the document. All other fields are from the | 143 // are merged across all frames in the document. All other fields are from the |
| 144 // main frame document. |current_merged_page_timing_| contains the most recent | 144 // main frame document. |current_merged_page_timing_| contains the most recent |
| 145 // valid page load timing data, while pending_merged_page_timing_ contains | 145 // valid page load timing data, while pending_merged_page_timing_ contains |
| 146 // pending updates received since |current_merged_page_timing_| was last | 146 // pending updates received since |current_merged_page_timing_| was last |
| 147 // dispatched to the client. pending_merged_page_timing_ will be copied to | 147 // dispatched to the client. pending_merged_page_timing_ will be copied to |
| 148 // |current_merged_page_timing_| once it is valid, at the time the | 148 // |current_merged_page_timing_| once it is valid, at the time the |
| 149 // Client::OnTimingChanged callback is invoked. | 149 // Client::OnTimingChanged callback is invoked. |
| 150 mojom::PageLoadTimingPtr current_merged_page_timing_; | 150 mojom::PageLoadTimingPtr current_merged_page_timing_; |
| 151 mojom::PageLoadTimingPtr pending_merged_page_timing_; | 151 mojom::PageLoadTimingPtr pending_merged_page_timing_; |
| 152 | 152 |
| 153 mojom::PageLoadMetadataPtr main_frame_metadata_; | 153 mojom::PageLoadMetadataPtr main_frame_metadata_; |
| 154 mojom::PageLoadMetadataPtr subframe_metadata_; | 154 mojom::PageLoadMetadataPtr subframe_metadata_; |
| 155 | 155 |
| 156 // Navigation start offsets for the most recently committed document in each | 156 // Navigation start offsets for the most recently committed document in each |
| 157 // frame. | 157 // frame. |
| 158 std::map<FrameTreeNodeId, base::TimeDelta> subframe_navigation_start_offset_; | 158 std::map<FrameTreeNodeId, base::TimeDelta> subframe_navigation_start_offset_; |
| 159 | 159 |
| 160 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsUpdateDispatcher); | 160 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsUpdateDispatcher); |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 } // namespace page_load_metrics | 163 } // namespace page_load_metrics |
| 164 | 164 |
| 165 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_ H_ | 165 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UPDATE_DISPATCHER_ H_ |
| OLD | NEW |