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

Unified Diff: content/browser/android/surface_texture_peer_browser_impl.cc

Issue 12388038: Android: Remove Surface cruft (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/surface_texture_peer_browser_impl.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/surface_texture_peer_browser_impl.cc
diff --git a/content/browser/android/surface_texture_peer_browser_impl.cc b/content/browser/android/surface_texture_peer_browser_impl.cc
index 70dcf1a7ba83d71115b92719e488cd6d6d6c9d25..afd999bd0eceb1b2274d9cef1fab3466a58b881a 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.cc
+++ b/content/browser/android/surface_texture_peer_browser_impl.cc
@@ -6,16 +6,15 @@
#include "content/browser/android/media_player_manager_android.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/common/android/surface_callback.h"
+#include "content/common/android/scoped_java_surface.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
-#include "jni/BrowserProcessSurfaceTexture_jni.h"
#include "media/base/android/media_player_bridge.h"
-using base::android::MethodID;
-
namespace content {
+namespace {
+
// Pass a java surface object to the MediaPlayerBridge object
// identified by render process handle, render view ID and player ID.
static void SetSurfacePeer(
@@ -33,8 +32,6 @@ static void SetSurfacePeer(
it.Advance();
}
- JNIEnv* env = base::android::AttachCurrentThread();
- DCHECK(env);
if (renderer_id) {
RenderViewHostImpl* host = RenderViewHostImpl::FromID(
renderer_id, render_view_id);
@@ -43,57 +40,32 @@ static void SetSurfacePeer(
host->media_player_manager()->GetPlayer(player_id);
if (player &&
player != host->media_player_manager()->GetFullscreenPlayer()) {
- base::android::ScopedJavaLocalRef<jclass> cls(
- base::android::GetClass(env, "android/view/Surface"));
- jmethodID constructor = MethodID::Get<MethodID::TYPE_INSTANCE>(
- env, cls.obj(), "<init>", "(Landroid/graphics/SurfaceTexture;)V");
- ScopedJavaLocalRef<jobject> j_surface(
- env, env->NewObject(
- cls.obj(), constructor,
- surface_texture_bridge->j_surface_texture().obj()));
- player->SetVideoSurface(j_surface.obj());
- ReleaseSurface(j_surface.obj());
+ ScopedJavaSurface surface(surface_texture_bridge.get());
+ player->SetVideoSurface(surface.j_surface().obj());
}
}
}
}
-SurfaceTexturePeerBrowserImpl::SurfaceTexturePeerBrowserImpl(
- bool player_in_render_process)
- : player_in_render_process_(player_in_render_process) {
+} // anonymous namespace
+
+SurfaceTexturePeerBrowserImpl::SurfaceTexturePeerBrowserImpl() {
}
SurfaceTexturePeerBrowserImpl::~SurfaceTexturePeerBrowserImpl() {
- if (surface_.obj())
- ReleaseSurface(surface_.obj());
}
void SurfaceTexturePeerBrowserImpl::EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
- SurfaceTextureTarget type,
scoped_refptr<SurfaceTextureBridge> surface_texture_bridge,
int render_view_id,
int player_id) {
if (!surface_texture_bridge)
return;
- JNIEnv* env = base::android::AttachCurrentThread();
- DCHECK(env);
- if (player_in_render_process_) {
- Java_BrowserProcessSurfaceTexture_establishSurfaceTexturePeer(
- env, render_process_handle, type,
- surface_texture_bridge->j_surface_texture().obj(),
- render_view_id, player_id);
- } else {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
- &SetSurfacePeer, surface_texture_bridge, render_process_handle,
- render_view_id, player_id));
- }
-}
-
-bool SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture(
- JNIEnv* env) {
- return RegisterNativesImpl(env);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
+ &SetSurfacePeer, surface_texture_bridge, render_process_handle,
+ render_view_id, player_id));
}
} // namespace content
« no previous file with comments | « content/browser/android/surface_texture_peer_browser_impl.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698