| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/cast_environment.h" | 5 #include "media/cast/cast_environment.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 using base::SingleThreadTaskRunner; | 11 using base::SingleThreadTaskRunner; |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 void DeleteLoggingOnMainThread(scoped_ptr<media::cast::LoggingImpl> logging) { | 15 void DeleteLoggingOnMainThread(scoped_ptr<media::cast::LoggingImpl> logging) { |
| 16 logging.reset(); | 16 logging.reset(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 namespace cast { | 22 namespace cast { |
| 23 | 23 |
| 24 CastEnvironment::CastEnvironment( | 24 CastEnvironment::CastEnvironment( |
| 25 scoped_ptr<base::TickClock> clock, | 25 scoped_ptr<base::TickClock> clock, |
| 26 scoped_refptr<SingleThreadTaskRunner> main_thread_proxy, | 26 scoped_refptr<SingleThreadTaskRunner> main_thread_proxy, |
| 27 scoped_refptr<SingleThreadTaskRunner> audio_thread_proxy, | 27 scoped_refptr<SingleThreadTaskRunner> audio_thread_proxy, |
| 28 scoped_refptr<SingleThreadTaskRunner> video_thread_proxy, | 28 scoped_refptr<SingleThreadTaskRunner> video_thread_proxy) |
| 29 const CastLoggingConfig& logging_config) | |
| 30 : main_thread_proxy_(main_thread_proxy), | 29 : main_thread_proxy_(main_thread_proxy), |
| 31 audio_thread_proxy_(audio_thread_proxy), | 30 audio_thread_proxy_(audio_thread_proxy), |
| 32 video_thread_proxy_(video_thread_proxy), | 31 video_thread_proxy_(video_thread_proxy), |
| 33 clock_(clock.Pass()), | 32 clock_(clock.Pass()), |
| 34 logging_(new LoggingImpl(logging_config)) {} | 33 logging_(new LoggingImpl) {} |
| 35 | 34 |
| 36 CastEnvironment::~CastEnvironment() { | 35 CastEnvironment::~CastEnvironment() { |
| 37 // Logging must be deleted on the main thread. | 36 // Logging must be deleted on the main thread. |
| 38 if (main_thread_proxy_ && !main_thread_proxy_->RunsTasksOnCurrentThread()) { | 37 if (main_thread_proxy_ && !main_thread_proxy_->RunsTasksOnCurrentThread()) { |
| 39 main_thread_proxy_->PostTask( | 38 main_thread_proxy_->PostTask( |
| 40 FROM_HERE, | 39 FROM_HERE, |
| 41 base::Bind(&DeleteLoggingOnMainThread, base::Passed(&logging_))); | 40 base::Bind(&DeleteLoggingOnMainThread, base::Passed(&logging_))); |
| 42 } | 41 } |
| 43 } | 42 } |
| 44 | 43 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return video_thread_proxy_ && | 82 return video_thread_proxy_ && |
| 84 video_thread_proxy_->RunsTasksOnCurrentThread(); | 83 video_thread_proxy_->RunsTasksOnCurrentThread(); |
| 85 default: | 84 default: |
| 86 NOTREACHED() << "Invalid thread identifier"; | 85 NOTREACHED() << "Invalid thread identifier"; |
| 87 return false; | 86 return false; |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 } // namespace cast | 90 } // namespace cast |
| 92 } // namespace media | 91 } // namespace media |
| OLD | NEW |