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

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

Issue 278353003: Make RendererMediaPlayerManager a RenderFrameObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: content/browser/android/child_process_launcher_android.cc
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index 8c940da89e537cb4851bae9b8d119b5dcba3566e..edb24ee32b67947882801bce962d424c26f75163 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.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"
@@ -45,18 +46,44 @@ static void SetSurfacePeer(
it.Advance();
}
- 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());
- }
- }
+ if (!renderer_id) {
+ DVLOG(1) << "Cannot find renderer for " << render_process_handle;
+ return;
+ }
+
+ RenderViewHostImpl* host =
+ RenderViewHostImpl::FromID(renderer_id, render_view_id);
+
+ if (!host) {
+ DVLOG(1) << "Cannot find host for render_view" << render_view_id;
+ return;
+ }
+
+ // TODO(xhwang): This assumes all media elements are in the main frame which
+ // is not true. Update the SetSurfacePeer() stack to use |render_frame_id|
+ // instead of |render_view_id|.
xhwang 2014/05/12 17:01:58 qinmin: let me know if this TODO makes sense ;)
jam 2014/05/20 00:34:49 hmm, this is going to be broken in the meantime. w
xhwang 2014/05/22 19:06:00 Done.
+ RenderFrameHost* frame = host->GetMainFrame();
+ if (!frame) {
+ DVLOG(1) << "Cannot find the main frame.";
+ return;
+ }
+
+ BrowserMediaPlayerManager* player_manager =
+ host->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 the media player player_id " << player_id;
+ return;
+ }
+
+ if (player != player_manager->GetFullscreenPlayer()) {
+ gfx::ScopedJavaSurface scoped_surface(surface);
+ player->SetVideoSurface(scoped_surface.Pass());
}
}

Powered by Google App Engine
This is Rietveld 408576698