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/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 CastEnvironment::CastEnvironment( | 14 CastEnvironment::CastEnvironment( |
15 base::TickClock* clock, | 15 base::TickClock* clock, |
16 scoped_refptr<TaskRunner> main_thread_proxy, | 16 scoped_refptr<TaskRunner> main_thread_proxy, |
17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, | 17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, |
18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, | 18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, |
19 scoped_refptr<TaskRunner> video_encode_thread_proxy, | 19 scoped_refptr<TaskRunner> video_encode_thread_proxy, |
20 scoped_refptr<TaskRunner> video_decode_thread_proxy) | 20 scoped_refptr<TaskRunner> video_decode_thread_proxy, |
21 bool enable_data_collection, | |
22 bool enable_uma_stats, | |
23 bool enable_tracing) | |
21 : clock_(clock), | 24 : clock_(clock), |
22 main_thread_proxy_(main_thread_proxy), | 25 main_thread_proxy_(main_thread_proxy), |
23 audio_encode_thread_proxy_(audio_encode_thread_proxy), | 26 audio_encode_thread_proxy_(audio_encode_thread_proxy), |
24 audio_decode_thread_proxy_(audio_decode_thread_proxy), | 27 audio_decode_thread_proxy_(audio_decode_thread_proxy), |
25 video_encode_thread_proxy_(video_encode_thread_proxy), | 28 video_encode_thread_proxy_(video_encode_thread_proxy), |
26 video_decode_thread_proxy_(video_decode_thread_proxy) { | 29 video_decode_thread_proxy_(video_decode_thread_proxy), |
30 logging_(new LoggingImpl(clock, main_thread_proxy, | |
Alpha Left Google
2013/11/14 00:29:24
Use a separate method to start logging instead of
mikhal
2013/11/14 17:42:31
Don't see why.
On 2013/11/14 00:29:24, Alpha wrote
| |
31 enable_data_collection, enable_uma_stats, enable_tracing)) { | |
27 DCHECK(main_thread_proxy) << "Main thread required"; | 32 DCHECK(main_thread_proxy) << "Main thread required"; |
28 } | 33 } |
29 | 34 |
30 CastEnvironment::~CastEnvironment() {} | 35 CastEnvironment::~CastEnvironment() {} |
31 | 36 |
32 bool CastEnvironment::PostTask(ThreadId identifier, | 37 bool CastEnvironment::PostTask(ThreadId identifier, |
33 const tracked_objects::Location& from_here, | 38 const tracked_objects::Location& from_here, |
34 const base::Closure& task) { | 39 const base::Closure& task) { |
35 scoped_refptr<TaskRunner> task_runner = | 40 scoped_refptr<TaskRunner> task_runner = |
36 GetMessageTaskRunnerForThread(identifier); | 41 GetMessageTaskRunnerForThread(identifier); |
(...skipping 18 matching lines...) Expand all Loading... | |
55 return main_thread_proxy_; | 60 return main_thread_proxy_; |
56 case CastEnvironment::AUDIO_ENCODER: | 61 case CastEnvironment::AUDIO_ENCODER: |
57 return audio_encode_thread_proxy_; | 62 return audio_encode_thread_proxy_; |
58 case CastEnvironment::AUDIO_DECODER: | 63 case CastEnvironment::AUDIO_DECODER: |
59 return audio_decode_thread_proxy_; | 64 return audio_decode_thread_proxy_; |
60 case CastEnvironment::VIDEO_ENCODER: | 65 case CastEnvironment::VIDEO_ENCODER: |
61 return video_encode_thread_proxy_; | 66 return video_encode_thread_proxy_; |
62 case CastEnvironment::VIDEO_DECODER: | 67 case CastEnvironment::VIDEO_DECODER: |
63 return video_decode_thread_proxy_; | 68 return video_decode_thread_proxy_; |
64 default: | 69 default: |
65 NOTREACHED() << "Invalid Thread ID."; | 70 NOTREACHED() << "Invalid Thread identifier"; |
66 return NULL; | 71 return NULL; |
67 } | 72 } |
68 } | 73 } |
69 | 74 |
70 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { | 75 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { |
71 switch (identifier) { | 76 switch (identifier) { |
72 case CastEnvironment::MAIN: | 77 case CastEnvironment::MAIN: |
73 return main_thread_proxy_->RunsTasksOnCurrentThread(); | 78 return main_thread_proxy_->RunsTasksOnCurrentThread(); |
74 case CastEnvironment::AUDIO_ENCODER: | 79 case CastEnvironment::AUDIO_ENCODER: |
75 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 80 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
76 case CastEnvironment::AUDIO_DECODER: | 81 case CastEnvironment::AUDIO_DECODER: |
77 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 82 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
78 case CastEnvironment::VIDEO_ENCODER: | 83 case CastEnvironment::VIDEO_ENCODER: |
79 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 84 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
80 case CastEnvironment::VIDEO_DECODER: | 85 case CastEnvironment::VIDEO_DECODER: |
81 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 86 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
82 default: | 87 default: |
83 NOTREACHED() << "Wrong thread identifier"; | 88 NOTREACHED() << "Invalid thread identifier"; |
84 return false; | 89 return false; |
85 } | 90 } |
86 } | 91 } |
87 | 92 |
88 base::TickClock* CastEnvironment::Clock() { | 93 base::TickClock* const CastEnvironment::Clock() const { |
89 return clock_; | 94 return clock_; |
90 } | 95 } |
91 | 96 |
97 LoggingImpl* const CastEnvironment::Logging() { | |
98 return logging_.get(); | |
Alpha Left Google
2013/11/14 00:29:24
Check that this accessor is called on the right th
mikhal
2013/11/14 17:42:31
Added a dcheck
On 2013/11/14 00:29:24, Alpha wrote
| |
99 } | |
100 | |
92 } // namespace cast | 101 } // namespace cast |
93 } // namespace media | 102 } // namespace media |
OLD | NEW |