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

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: Rebased 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( 21 static void SetSurfacePeer(
20 scoped_refptr<SurfaceTextureBridge> surface_texture_bridge, 22 scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
21 base::ProcessHandle render_process_handle, 23 base::ProcessHandle render_process_handle,
22 int render_view_id, 24 int render_view_id,
23 int player_id) { 25 int player_id) {
24 int renderer_id = 0; 26 int renderer_id = 0;
(...skipping 11 matching lines...) Expand all
36 if (renderer_id) { 38 if (renderer_id) {
37 RenderViewHostImpl* host = RenderViewHostImpl::FromID( 39 RenderViewHostImpl* host = RenderViewHostImpl::FromID(
38 renderer_id, render_view_id); 40 renderer_id, render_view_id);
39 if (host) { 41 if (host) {
40 media::MediaPlayerBridge* player = 42 media::MediaPlayerBridge* player =
41 host->media_player_manager()->GetPlayer(player_id); 43 host->media_player_manager()->GetPlayer(player_id);
42 if (player && 44 if (player &&
43 player != host->media_player_manager()->GetFullscreenPlayer()) { 45 player != host->media_player_manager()->GetFullscreenPlayer()) {
44 base::android::ScopedJavaLocalRef<jclass> cls( 46 base::android::ScopedJavaLocalRef<jclass> cls(
45 base::android::GetClass(env, "android/view/Surface")); 47 base::android::GetClass(env, "android/view/Surface"));
46 jmethodID constructor = GetMethodID(env, cls, "<init>", 48 jmethodID constructor = MethodID::Get<MethodID::TYPE_INSTANCE>(
47 "(Landroid/graphics/SurfaceTexture;)V"); 49 env, cls.obj(), "<init>", "(Landroid/graphics/SurfaceTexture;)V");
48 ScopedJavaLocalRef<jobject> j_surface(env, 50 ScopedJavaLocalRef<jobject> j_surface(
49 env->NewObject(cls.obj(), constructor, 51 env, env->NewObject(
50 surface_texture_bridge->j_surface_texture().obj())); 52 cls.obj(), constructor,
53 surface_texture_bridge->j_surface_texture().obj()));
51 player->SetVideoSurface(j_surface.obj()); 54 player->SetVideoSurface(j_surface.obj());
52 ReleaseSurface(j_surface.obj()); 55 ReleaseSurface(j_surface.obj());
53 } 56 }
54 } 57 }
55 } 58 }
56 } 59 }
57 60
58 SurfaceTexturePeerBrowserImpl::SurfaceTexturePeerBrowserImpl( 61 SurfaceTexturePeerBrowserImpl::SurfaceTexturePeerBrowserImpl(
59 bool player_in_render_process) 62 bool player_in_render_process)
60 : player_in_render_process_(player_in_render_process) { 63 : player_in_render_process_(player_in_render_process) {
(...skipping 26 matching lines...) Expand all
87 render_view_id, player_id)); 90 render_view_id, 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