| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { | 40 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { |
| 41 return RegisterNativesImpl(env); | 41 return RegisterNativesImpl(env); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ContentVideoView* ContentVideoView::GetInstance() { | 44 ContentVideoView* ContentVideoView::GetInstance() { |
| 45 return g_content_video_view; | 45 return g_content_video_view; |
| 46 } | 46 } |
| 47 | 47 |
| 48 ContentVideoView::ContentVideoView(Client* client, | 48 ContentVideoView::ContentVideoView(Client* client, |
| 49 ContentViewCore* content_view_core) | 49 ContentViewCore* content_view_core, |
| 50 const gfx::Size& video_natural_size) |
| 50 : client_(client), weak_factory_(this) { | 51 : client_(client), weak_factory_(this) { |
| 51 DCHECK(!g_content_video_view); | 52 DCHECK(!g_content_video_view); |
| 52 j_content_video_view_ = CreateJavaObject(content_view_core); | 53 j_content_video_view_ = |
| 54 CreateJavaObject(content_view_core, video_natural_size); |
| 53 g_content_video_view = this; | 55 g_content_video_view = this; |
| 54 } | 56 } |
| 55 | 57 |
| 56 ContentVideoView::~ContentVideoView() { | 58 ContentVideoView::~ContentVideoView() { |
| 57 DCHECK(g_content_video_view); | 59 DCHECK(g_content_video_view); |
| 58 JNIEnv* env = AttachCurrentThread(); | 60 JNIEnv* env = AttachCurrentThread(); |
| 59 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 61 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
| 60 if (!content_video_view.is_null()) { | 62 if (!content_video_view.is_null()) { |
| 61 Java_ContentVideoView_destroyContentVideoView(env, | 63 Java_ContentVideoView_destroyContentVideoView(env, |
| 62 content_video_view.obj(), true); | 64 content_video_view.obj(), true); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } else { | 152 } else { |
| 151 UMA_HISTOGRAM_COUNTS( | 153 UMA_HISTOGRAM_COUNTS( |
| 152 "MobileFullscreenVideo.LandscapeDuration", | 154 "MobileFullscreenVideo.LandscapeDuration", |
| 153 playback_duration_in_milliseconds_before_orientation_change); | 155 playback_duration_in_milliseconds_before_orientation_change); |
| 154 UMA_HISTOGRAM_COUNTS( | 156 UMA_HISTOGRAM_COUNTS( |
| 155 "MobileFullscreenVideo.LandscapeRotation", orientation_changed); | 157 "MobileFullscreenVideo.LandscapeRotation", orientation_changed); |
| 156 } | 158 } |
| 157 } | 159 } |
| 158 | 160 |
| 159 JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject( | 161 JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject( |
| 160 ContentViewCore* content_view_core) { | 162 ContentViewCore* content_view_core, |
| 163 const gfx::Size& video_natural_size) { |
| 161 JNIEnv* env = AttachCurrentThread(); | 164 JNIEnv* env = AttachCurrentThread(); |
| 162 base::android::ScopedJavaLocalRef<jobject> j_content_view_core = | 165 base::android::ScopedJavaLocalRef<jobject> j_content_view_core = |
| 163 content_view_core->GetJavaObject(); | 166 content_view_core->GetJavaObject(); |
| 164 if (j_content_view_core.is_null()) | 167 if (j_content_view_core.is_null()) |
| 165 return JavaObjectWeakGlobalRef(env, nullptr); | 168 return JavaObjectWeakGlobalRef(env, nullptr); |
| 166 | 169 |
| 167 return JavaObjectWeakGlobalRef( | 170 return JavaObjectWeakGlobalRef( |
| 168 env, | 171 env, Java_ContentVideoView_createContentVideoView( |
| 169 Java_ContentVideoView_createContentVideoView( | 172 env, j_content_view_core.obj(), reinterpret_cast<intptr_t>(this), |
| 170 env, | 173 video_natural_size.width(), video_natural_size.height()) |
| 171 j_content_view_core.obj(), | 174 .obj()); |
| 172 reinterpret_cast<intptr_t>(this)).obj()); | |
| 173 } | 175 } |
| 174 } // namespace content | 176 } // namespace content |
| OLD | NEW |