| 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", |
| 144 orientation_changed); |
| 145 if (orientation_changed) { |
| 146 UMA_HISTOGRAM_COUNTS( |
| 147 "MobileFullscreenVideo.DurationAfterPotraitRotation", |
| 148 playback_duration_in_milliseconds_after_orientation_change); |
| 149 } |
| 150 } else { |
| 151 UMA_HISTOGRAM_COUNTS( |
| 152 "MobileFullscreenVideo.LandscapeDuration", |
| 153 playback_duration_in_milliseconds_before_orientation_change); |
| 154 } |
| 155 } |
| 156 |
| 120 void ContentVideoView::UpdateMediaMetadata() { | 157 void ContentVideoView::UpdateMediaMetadata() { |
| 121 JNIEnv* env = AttachCurrentThread(); | 158 JNIEnv* env = AttachCurrentThread(); |
| 122 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 159 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
| 123 if (content_video_view.is_null()) | 160 if (content_video_view.is_null()) |
| 124 return; | 161 return; |
| 125 | 162 |
| 126 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 163 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
| 127 if (player && player->IsPlayerReady()) { | 164 if (player && player->IsPlayerReady()) { |
| 128 Java_ContentVideoView_onUpdateMediaMetadata( | 165 Java_ContentVideoView_onUpdateMediaMetadata( |
| 129 env, content_video_view.obj(), player->GetVideoWidth(), | 166 env, content_video_view.obj(), player->GetVideoWidth(), |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 267 } |
| 231 | 268 |
| 232 if (power_save_blocker_) return; | 269 if (power_save_blocker_) return; |
| 233 | 270 |
| 234 power_save_blocker_ = PowerSaveBlocker::Create( | 271 power_save_blocker_ = PowerSaveBlocker::Create( |
| 235 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 272 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 236 "Playing video").Pass(); | 273 "Playing video").Pass(); |
| 237 static_cast<PowerSaveBlockerImpl*>(power_save_blocker_.get())-> | 274 static_cast<PowerSaveBlockerImpl*>(power_save_blocker_.get())-> |
| 238 InitDisplaySleepBlocker(GetNativeView()); | 275 InitDisplaySleepBlocker(GetNativeView()); |
| 239 } | 276 } |
| 277 |
| 240 } // namespace content | 278 } // namespace content |
| OLD | NEW |