| 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_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OBSER
VER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OBSER
VER_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OBSER
VER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OBSER
VER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" | 11 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 namespace page_load_metrics { | |
| 15 struct PageLoadExtraInfo; | |
| 16 struct PageLoadTiming; | |
| 17 } | |
| 18 | |
| 19 // Observer responsible for recording metrics on pages that play at least one | 14 // Observer responsible for recording metrics on pages that play at least one |
| 20 // MEDIA request. | 15 // MEDIA request. |
| 21 class MediaPageLoadMetricsObserver | 16 class MediaPageLoadMetricsObserver |
| 22 : public page_load_metrics::PageLoadMetricsObserver { | 17 : public page_load_metrics::PageLoadMetricsObserver { |
| 23 public: | 18 public: |
| 24 MediaPageLoadMetricsObserver(); | 19 MediaPageLoadMetricsObserver(); |
| 25 ~MediaPageLoadMetricsObserver() override; | 20 ~MediaPageLoadMetricsObserver() override; |
| 26 | 21 |
| 27 // page_load_metrics::PageLoadMetricsObserver: | 22 // page_load_metrics::PageLoadMetricsObserver: |
| 28 void OnComplete(const page_load_metrics::PageLoadTiming& timing, | 23 void OnComplete(const page_load_metrics::mojom::PageLoadTiming& timing, |
| 29 const page_load_metrics::PageLoadExtraInfo& info) override; | 24 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 30 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 25 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 31 FlushMetricsOnAppEnterBackground( | 26 FlushMetricsOnAppEnterBackground( |
| 32 const page_load_metrics::PageLoadTiming& timing, | 27 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 33 const page_load_metrics::PageLoadExtraInfo& info) override; | 28 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 34 void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo& | 29 void OnLoadedResource(const page_load_metrics::ExtraRequestCompleteInfo& |
| 35 extra_request_complete_info) override; | 30 extra_request_complete_info) override; |
| 36 void MediaStartedPlaying( | 31 void MediaStartedPlaying( |
| 37 const content::WebContentsObserver::MediaPlayerInfo& video_type, | 32 const content::WebContentsObserver::MediaPlayerInfo& video_type, |
| 38 bool is_in_main_frame) override; | 33 bool is_in_main_frame) override; |
| 39 | 34 |
| 40 private: | 35 private: |
| 41 // Records histograms for byte information. | 36 // Records histograms for byte information. |
| 42 void RecordByteHistograms(); | 37 void RecordByteHistograms(); |
| 43 | 38 |
| 44 // The number of body (not header) prefilter bytes consumed by requests for | 39 // The number of body (not header) prefilter bytes consumed by requests for |
| 45 // the page. | 40 // the page. |
| 46 int64_t cache_bytes_; | 41 int64_t cache_bytes_; |
| 47 int64_t network_bytes_; | 42 int64_t network_bytes_; |
| 48 | 43 |
| 49 // Whether the page load played a media element. | 44 // Whether the page load played a media element. |
| 50 bool played_media_; | 45 bool played_media_; |
| 51 | 46 |
| 52 DISALLOW_COPY_AND_ASSIGN(MediaPageLoadMetricsObserver); | 47 DISALLOW_COPY_AND_ASSIGN(MediaPageLoadMetricsObserver); |
| 53 }; | 48 }; |
| 54 | 49 |
| 55 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OB
SERVER_H_ | 50 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_MEDIA_PAGE_LOAD_METRICS_OB
SERVER_H_ |
| OLD | NEW |