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

Unified Diff: media/cast/cast_environment.cc

Issue 184813009: Cast Streaming API end-to-end browser_test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix LoggingImplTest + REBASE Created 6 years, 9 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 | « media/cast/cast_environment.h ('k') | media/cast/cast_receiver_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/cast_environment.cc
diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc
index 9b1a5696486d5c85187121c5bf7c95ea647ab4e6..9077b52b723294e34142628f0e2c2f1add5dd290 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
« no previous file with comments | « media/cast/cast_environment.h ('k') | media/cast/cast_receiver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698