summaryrefslogtreecommitdiffstats
path: root/content/browser/android
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 21:17:17 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 21:17:17 +0000
commita017938bc9a573c30a26df17252ed95ad4b151c1 (patch)
treef64b3f00ad96a6145c003f2d74243dc6abb71594 /content/browser/android
parent3d990b7aab7a23019bd4f03f91a33f9fb0ff741f (diff)
downloadchromium_src-a017938bc9a573c30a26df17252ed95ad4b151c1.zip
chromium_src-a017938bc9a573c30a26df17252ed95ad4b151c1.tar.gz
chromium_src-a017938bc9a573c30a26df17252ed95ad4b151c1.tar.bz2
Make RendererMediaPlayerManager a RenderFrameObserver.
Major change: - Make BrowserMediaPlayerManager (BMPM) a per RenderFrame object. - Introduce MediaWebContentsObserver (MWCO) which managers all BMPMs. - MWCO forwards all IPCs to BMPM. Other changes necessary to switch from RenderView to RenderFrame: - Use MediaWebContentsObserver to send PauseVideo message to render. - Use render frame routing ID to set surface peer. VIDEO_HOLE related changes: - Add DidCommitCompositorFrame() to RenderFrameObserver. - Add OnFrameInfoUpdated() to MediaWebContentsObserver. BUG=338910 TEST=Tested with test pages and Youtube purchased movies. Review URL: https://codereview.chromium.org/278353003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/android')
-rw-r--r--content/browser/android/child_process_launcher_android.cc52
-rw-r--r--content/browser/android/content_view_core_impl.cc9
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.cc4
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.cc56
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.h2
5 files changed, 82 insertions, 41 deletions
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index 8c940da..06fa0cb 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -8,7 +8,9 @@
#include "base/android/jni_array.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/media/android/browser_media_player_manager.h"
+#include "content/browser/media/android/media_web_contents_observer.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/browser_thread.h"
@@ -29,34 +31,52 @@ namespace content {
namespace {
// Pass a java surface object to the MediaPlayerAndroid object
-// identified by render process handle, render view ID and player ID.
+// identified by render process handle, render frame ID and player ID.
static void SetSurfacePeer(
const base::android::JavaRef<jobject>& surface,
base::ProcessHandle render_process_handle,
- int render_view_id,
+ int render_frame_id,
int player_id) {
- int renderer_id = 0;
+ int render_process_id = 0;
RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
while (!it.IsAtEnd()) {
if (it.GetCurrentValue()->GetHandle() == render_process_handle) {
- renderer_id = it.GetCurrentValue()->GetID();
+ render_process_id = it.GetCurrentValue()->GetID();
break;
}
it.Advance();
}
+ if (!render_process_id) {
+ DVLOG(1) << "Cannot find render process for render_process_handle "
+ << render_process_handle;
+ return;
+ }
- if (renderer_id) {
- RenderViewHostImpl* host = RenderViewHostImpl::FromID(
- renderer_id, render_view_id);
- if (host) {
- media::MediaPlayerAndroid* player =
- host->media_player_manager()->GetPlayer(player_id);
- if (player &&
- player != host->media_player_manager()->GetFullscreenPlayer()) {
- gfx::ScopedJavaSurface scoped_surface(surface);
- player->SetVideoSurface(scoped_surface.Pass());
- }
- }
+ RenderFrameHostImpl* frame =
+ RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
+ if (!frame) {
+ DVLOG(1) << "Cannot find frame for render_frame_id " << render_frame_id;
+ return;
+ }
+
+ RenderViewHostImpl* view =
+ static_cast<RenderViewHostImpl*>(frame->GetRenderViewHost());
+ BrowserMediaPlayerManager* player_manager =
+ view->media_web_contents_observer()->GetMediaPlayerManager(frame);
+ if (!player_manager) {
+ DVLOG(1) << "Cannot find the media player manager for frame " << frame;
+ return;
+ }
+
+ media::MediaPlayerAndroid* player = player_manager->GetPlayer(player_id);
+ if (!player) {
+ DVLOG(1) << "Cannot find media player for player_id " << player_id;
+ return;
+ }
+
+ if (player != player_manager->GetFullscreenPlayer()) {
+ gfx::ScopedJavaSurface scoped_surface(surface);
+ player->SetVideoSurface(scoped_surface.Pass());
}
}
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 2ef62be..66d83b2 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -24,7 +24,7 @@
#include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
#include "content/browser/geolocation/geolocation_dispatcher_host.h"
-#include "content/browser/media/android/browser_media_player_manager.h"
+#include "content/browser/media/android/media_web_contents_observer.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/input/motion_event_android.h"
#include "content/browser/renderer_host/input/web_input_event_builders_android.h"
@@ -365,9 +365,10 @@ void ContentViewCoreImpl::Hide() {
}
void ContentViewCoreImpl::PauseVideo() {
- RenderViewHost* host = web_contents_->GetRenderViewHost();
- if (host)
- host->Send(new ViewMsg_PauseVideo(host->GetRoutingID()));
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
+ web_contents_->GetRenderViewHost());
+ if (rvhi)
+ rvhi->media_web_contents_observer()->PauseVideo();
}
void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
index 6792951..c4fdb62 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -194,13 +194,13 @@ gpu::GLInProcessContext* SynchronousCompositorFactoryImpl::GetShareContext() {
}
scoped_refptr<StreamTextureFactory>
-SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int view_id) {
+SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
scoped_refptr<StreamTextureFactorySynchronousImpl> factory(
StreamTextureFactorySynchronousImpl::Create(
base::Bind(
&SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory,
base::Unretained(this)),
- view_id));
+ frame_id));
return factory;
}
diff --git a/content/browser/android/surface_texture_peer_browser_impl.cc b/content/browser/android/surface_texture_peer_browser_impl.cc
index 7935c9a..99e2c08 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.cc
+++ b/content/browser/android/surface_texture_peer_browser_impl.cc
@@ -4,7 +4,9 @@
#include "content/browser/android/surface_texture_peer_browser_impl.h"
+#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/media/android/browser_media_player_manager.h"
+#include "content/browser/media/android/media_web_contents_observer.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
@@ -16,34 +18,52 @@ namespace content {
namespace {
// Pass a java surface object to the MediaPlayerAndroid object
-// identified by render process handle, render view ID and player ID.
+// identified by render process handle, render frame ID and player ID.
static void SetSurfacePeer(
scoped_refptr<gfx::SurfaceTexture> surface_texture,
base::ProcessHandle render_process_handle,
- int render_view_id,
+ int render_frame_id,
int player_id) {
- int renderer_id = 0;
+ int render_process_id = 0;
RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
while (!it.IsAtEnd()) {
if (it.GetCurrentValue()->GetHandle() == render_process_handle) {
- renderer_id = it.GetCurrentValue()->GetID();
+ render_process_id = it.GetCurrentValue()->GetID();
break;
}
it.Advance();
}
+ if (!render_process_id) {
+ DVLOG(1) << "Cannot find render process for render_process_handle "
+ << render_process_handle;
+ return;
+ }
- if (renderer_id) {
- RenderViewHostImpl* host = RenderViewHostImpl::FromID(
- renderer_id, render_view_id);
- if (host) {
- media::MediaPlayerAndroid* player =
- host->media_player_manager()->GetPlayer(player_id);
- if (player &&
- player != host->media_player_manager()->GetFullscreenPlayer()) {
- gfx::ScopedJavaSurface surface(surface_texture.get());
- player->SetVideoSurface(surface.Pass());
- }
- }
+ RenderFrameHostImpl* frame =
+ RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
+ if (!frame) {
+ DVLOG(1) << "Cannot find frame for render_frame_id " << render_frame_id;
+ return;
+ }
+
+ RenderViewHostImpl* view =
+ static_cast<RenderViewHostImpl*>(frame->GetRenderViewHost());
+ BrowserMediaPlayerManager* player_manager =
+ view->media_web_contents_observer()->GetMediaPlayerManager(frame);
+ if (!player_manager) {
+ DVLOG(1) << "Cannot find the media player manager for frame " << frame;
+ return;
+ }
+
+ media::MediaPlayerAndroid* player = player_manager->GetPlayer(player_id);
+ if (!player) {
+ DVLOG(1) << "Cannot find media player for player_id " << player_id;
+ return;
+ }
+
+ if (player != player_manager->GetFullscreenPlayer()) {
+ gfx::ScopedJavaSurface scoped_surface(surface_texture);
+ player->SetVideoSurface(scoped_surface.Pass());
}
}
@@ -58,14 +78,14 @@ SurfaceTexturePeerBrowserImpl::~SurfaceTexturePeerBrowserImpl() {
void SurfaceTexturePeerBrowserImpl::EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
scoped_refptr<gfx::SurfaceTexture> surface_texture,
- int render_view_id,
+ int render_frame_id,
int player_id) {
if (!surface_texture.get())
return;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&SetSurfacePeer, surface_texture, render_process_handle,
- render_view_id, player_id));
+ render_frame_id, player_id));
}
} // namespace content
diff --git a/content/browser/android/surface_texture_peer_browser_impl.h b/content/browser/android/surface_texture_peer_browser_impl.h
index 4aa8563..ea3fd04 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.h
+++ b/content/browser/android/surface_texture_peer_browser_impl.h
@@ -25,7 +25,7 @@ class SurfaceTexturePeerBrowserImpl : public SurfaceTexturePeer {
virtual void EstablishSurfaceTexturePeer(
base::ProcessHandle render_process_handle,
scoped_refptr<gfx::SurfaceTexture> surface_texture,
- int render_view_id,
+ int render_frame_id,
int player_id) OVERRIDE;
private: