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 |
(...skipping 16 matching lines...) Expand all Loading... |
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 : main_thread_proxy_(main_thread_proxy), | 29 : main_thread_proxy_(main_thread_proxy), |
30 audio_thread_proxy_(audio_thread_proxy), | 30 audio_thread_proxy_(audio_thread_proxy), |
31 video_thread_proxy_(video_thread_proxy), | 31 video_thread_proxy_(video_thread_proxy), |
32 clock_(clock.Pass()), | 32 clock_(clock.Pass()), |
33 logging_(new LoggingImpl) {} | 33 logging_(new LoggingImpl) {} |
34 | 34 |
35 CastEnvironment::~CastEnvironment() { | 35 CastEnvironment::~CastEnvironment() { |
36 // Logging must be deleted on the main thread. | 36 // Logging must be deleted on the main thread. |
37 if (main_thread_proxy_ && !main_thread_proxy_->RunsTasksOnCurrentThread()) { | 37 if (main_thread_proxy_.get() && |
| 38 !main_thread_proxy_->RunsTasksOnCurrentThread()) { |
38 main_thread_proxy_->PostTask( | 39 main_thread_proxy_->PostTask( |
39 FROM_HERE, | 40 FROM_HERE, |
40 base::Bind(&DeleteLoggingOnMainThread, base::Passed(&logging_))); | 41 base::Bind(&DeleteLoggingOnMainThread, base::Passed(&logging_))); |
41 } | 42 } |
42 } | 43 } |
43 | 44 |
44 bool CastEnvironment::PostTask(ThreadId identifier, | 45 bool CastEnvironment::PostTask(ThreadId identifier, |
45 const tracked_objects::Location& from_here, | 46 const tracked_objects::Location& from_here, |
46 const base::Closure& task) { | 47 const base::Closure& task) { |
47 return GetTaskRunner(identifier)->PostTask(from_here, task); | 48 return GetTaskRunner(identifier)->PostTask(from_here, task); |
(...skipping 18 matching lines...) Expand all Loading... |
66 return video_thread_proxy_; | 67 return video_thread_proxy_; |
67 default: | 68 default: |
68 NOTREACHED() << "Invalid Thread identifier"; | 69 NOTREACHED() << "Invalid Thread identifier"; |
69 return NULL; | 70 return NULL; |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { | 74 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { |
74 switch (identifier) { | 75 switch (identifier) { |
75 case CastEnvironment::MAIN: | 76 case CastEnvironment::MAIN: |
76 return main_thread_proxy_ && | 77 return main_thread_proxy_.get() && |
77 main_thread_proxy_->RunsTasksOnCurrentThread(); | 78 main_thread_proxy_->RunsTasksOnCurrentThread(); |
78 case CastEnvironment::AUDIO: | 79 case CastEnvironment::AUDIO: |
79 return audio_thread_proxy_ && | 80 return audio_thread_proxy_.get() && |
80 audio_thread_proxy_->RunsTasksOnCurrentThread(); | 81 audio_thread_proxy_->RunsTasksOnCurrentThread(); |
81 case CastEnvironment::VIDEO: | 82 case CastEnvironment::VIDEO: |
82 return video_thread_proxy_ && | 83 return video_thread_proxy_.get() && |
83 video_thread_proxy_->RunsTasksOnCurrentThread(); | 84 video_thread_proxy_->RunsTasksOnCurrentThread(); |
84 default: | 85 default: |
85 NOTREACHED() << "Invalid thread identifier"; | 86 NOTREACHED() << "Invalid thread identifier"; |
86 return false; | 87 return false; |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
90 } // namespace cast | 91 } // namespace cast |
91 } // namespace media | 92 } // namespace media |
OLD | NEW |