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

Unified Diff: chrome/renderer/media/cast_session_delegate.cc

Issue 174403002: Cast: Don't create threads for each CastSessionDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SingleThreadTaskRunner Created 6 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 | « chrome/renderer/media/cast_session_delegate.h ('k') | chrome/renderer/media/cast_threads.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/media/cast_session_delegate.cc
diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc
index d5133b61cc0259899b38a5d422f96ca694b321a3..ed4c8b853df1c6a9d193375913686b3203cb0200 100644
--- a/chrome/renderer/media/cast_session_delegate.cc
+++ b/chrome/renderer/media/cast_session_delegate.cc
@@ -4,8 +4,10 @@
#include "chrome/renderer/media/cast_session_delegate.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "chrome/renderer/media/cast_threads.h"
#include "chrome/renderer/media/cast_transport_sender_ipc.h"
#include "content/public/renderer/p2p_socket_client.h"
#include "content/public/renderer/render_thread.h"
@@ -21,10 +23,11 @@ using media::cast::CastEnvironment;
using media::cast::CastSender;
using media::cast::VideoSenderConfig;
+static base::LazyInstance<CastThreads> g_cast_threads =
+ LAZY_INSTANCE_INITIALIZER;
+
CastSessionDelegate::CastSessionDelegate()
- : audio_encode_thread_("CastAudioEncodeThread"),
- video_encode_thread_("CastVideoEncodeThread"),
- transport_configured_(false),
+ : transport_configured_(false),
io_message_loop_proxy_(
content::RenderThread::Get()->GetIOMessageLoopProxy()) {
DCHECK(io_message_loop_proxy_);
@@ -38,9 +41,6 @@ void CastSessionDelegate::Initialize() {
if (cast_environment_)
return; // Already initialized.
- audio_encode_thread_.Start();
- video_encode_thread_.Start();
-
// CastSender uses the renderer's IO thread as the main thread. This reduces
// thread hopping for incoming video frames and outgoing network packets.
// There's no need to decode so no thread assigned for decoding.
@@ -48,9 +48,9 @@ void CastSessionDelegate::Initialize() {
cast_environment_ = new CastEnvironment(
scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(),
base::MessageLoopProxy::current(),
- audio_encode_thread_.message_loop_proxy(),
+ g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(),
NULL,
- video_encode_thread_.message_loop_proxy(),
+ g_cast_threads.Get().GetVideoEncodeMessageLoopProxy(),
NULL,
base::MessageLoopProxy::current(),
media::cast::GetDefaultCastSenderLoggingConfig());
« no previous file with comments | « chrome/renderer/media/cast_session_delegate.h ('k') | chrome/renderer/media/cast_threads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698