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_thread.h" | 5 #include "media/cast/cast_thread.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 using base::TaskRunner; | 9 using base::TaskRunner; |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 namespace cast { | 12 namespace cast { |
13 | 13 |
14 CastThread::CastThread( | 14 CastThread::CastThread( |
15 scoped_refptr<TaskRunner> main_thread_proxy, | 15 scoped_refptr<TaskRunner> main_thread_proxy, |
16 scoped_refptr<TaskRunner> audio_encode_thread_proxy, | 16 scoped_refptr<TaskRunner> audio_encode_thread_proxy, |
17 scoped_refptr<TaskRunner> audio_decode_thread_proxy, | 17 scoped_refptr<TaskRunner> audio_decode_thread_proxy, |
18 scoped_refptr<TaskRunner> video_encode_thread_proxy, | 18 scoped_refptr<TaskRunner> video_encode_thread_proxy, |
19 scoped_refptr<TaskRunner> video_decode_thread_proxy) | 19 scoped_refptr<TaskRunner> video_decode_thread_proxy) |
20 : main_thread_proxy_(main_thread_proxy), | 20 : main_thread_proxy_(main_thread_proxy), |
21 audio_encode_thread_proxy_(audio_encode_thread_proxy), | 21 audio_encode_thread_proxy_(audio_encode_thread_proxy), |
22 audio_decode_thread_proxy_(audio_decode_thread_proxy), | 22 audio_decode_thread_proxy_(audio_decode_thread_proxy), |
23 video_encode_thread_proxy_(video_encode_thread_proxy), | 23 video_encode_thread_proxy_(video_encode_thread_proxy), |
24 video_decode_thread_proxy_(video_decode_thread_proxy) { | 24 video_decode_thread_proxy_(video_decode_thread_proxy) { |
25 DCHECK(main_thread_proxy) << "Main thread required"; | 25 DCHECK(main_thread_proxy) << "Main thread required"; |
26 } | 26 } |
27 | 27 |
| 28 CastThread::~CastThread() {} |
| 29 |
28 bool CastThread::PostTask(ThreadId identifier, | 30 bool CastThread::PostTask(ThreadId identifier, |
29 const tracked_objects::Location& from_here, | 31 const tracked_objects::Location& from_here, |
30 const base::Closure& task) { | 32 const base::Closure& task) { |
31 scoped_refptr<TaskRunner> task_runner = | 33 scoped_refptr<TaskRunner> task_runner = |
32 GetMessageTaskRunnerForThread(identifier); | 34 GetMessageTaskRunnerForThread(identifier); |
33 | 35 |
34 return task_runner->PostTask(from_here, task); | 36 return task_runner->PostTask(from_here, task); |
35 } | 37 } |
36 | 38 |
37 bool CastThread::PostDelayedTask(ThreadId identifier, | 39 bool CastThread::PostDelayedTask(ThreadId identifier, |
(...skipping 12 matching lines...) Expand all Loading... |
50 case CastThread::MAIN: | 52 case CastThread::MAIN: |
51 return main_thread_proxy_; | 53 return main_thread_proxy_; |
52 case CastThread::AUDIO_ENCODER: | 54 case CastThread::AUDIO_ENCODER: |
53 return audio_encode_thread_proxy_; | 55 return audio_encode_thread_proxy_; |
54 case CastThread::AUDIO_DECODER: | 56 case CastThread::AUDIO_DECODER: |
55 return audio_decode_thread_proxy_; | 57 return audio_decode_thread_proxy_; |
56 case CastThread::VIDEO_ENCODER: | 58 case CastThread::VIDEO_ENCODER: |
57 return video_encode_thread_proxy_; | 59 return video_encode_thread_proxy_; |
58 case CastThread::VIDEO_DECODER: | 60 case CastThread::VIDEO_DECODER: |
59 return video_decode_thread_proxy_; | 61 return video_decode_thread_proxy_; |
| 62 default: |
| 63 CHECK(false) << "Invalid Thread ID."; |
| 64 return NULL; |
60 } | 65 } |
61 } | 66 } |
62 | 67 |
63 bool CastThread::CurrentlyOn(ThreadId identifier) { | 68 bool CastThread::CurrentlyOn(ThreadId identifier) { |
64 switch (identifier) { | 69 switch (identifier) { |
65 case CastThread::MAIN: | 70 case CastThread::MAIN: |
66 return main_thread_proxy_->RunsTasksOnCurrentThread(); | 71 return main_thread_proxy_->RunsTasksOnCurrentThread(); |
67 case CastThread::AUDIO_ENCODER: | 72 case CastThread::AUDIO_ENCODER: |
68 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 73 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
69 case CastThread::AUDIO_DECODER: | 74 case CastThread::AUDIO_DECODER: |
70 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 75 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
71 case CastThread::VIDEO_ENCODER: | 76 case CastThread::VIDEO_ENCODER: |
72 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 77 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
73 case CastThread::VIDEO_DECODER: | 78 case CastThread::VIDEO_DECODER: |
74 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 79 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
75 default: | 80 default: |
76 DCHECK(false) << "Wrong thread identifier"; | 81 CHECK(false) << "Wrong thread identifier"; |
| 82 return false; |
77 } | 83 } |
78 } | 84 } |
79 | 85 |
80 } // namespace cast | 86 } // namespace cast |
81 } // namespace media | 87 } // namespace media |
OLD | NEW |