Commit 0c9b968d authored by prashantv's avatar prashantv Committed by Commit bot

Propagate media play/pause to WebContentsObserver for Chromecast metrics

Propagate OnMedia{Playing,Paused}Notification to WebContentsObserver and use
this to track Chromecast metrics.

BUG=417000

Review URL: https://codereview.chromium.org/1037593003

Cr-Commit-Position: refs/heads/master@{#322282}
parent 2166dd4a
...@@ -119,4 +119,12 @@ void CastContentWindow::DidFirstVisuallyNonEmptyPaint() { ...@@ -119,4 +119,12 @@ void CastContentWindow::DidFirstVisuallyNonEmptyPaint() {
metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint();
} }
void CastContentWindow::MediaPaused() {
metrics::CastMetricsHelper::GetInstance()->LogMediaPause();
}
void CastContentWindow::MediaStartedPlaying() {
metrics::CastMetricsHelper::GetInstance()->LogMediaPlay();
}
} // namespace chromecast } // namespace chromecast
...@@ -44,6 +44,8 @@ class CastContentWindow : public content::WebContentsObserver { ...@@ -44,6 +44,8 @@ class CastContentWindow : public content::WebContentsObserver {
// content::WebContentsObserver implementation: // content::WebContentsObserver implementation:
void DidFirstVisuallyNonEmptyPaint() override; void DidFirstVisuallyNonEmptyPaint() override;
void MediaPaused() override;
void MediaStartedPlaying() override;
private: private:
#if defined(USE_AURA) #if defined(USE_AURA)
......
...@@ -3326,12 +3326,16 @@ void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, ...@@ -3326,12 +3326,16 @@ void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie,
if (!video_power_save_blocker_ && !IsHidden()) if (!video_power_save_blocker_ && !IsHidden())
CreateVideoPowerSaveBlocker(); CreateVideoPowerSaveBlocker();
} }
FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying());
} }
void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) {
RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); RemoveMediaPlayerEntry(player_cookie, &active_audio_players_);
RemoveMediaPlayerEntry(player_cookie, &active_video_players_); RemoveMediaPlayerEntry(player_cookie, &active_video_players_);
MaybeReleasePowerSaveBlockers(); MaybeReleasePowerSaveBlockers();
FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaPaused());
} }
void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() {
......
...@@ -343,6 +343,12 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, ...@@ -343,6 +343,12 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
// Invoked when theme color is changed to |theme_color|. // Invoked when theme color is changed to |theme_color|.
virtual void DidChangeThemeColor(SkColor theme_color) {} virtual void DidChangeThemeColor(SkColor theme_color) {}
// Invoked when media is playing.
virtual void MediaStartedPlaying() {}
// Invoked when media is paused.
virtual void MediaPaused() {}
// Invoked if an IPC message is coming from a specific RenderFrameHost. // Invoked if an IPC message is coming from a specific RenderFrameHost.
virtual bool OnMessageReceived(const IPC::Message& message, virtual bool OnMessageReceived(const IPC::Message& message,
RenderFrameHost* render_frame_host); RenderFrameHost* render_frame_host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment