Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/media/media_internals.h" | 5 #include "chrome/browser/media/media_internals.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/media/audio_stream_indicator.h" | |
| 10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 11 #include "chrome/browser/media/media_internals_observer.h" | 12 #include "chrome/browser/media/media_internals_observer.h" |
| 12 #include "chrome/browser/media/media_stream_capture_indicator.h" | 13 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
| 18 #include "media/base/media_log.h" | 19 #include "media/base/media_log.h" |
| 19 #include "media/base/media_log_event.h" | 20 #include "media/base/media_log_event.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 85 |
| 85 MediaInternals::~MediaInternals() {} | 86 MediaInternals::~MediaInternals() {} |
| 86 | 87 |
| 87 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { | 88 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { |
| 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 89 std::string stream = base::StringPrintf("audio_streams.%p:%d", | 90 std::string stream = base::StringPrintf("audio_streams.%p:%d", |
| 90 host, stream_id); | 91 host, stream_id); |
| 91 DeleteItem(stream); | 92 DeleteItem(stream); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void MediaInternals::OnSetAudioStreamPlaying( | 95 void MediaInternals::OnSetAudioStreamPlaying(void* host, |
| 95 void* host, int stream_id, bool playing) { | 96 int stream_id, |
| 97 int render_process_id, | |
| 98 int render_view_id, | |
| 99 bool playing) { | |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 97 UpdateAudioStream(host, stream_id, | 101 UpdateAudioStream(host, stream_id, |
| 98 "playing", Value::CreateBooleanValue(playing)); | 102 "playing", Value::CreateBooleanValue(playing)); |
| 103 audio_stream_indicator_->UpdateWebContentsStatus(render_process_id, | |
| 104 render_view_id, | |
|
miu
2012/12/19 00:49:08
fix indentation.
| |
| 105 playing); | |
| 99 } | 106 } |
| 100 | 107 |
| 101 void MediaInternals::OnSetAudioStreamStatus( | 108 void MediaInternals::OnSetAudioStreamStatus( |
| 102 void* host, int stream_id, const std::string& status) { | 109 void* host, int stream_id, const std::string& status) { |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 104 UpdateAudioStream(host, stream_id, | 111 UpdateAudioStream(host, stream_id, |
| 105 "status", Value::CreateStringValue(status)); | 112 "status", Value::CreateStringValue(status)); |
| 106 } | 113 } |
| 107 | 114 |
| 108 void MediaInternals::OnSetAudioStreamVolume( | 115 void MediaInternals::OnSetAudioStreamVolume( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 scoped_refptr<MediaCaptureDevicesDispatcher> | 199 scoped_refptr<MediaCaptureDevicesDispatcher> |
| 193 MediaInternals::GetMediaCaptureDevicesDispatcher() { | 200 MediaInternals::GetMediaCaptureDevicesDispatcher() { |
| 194 return media_devices_dispatcher_; | 201 return media_devices_dispatcher_; |
| 195 } | 202 } |
| 196 | 203 |
| 197 scoped_refptr<MediaStreamCaptureIndicator> | 204 scoped_refptr<MediaStreamCaptureIndicator> |
| 198 MediaInternals::GetMediaStreamCaptureIndicator() { | 205 MediaInternals::GetMediaStreamCaptureIndicator() { |
| 199 return media_stream_capture_indicator_.get(); | 206 return media_stream_capture_indicator_.get(); |
| 200 } | 207 } |
| 201 | 208 |
| 209 AudioStreamIndicator* MediaInternals::GetAudioStreamIndicator() { | |
| 210 return audio_stream_indicator_; | |
| 211 } | |
| 212 | |
| 202 MediaInternals::MediaInternals() | 213 MediaInternals::MediaInternals() |
| 203 : media_stream_capture_indicator_(new MediaStreamCaptureIndicator()), | 214 : media_stream_capture_indicator_(new MediaStreamCaptureIndicator()), |
| 204 media_devices_dispatcher_(new MediaCaptureDevicesDispatcher()) { | 215 media_devices_dispatcher_(new MediaCaptureDevicesDispatcher()), |
| 216 audio_stream_indicator_(new AudioStreamIndicator()) { | |
| 205 } | 217 } |
| 206 | 218 |
| 207 void MediaInternals::UpdateAudioStream( | 219 void MediaInternals::UpdateAudioStream( |
| 208 void* host, int stream_id, const std::string& property, Value* value) { | 220 void* host, int stream_id, const std::string& property, Value* value) { |
| 209 std::string stream = base::StringPrintf("audio_streams.%p:%d", | 221 std::string stream = base::StringPrintf("audio_streams.%p:%d", |
| 210 host, stream_id); | 222 host, stream_id); |
| 211 UpdateItem("media.addAudioStream", stream, property, value); | 223 UpdateItem("media.addAudioStream", stream, property, value); |
| 212 } | 224 } |
| 213 | 225 |
| 214 void MediaInternals::DeleteItem(const std::string& item) { | 226 void MediaInternals::DeleteItem(const std::string& item) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 232 | 244 |
| 233 void MediaInternals::SendUpdate(const std::string& function, Value* value) { | 245 void MediaInternals::SendUpdate(const std::string& function, Value* value) { |
| 234 // Only bother serializing the update to JSON if someone is watching. | 246 // Only bother serializing the update to JSON if someone is watching. |
| 235 if (observers_.size()) { | 247 if (observers_.size()) { |
| 236 std::vector<const Value*> args; | 248 std::vector<const Value*> args; |
| 237 args.push_back(value); | 249 args.push_back(value); |
| 238 string16 update = content::WebUI::GetJavascriptCall(function, args); | 250 string16 update = content::WebUI::GetJavascriptCall(function, args); |
| 239 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); | 251 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); |
| 240 } | 252 } |
| 241 } | 253 } |
| OLD | NEW |