Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: content/browser/android/surface_texture_peer_browser_impl.cc

Issue 11038015: Android: lazy initialization for method id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moves to MethodID Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/surface_texture_peer_browser_impl.h" 5 #include "content/browser/android/surface_texture_peer_browser_impl.h"
6 6
7 #include "content/browser/android/media_player_manager_android.h" 7 #include "content/browser/android/media_player_manager_android.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/common/android/surface_callback.h" 9 #include "content/common/android/surface_callback.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "jni/BrowserProcessSurfaceTexture_jni.h" 12 #include "jni/BrowserProcessSurfaceTexture_jni.h"
13 #include "media/base/android/media_player_bridge.h" 13 #include "media/base/android/media_player_bridge.h"
14 14
15 using base::android::MethodID;
16
15 namespace content { 17 namespace content {
16 18
17 // Pass a java surface object to the MediaPlayerBridge object 19 // Pass a java surface object to the MediaPlayerBridge object
18 // identified by render process handle, render view ID and player ID. 20 // identified by render process handle, render view ID and player ID.
19 static void SetSurfacePeer(jobject j_surface, 21 static void SetSurfacePeer(jobject j_surface,
20 base::ProcessHandle render_process_handle, 22 base::ProcessHandle render_process_handle,
21 int render_view_id, 23 int render_view_id,
22 int player_id) { 24 int player_id) {
23 int renderer_id = 0; 25 int renderer_id = 0;
24 RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); 26 RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 JNIEnv* env = base::android::AttachCurrentThread(); 72 JNIEnv* env = base::android::AttachCurrentThread();
71 DCHECK(env); 73 DCHECK(env);
72 if (player_in_render_process_) { 74 if (player_in_render_process_) {
73 Java_BrowserProcessSurfaceTexture_establishSurfaceTexturePeer( 75 Java_BrowserProcessSurfaceTexture_establishSurfaceTexturePeer(
74 env, render_process_handle, type, j_surface_texture, 76 env, render_process_handle, type, j_surface_texture,
75 render_view_id, player_id); 77 render_view_id, player_id);
76 } else { 78 } else {
77 base::android::ScopedJavaLocalRef<jclass> cls( 79 base::android::ScopedJavaLocalRef<jclass> cls(
78 base::android::GetClass(env, "android/view/Surface")); 80 base::android::GetClass(env, "android/view/Surface"));
79 jmethodID constructor = GetMethodID(env, cls, "<init>", 81 jmethodID constructor = MethodID::Get<
80 "(Landroid/graphics/SurfaceTexture;)V"); 82 MethodID::METHODTYPE_NORMAL, MethodID::EXCEPTIONCHECK_YES>(
83 env, cls.obj(), "<init>", "(Landroid/graphics/SurfaceTexture;)V");
81 ScopedJavaLocalRef<jobject> tmp(env, 84 ScopedJavaLocalRef<jobject> tmp(env,
82 env->NewObject(cls.obj(), constructor, j_surface_texture)); 85 env->NewObject(cls.obj(), constructor, j_surface_texture));
83 jobject surface = env->NewGlobalRef(tmp.obj()); 86 jobject surface = env->NewGlobalRef(tmp.obj());
84 87
85 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 88 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
86 &SetSurfacePeer, surface, render_process_handle, render_view_id, 89 &SetSurfacePeer, surface, render_process_handle, render_view_id,
87 player_id)); 90 player_id));
88 } 91 }
89 } 92 }
90 93
91 bool SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture( 94 bool SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture(
92 JNIEnv* env) { 95 JNIEnv* env) {
93 return RegisterNativesImpl(env); 96 return RegisterNativesImpl(env);
94 } 97 }
95 98
96 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698