summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-30 06:40:16 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-30 06:40:16 +0000
commit9d2cd33e9d1be6b1ff0a31f2b6a15e605c39ba3b (patch)
treebbab82f86944ec7ce856682f83a3bb849a8011ec
parent40076a26f49d0494b2231fec5ec2ebb736fc9039 (diff)
downloadchromium_src-9d2cd33e9d1be6b1ff0a31f2b6a15e605c39ba3b.zip
chromium_src-9d2cd33e9d1be6b1ff0a31f2b6a15e605c39ba3b.tar.gz
chromium_src-9d2cd33e9d1be6b1ff0a31f2b6a15e605c39ba3b.tar.bz2
Migrate media::MediaPlayerManager::Create() to content::BrowserMediaPlayerManager.
This fixes a layering violation where content::RenderViewHost was forward declared in media code. It also lets content code use BrowserMediaPlayerManager directly without resorting to casting. BUG=263652 Review URL: https://chromiumcodereview.appspot.com/23735002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220520 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/android/browser_media_player_manager.cc23
-rw-r--r--content/browser/android/browser_media_player_manager.h13
-rw-r--r--content/browser/android/child_process_launcher_android.cc2
-rw-r--r--content/browser/android/content_view_core_impl.cc16
-rw-r--r--content/browser/android/surface_texture_peer_browser_impl.cc2
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc4
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h11
-rw-r--r--content/browser/web_contents/web_contents_view_android.cc2
-rw-r--r--media/base/android/media_player_manager.h21
9 files changed, 29 insertions, 65 deletions
diff --git a/content/browser/android/browser_media_player_manager.cc b/content/browser/android/browser_media_player_manager.cc
index cd4f764..31457f0 100644
--- a/content/browser/android/browser_media_player_manager.cc
+++ b/content/browser/android/browser_media_player_manager.cc
@@ -22,28 +22,23 @@ using media::MediaPlayerAndroid;
// attempting to release inactive media players.
static const int kMediaPlayerThreshold = 1;
-namespace media {
+namespace content {
-static MediaPlayerManager::FactoryFunction g_factory_function = NULL;
+static BrowserMediaPlayerManager::Factory g_factory = NULL;
// static
-CONTENT_EXPORT void MediaPlayerManager::RegisterFactoryFunction(
- FactoryFunction factory_function) {
- g_factory_function = factory_function;
+void BrowserMediaPlayerManager::RegisterFactory(Factory factory) {
+ g_factory = factory;
}
// static
-media::MediaPlayerManager* MediaPlayerManager::Create(
- content::RenderViewHost* render_view_host) {
- if (g_factory_function)
- return g_factory_function(render_view_host);
- return new content::BrowserMediaPlayerManager(render_view_host);
+BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create(
+ RenderViewHost* rvh) {
+ if (g_factory)
+ return g_factory(rvh);
+ return new BrowserMediaPlayerManager(rvh);
}
-} // namespace media
-
-namespace content {
-
BrowserMediaPlayerManager::BrowserMediaPlayerManager(
RenderViewHost* render_view_host)
: RenderViewHostObserver(render_view_host),
diff --git a/content/browser/android/browser_media_player_manager.h b/content/browser/android/browser_media_player_manager.h
index 2685806..e7c227a 100644
--- a/content/browser/android/browser_media_player_manager.h
+++ b/content/browser/android/browser_media_player_manager.h
@@ -39,6 +39,13 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
: public RenderViewHostObserver,
public media::MediaPlayerManager {
public:
+ // Permits embedders to provide an extended version of the class.
+ typedef BrowserMediaPlayerManager* (*Factory)(RenderViewHost*);
+ static void RegisterFactory(Factory factory);
+
+ // Returns a new instance using the registered factory if available.
+ static BrowserMediaPlayerManager* Create(RenderViewHost* rvh);
+
virtual ~BrowserMediaPlayerManager();
// RenderViewHostObserver overrides.
@@ -98,11 +105,7 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
#endif
protected:
- friend MediaPlayerManager* MediaPlayerManager::Create(
- content::RenderViewHost*);
-
- // The instance of this class is supposed to be created by either Create()
- // method of MediaPlayerManager or the derived classes constructors.
+ // Clients must use Create() or subclass constructor.
explicit BrowserMediaPlayerManager(RenderViewHost* render_view_host);
// Message handlers.
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index d73e299..ad1a018 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -8,6 +8,7 @@
#include "base/android/jni_array.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "content/browser/android/browser_media_player_manager.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"
@@ -15,7 +16,6 @@
#include "content/public/common/content_switches.h"
#include "jni/ChildProcessLauncher_jni.h"
#include "media/base/android/media_player_android.h"
-#include "media/base/android/media_player_manager.h"
#include "ui/gl/android/scoped_java_surface.h"
using base::android::AttachCurrentThread;
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 41f0b94..24c3cbf 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -1301,12 +1301,8 @@ void ContentViewCoreImpl::AttachExternalVideoSurface(JNIEnv* env,
#if defined(GOOGLE_TV)
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
web_contents_->GetRenderViewHost());
- BrowserMediaPlayerManager* browser_media_player_manager =
- rvhi ? static_cast<BrowserMediaPlayerManager*>(
- rvhi->media_player_manager())
- : NULL;
- if (browser_media_player_manager) {
- browser_media_player_manager->AttachExternalVideoSurface(
+ if (rvhi && rvhi->media_player_manager()) {
+ rvhi->media_player_manager()->AttachExternalVideoSurface(
static_cast<int>(player_id), jsurface);
}
#endif
@@ -1318,12 +1314,8 @@ void ContentViewCoreImpl::DetachExternalVideoSurface(JNIEnv* env,
#if defined(GOOGLE_TV)
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
web_contents_->GetRenderViewHost());
- BrowserMediaPlayerManager* browser_media_player_manager =
- rvhi ? static_cast<BrowserMediaPlayerManager*>(
- rvhi->media_player_manager())
- : NULL;
- if (browser_media_player_manager) {
- browser_media_player_manager->DetachExternalVideoSurface(
+ if (rvhi && rvhi->media_player_manager()) {
+ rvhi->media_player_manager()->DetachExternalVideoSurface(
static_cast<int>(player_id));
}
#endif
diff --git a/content/browser/android/surface_texture_peer_browser_impl.cc b/content/browser/android/surface_texture_peer_browser_impl.cc
index de110db..622c2d0 100644
--- a/content/browser/android/surface_texture_peer_browser_impl.cc
+++ b/content/browser/android/surface_texture_peer_browser_impl.cc
@@ -4,11 +4,11 @@
#include "content/browser/android/surface_texture_peer_browser_impl.h"
+#include "content/browser/android/browser_media_player_manager.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"
#include "media/base/android/media_player_android.h"
-#include "media/base/android/media_player_manager.h"
#include "ui/gl/android/scoped_java_surface.h"
namespace content {
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index d2be3e3..de33517 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -72,7 +72,7 @@
#if defined(OS_MACOSX)
#include "content/browser/renderer_host/popup_menu_helper_mac.h"
#elif defined(OS_ANDROID)
-#include "media/base/android/media_player_manager.h"
+#include "content/browser/android/browser_media_player_manager.h"
#endif
using base::TimeDelta;
@@ -194,7 +194,7 @@ RenderViewHostImpl::RenderViewHostImpl(
instance_->increment_active_view_count();
#if defined(OS_ANDROID)
- media_player_manager_ = media::MediaPlayerManager::Create(this);
+ media_player_manager_ = BrowserMediaPlayerManager::Create(this);
#endif
}
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index 649d83a..880a339 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -53,14 +53,9 @@ class Range;
struct SelectedFileInfo;
}
-#if defined(OS_ANDROID)
-namespace media {
-class MediaPlayerManager;
-}
-#endif
-
namespace content {
+class BrowserMediaPlayerManager;
class ChildProcessSecurityPolicyImpl;
class PageState;
class RenderFrameHostImpl;
@@ -391,7 +386,7 @@ class CONTENT_EXPORT RenderViewHostImpl
#endif
#if defined(OS_ANDROID)
- media::MediaPlayerManager* media_player_manager() {
+ BrowserMediaPlayerManager* media_player_manager() {
return media_player_manager_;
}
@@ -709,7 +704,7 @@ class CONTENT_EXPORT RenderViewHostImpl
#if defined(OS_ANDROID)
// Manages all the android mediaplayer objects and handling IPCs for video.
// This class inherits from RenderViewHostObserver.
- media::MediaPlayerManager* media_player_manager_;
+ BrowserMediaPlayerManager* media_player_manager_;
#endif
DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl);
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index 1f7b247..ebdfd47 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -5,6 +5,7 @@
#include "content/browser/web_contents/web_contents_view_android.h"
#include "base/logging.h"
+#include "content/browser/android/browser_media_player_manager.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
@@ -12,7 +13,6 @@
#include "content/browser/web_contents/interstitial_page_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents_delegate.h"
-#include "media/base/android/media_player_manager.h"
namespace content {
WebContentsViewPort* CreateWebContentsView(
diff --git a/media/base/android/media_player_manager.h b/media/base/android/media_player_manager.h
index a0f5017..46ea8ca 100644
--- a/media/base/android/media_player_manager.h
+++ b/media/base/android/media_player_manager.h
@@ -14,10 +14,6 @@
#include "media/base/media_export.h"
#include "media/base/media_keys.h"
-namespace content {
-class RenderViewHost;
-}
-
namespace media {
class MediaDrmBridge;
@@ -25,25 +21,8 @@ class MediaPlayerAndroid;
class MediaResourceGetter;
// This class is responsible for managing active MediaPlayerAndroid objects.
-// Objects implementing this interface a created via
-// MediaPlayerManager::Create(), allowing embedders to provide their
-// implementation.
class MEDIA_EXPORT MediaPlayerManager {
public:
- // The type of the factory function that returns a new instance of the
- // MediaPlayerManager implementation.
- typedef MediaPlayerManager* (*FactoryFunction)(content::RenderViewHost*);
-
- // Allows to override the default factory function in order to provide
- // a custom implementation to the RenderViewHost instance.
- // Must be called from the main thread.
- static void RegisterFactoryFunction(FactoryFunction factory_function);
-
- // Returns a new instance of MediaPlayerManager interface implementation.
- // The returned object is owned by the caller. Must be called on the main
- // thread.
- static MediaPlayerManager* Create(content::RenderViewHost* render_view_host);
-
virtual ~MediaPlayerManager() {}
// Called by a MediaPlayerAndroid object when it is going to decode