summaryrefslogtreecommitdiffstats
path: root/media/cast/cast_environment.cc
diff options
context:
space:
mode:
authormiu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-09 01:41:55 +0000
committermiu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-09 01:41:55 +0000
commite81fe1a173230947493bdfd885c8e518a343a90f (patch)
treee6f0d9dad174fbe82f1e0d7b55022a159939c721 /media/cast/cast_environment.cc
parent963a91b1fda682b844b9ece88d2070862f51893f (diff)
downloadchromium_src-e81fe1a173230947493bdfd885c8e518a343a90f.zip
chromium_src-e81fe1a173230947493bdfd885c8e518a343a90f.tar.gz
chromium_src-e81fe1a173230947493bdfd885c8e518a343a90f.tar.bz2
Cast Streaming API end-to-end browser_test.
Similar to the TabCaptureApi.EndToEnd test: An extension is run that generates a rotating cycle of colors and audio tones, and the result is captured and streamed to an in-process Cast receiver. In addition: 1. Refactored existing code out of the cast_receiver_app into a shared InProcessReceiver class. 2. Added a convenient StandaloneCastEnvironment for test apps. 3. Got rid of the cast_receiver_app prompts since the defaults are used >99% of the time. Using the --enable-prompts command line arg will show them again. 4. Minor clean-ups in files touched. NOTE: The new EndToEnd test is being submitted as disabled while outstanding bugs are worked by the team. Will re-enable once the implementation is sufficiently stable for the bots. R=hubbe@chromium.org, kalman@chromium.org Review URL: https://codereview.chromium.org/184813009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255805 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/cast_environment.cc')
-rw-r--r--media/cast/cast_environment.cc55
1 files changed, 21 insertions, 34 deletions
diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc
index 9b1a569..9077b52 100644
--- a/media/cast/cast_environment.cc
+++ b/media/cast/cast_environment.cc
@@ -29,23 +29,19 @@ CastEnvironment::CastEnvironment(
scoped_refptr<SingleThreadTaskRunner> video_encode_thread_proxy,
scoped_refptr<SingleThreadTaskRunner> video_decode_thread_proxy,
scoped_refptr<SingleThreadTaskRunner> transport_thread_proxy,
- const CastLoggingConfig& config)
- : clock_(clock.Pass()),
- main_thread_proxy_(main_thread_proxy),
+ const CastLoggingConfig& logging_config)
+ : main_thread_proxy_(main_thread_proxy),
audio_encode_thread_proxy_(audio_encode_thread_proxy),
audio_decode_thread_proxy_(audio_decode_thread_proxy),
video_encode_thread_proxy_(video_encode_thread_proxy),
video_decode_thread_proxy_(video_decode_thread_proxy),
transport_thread_proxy_(transport_thread_proxy),
- logging_(new LoggingImpl(main_thread_proxy, config)) {
- DCHECK(main_thread_proxy);
-}
+ clock_(clock.Pass()),
+ logging_(new LoggingImpl(logging_config)) {}
CastEnvironment::~CastEnvironment() {
// Logging must be deleted on the main thread.
- if (main_thread_proxy_->RunsTasksOnCurrentThread()) {
- logging_.reset();
- } else {
+ if (main_thread_proxy_ && !main_thread_proxy_->RunsTasksOnCurrentThread()) {
main_thread_proxy_->PostTask(
FROM_HERE,
base::Bind(&DeleteLoggingOnMainThread, base::Passed(&logging_)));
@@ -55,10 +51,7 @@ CastEnvironment::~CastEnvironment() {
bool CastEnvironment::PostTask(ThreadId identifier,
const tracked_objects::Location& from_here,
const base::Closure& task) {
- scoped_refptr<SingleThreadTaskRunner> task_runner =
- GetMessageSingleThreadTaskRunnerForThread(identifier);
-
- return task_runner->PostTask(from_here, task);
+ return GetTaskRunner(identifier)->PostTask(from_here, task);
}
bool CastEnvironment::PostDelayedTask(
@@ -66,15 +59,11 @@ bool CastEnvironment::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
- scoped_refptr<SingleThreadTaskRunner> task_runner =
- GetMessageSingleThreadTaskRunnerForThread(identifier);
-
- return task_runner->PostDelayedTask(from_here, task, delay);
+ return GetTaskRunner(identifier)->PostDelayedTask(from_here, task, delay);
}
-scoped_refptr<SingleThreadTaskRunner>
-CastEnvironment::GetMessageSingleThreadTaskRunnerForThread(
- ThreadId identifier) {
+scoped_refptr<SingleThreadTaskRunner> CastEnvironment::GetTaskRunner(
+ ThreadId identifier) const {
switch (identifier) {
case CastEnvironment::MAIN:
return main_thread_proxy_;
@@ -97,30 +86,28 @@ CastEnvironment::GetMessageSingleThreadTaskRunnerForThread(
bool CastEnvironment::CurrentlyOn(ThreadId identifier) {
switch (identifier) {
case CastEnvironment::MAIN:
- return main_thread_proxy_->RunsTasksOnCurrentThread();
+ return main_thread_proxy_ &&
+ main_thread_proxy_->RunsTasksOnCurrentThread();
case CastEnvironment::AUDIO_ENCODER:
- return audio_encode_thread_proxy_->RunsTasksOnCurrentThread();
+ return audio_encode_thread_proxy_ &&
+ audio_encode_thread_proxy_->RunsTasksOnCurrentThread();
case CastEnvironment::AUDIO_DECODER:
- return audio_decode_thread_proxy_->RunsTasksOnCurrentThread();
+ return audio_decode_thread_proxy_ &&
+ audio_decode_thread_proxy_->RunsTasksOnCurrentThread();
case CastEnvironment::VIDEO_ENCODER:
- return video_encode_thread_proxy_->RunsTasksOnCurrentThread();
+ return video_encode_thread_proxy_ &&
+ video_encode_thread_proxy_->RunsTasksOnCurrentThread();
case CastEnvironment::VIDEO_DECODER:
- return video_decode_thread_proxy_->RunsTasksOnCurrentThread();
+ return video_decode_thread_proxy_ &&
+ video_decode_thread_proxy_->RunsTasksOnCurrentThread();
case CastEnvironment::TRANSPORT:
- return transport_thread_proxy_->RunsTasksOnCurrentThread();
+ return transport_thread_proxy_ &&
+ transport_thread_proxy_->RunsTasksOnCurrentThread();
default:
NOTREACHED() << "Invalid thread identifier";
return false;
}
}
-base::TickClock* CastEnvironment::Clock() const { return clock_.get(); }
-
-LoggingImpl* CastEnvironment::Logging() {
- DCHECK(CurrentlyOn(CastEnvironment::MAIN))
- << "Must be called from main thread";
- return logging_.get();
-}
-
} // namespace cast
} // namespace media