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

Unified Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 1867873002: Move unittests in content/common/gpu/client to gpu/ipc/client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 8 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/media/android/browser_media_player_manager.cc
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc
index 96f6fcde97cd78e4beb6f7260d4c0b1c1f28d0c2..684020f456459f0749c3467f2e89415bb2bee7ce 100644
--- a/content/browser/media/android/browser_media_player_manager.cc
+++ b/content/browser/media/android/browser_media_player_manager.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/android/scoped_java_ref.h"
+#include "base/memory/singleton.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/media/android/browser_demuxer_android.h"
#include "content/browser/media/android/media_resource_getter_impl.h"
@@ -27,6 +28,7 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
+#include "gpu/ipc/common/android/surface_texture_peer.h"
#include "media/base/android/media_codec_player.h"
#include "media/base/android/media_player_bridge.h"
#include "media/base/android/media_source_player.h"
@@ -46,6 +48,57 @@ using media::MediaSourcePlayer;
namespace content {
+namespace {
+
+class BrowserSurfaceTexturePeer : public gpu::SurfaceTexturePeer {
+ public:
+ static BrowserSurfaceTexturePeer* GetInstance();
+
+ private:
+ friend struct base::DefaultSingletonTraits<BrowserSurfaceTexturePeer>;
+
+ BrowserSurfaceTexturePeer();
+ ~BrowserSurfaceTexturePeer() override;
+
+ void EstablishSurfaceTexturePeer(
+ base::ProcessHandle render_process_handle,
+ scoped_refptr<gfx::SurfaceTexture> surface_texture,
+ int render_frame_id,
+ int player_id) override;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserSurfaceTexturePeer);
+};
+
+// static
+BrowserSurfaceTexturePeer* BrowserSurfaceTexturePeer::GetInstance() {
+ return base::Singleton<
+ BrowserSurfaceTexturePeer,
+ base::LeakySingletonTraits<BrowserSurfaceTexturePeer>>::get();
+}
+
+BrowserSurfaceTexturePeer::BrowserSurfaceTexturePeer() {
+ gpu::SurfaceTexturePeer::InitInstance(this);
+}
+
+BrowserSurfaceTexturePeer::~BrowserSurfaceTexturePeer() {
+ gpu::SurfaceTexturePeer::InitInstance(nullptr);
+}
+
+void BrowserSurfaceTexturePeer::EstablishSurfaceTexturePeer(
+ base::ProcessHandle render_process_handle,
+ scoped_refptr<gfx::SurfaceTexture> surface_texture,
+ int render_frame_id,
+ int player_id) {
+ if (!surface_texture.get())
+ return;
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&BrowserMediaPlayerManager::SetSurfacePeer, surface_texture,
+ render_process_handle, render_frame_id, player_id));
+}
+
+} // namespace
+
// Threshold on the number of media players per renderer before we start
// attempting to release inactive media players.
const int kMediaPlayerThreshold = 1;
@@ -71,6 +124,11 @@ void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor(
}
// static
+void BrowserMediaPlayerManager::InitSurfaceTexturePeer() {
+ BrowserSurfaceTexturePeer::GetInstance();
+}
+
+// static
void BrowserMediaPlayerManager::SetSurfacePeer(
scoped_refptr<gfx::SurfaceTexture> surface_texture,
base::ProcessHandle render_process_handle,
« no previous file with comments | « content/browser/media/android/browser_media_player_manager.h ('k') | content/common/gpu/client/gpu_context_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698