Index: media/cast/cast_environment.h |
diff --git a/media/cast/cast_environment.h b/media/cast/cast_environment.h |
index 5abb5c7376f33dec4393175d9e4f590b1b1ed359..38d5564fc5f72fadcd2eca38bca873877906af96 100644 |
--- a/media/cast/cast_environment.h |
+++ b/media/cast/cast_environment.h |
@@ -9,11 +9,16 @@ |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/single_thread_task_runner.h" |
+#include "base/synchronization/lock.h" |
#include "base/time/tick_clock.h" |
#include "base/time/time.h" |
#include "media/cast/logging/logging_defines.h" |
#include "media/cast/logging/logging_impl.h" |
+namespace base { |
+class Thread; |
+} |
+ |
namespace media { |
namespace cast { |
@@ -38,6 +43,15 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { |
TRANSPORT, |
}; |
+ // Use these constructors to create a standalone CastEnvironment. They use |
+ // base::DefaultTickClock, and all task runners are created on-demand. |
+ CastEnvironment(); // No logging. |
hubbe
2014/03/04 22:42:26
This is only used for testing.
Seems better to kee
miu
2014/03/06 06:09:15
Done.
|
+ explicit CastEnvironment(const CastLoggingConfig& logging_config); |
+ |
+ // Use this constructor to create a CastEnvironment that integrates with an |
+ // existing environment, such as content::BrowserThread, or a test/simulation |
+ // framework. It is valid for any of the proxy args to be NULL for any task |
+ // runners that will not be used. |
CastEnvironment( |
scoped_ptr<base::TickClock> clock, |
scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, |
@@ -46,7 +60,7 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { |
scoped_refptr<base::SingleThreadTaskRunner> video_encode_thread_proxy, |
scoped_refptr<base::SingleThreadTaskRunner> video_decode_thread_proxy, |
scoped_refptr<base::SingleThreadTaskRunner> transport_thread_proxy, |
- const CastLoggingConfig& config); |
+ const CastLoggingConfig& logging_config); |
// These are the same methods in message_loop.h, but are guaranteed to either |
// get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
@@ -64,10 +78,12 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { |
bool CurrentlyOn(ThreadId identifier); |
- base::TickClock* Clock() const; |
+ // All of the media::cast implementation must use this TickClock. |
+ base::TickClock* Clock() const { return clock_.get(); } |
- // Logging is not thread safe. Should always be called from the main thread. |
- LoggingImpl* Logging(); |
+ // Logging is not thread safe. Its methods should always be called from the |
+ // main thread. |
+ LoggingImpl* Logging() const { return logging_.get(); } |
scoped_refptr<base::SingleThreadTaskRunner> |
GetMessageSingleThreadTaskRunnerForThread(ThreadId identifier); |
@@ -96,6 +112,16 @@ class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { |
scoped_ptr<LoggingImpl> logging_; |
+ // Auto-created threads for missing task runners, with the one-time creation |
+ // action protected by a lock. |
+ base::Lock create_lock_; |
+ scoped_ptr<base::Thread> main_thread_; |
+ scoped_ptr<base::Thread> audio_encode_thread_; |
+ scoped_ptr<base::Thread> audio_decode_thread_; |
+ scoped_ptr<base::Thread> video_encode_thread_; |
+ scoped_ptr<base::Thread> video_decode_thread_; |
+ scoped_ptr<base::Thread> transport_thread_; |
+ |
DISALLOW_COPY_AND_ASSIGN(CastEnvironment); |
}; |