OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/android/content_video_view.h" | 5 #include "content/browser/android/content_video_view.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" |
10 #include "content/browser/android/content_view_core_impl.h" | 11 #include "content/browser/android/content_view_core_impl.h" |
11 #include "content/browser/media/android/browser_media_player_manager.h" | 12 #include "content/browser/media/android/browser_media_player_manager.h" |
12 #include "content/browser/power_save_blocker_impl.h" | 13 #include "content/browser/power_save_blocker_impl.h" |
13 #include "content/common/android/surface_texture_peer.h" | 14 #include "content/common/android/surface_texture_peer.h" |
| 15 #include "content/public/browser/user_metrics.h" |
14 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
15 #include "jni/ContentVideoView_jni.h" | 17 #include "jni/ContentVideoView_jni.h" |
16 | 18 |
17 using base::android::AttachCurrentThread; | 19 using base::android::AttachCurrentThread; |
18 using base::android::CheckException; | 20 using base::android::CheckException; |
19 using base::android::ScopedJavaGlobalRef; | 21 using base::android::ScopedJavaGlobalRef; |
| 22 using base::UserMetricsAction; |
| 23 using content::RecordAction; |
20 | 24 |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 namespace { | 27 namespace { |
24 // There can only be one content video view at a time, this holds onto that | 28 // There can only be one content video view at a time, this holds onto that |
25 // singleton instance. | 29 // singleton instance. |
26 ContentVideoView* g_content_video_view = NULL; | 30 ContentVideoView* g_content_video_view = NULL; |
27 | 31 |
28 } // namespace | 32 } // namespace |
29 | 33 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 114 } |
111 } | 115 } |
112 | 116 |
113 void ContentVideoView::OnExitFullscreen() { | 117 void ContentVideoView::OnExitFullscreen() { |
114 JNIEnv* env = AttachCurrentThread(); | 118 JNIEnv* env = AttachCurrentThread(); |
115 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 119 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
116 if (!content_video_view.is_null()) | 120 if (!content_video_view.is_null()) |
117 Java_ContentVideoView_onExitFullscreen(env, content_video_view.obj()); | 121 Java_ContentVideoView_onExitFullscreen(env, content_video_view.obj()); |
118 } | 122 } |
119 | 123 |
| 124 void ContentVideoView::RecordFullscreenPlayback( |
| 125 JNIEnv*, jobject, bool is_portrait_video, bool is_orientation_portrait) { |
| 126 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.OrientationPortrait", |
| 127 is_orientation_portrait); |
| 128 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.VideoPortrait", |
| 129 is_portrait_video); |
| 130 } |
| 131 |
| 132 void ContentVideoView::RecordExitFullscreenPlayback( |
| 133 JNIEnv*, jobject, bool is_portrait_video, |
| 134 long playback_duration_in_milliseconds_before_orientation_change, |
| 135 long playback_duration_in_milliseconds_after_orientation_change) { |
| 136 bool orientation_changed = ( |
| 137 playback_duration_in_milliseconds_after_orientation_change != 0); |
| 138 if (is_portrait_video) { |
| 139 UMA_HISTOGRAM_COUNTS( |
| 140 "MobileFullscreenVideo.PortraitDuration", |
| 141 playback_duration_in_milliseconds_before_orientation_change); |
| 142 UMA_HISTOGRAM_COUNTS( |
| 143 "MobileFullscreenVideo.PortraitRotation", orientation_changed); |
| 144 if (orientation_changed) { |
| 145 UMA_HISTOGRAM_COUNTS( |
| 146 "MobileFullscreenVideo.DurationAfterPotraitRotation", |
| 147 playback_duration_in_milliseconds_after_orientation_change); |
| 148 } |
| 149 } else { |
| 150 UMA_HISTOGRAM_COUNTS( |
| 151 "MobileFullscreenVideo.LandscapeDuration", |
| 152 playback_duration_in_milliseconds_before_orientation_change); |
| 153 UMA_HISTOGRAM_COUNTS( |
| 154 "MobileFullscreenVideo.LandscapeRotation", orientation_changed); |
| 155 } |
| 156 } |
| 157 |
120 void ContentVideoView::UpdateMediaMetadata() { | 158 void ContentVideoView::UpdateMediaMetadata() { |
121 JNIEnv* env = AttachCurrentThread(); | 159 JNIEnv* env = AttachCurrentThread(); |
122 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 160 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
123 if (content_video_view.is_null()) | 161 if (content_video_view.is_null()) |
124 return; | 162 return; |
125 | 163 |
126 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 164 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
127 if (player && player->IsPlayerReady()) { | 165 if (player && player->IsPlayerReady()) { |
128 Java_ContentVideoView_onUpdateMediaMetadata( | 166 Java_ContentVideoView_onUpdateMediaMetadata( |
129 env, content_video_view.obj(), player->GetVideoWidth(), | 167 env, content_video_view.obj(), player->GetVideoWidth(), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 268 } |
231 | 269 |
232 if (power_save_blocker_) return; | 270 if (power_save_blocker_) return; |
233 | 271 |
234 power_save_blocker_ = PowerSaveBlocker::Create( | 272 power_save_blocker_ = PowerSaveBlocker::Create( |
235 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 273 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
236 "Playing video").Pass(); | 274 "Playing video").Pass(); |
237 static_cast<PowerSaveBlockerImpl*>(power_save_blocker_.get())-> | 275 static_cast<PowerSaveBlockerImpl*>(power_save_blocker_.get())-> |
238 InitDisplaySleepBlocker(GetNativeView()); | 276 InitDisplaySleepBlocker(GetNativeView()); |
239 } | 277 } |
| 278 |
240 } // namespace content | 279 } // namespace content |
OLD | NEW |