| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/media/webrtc_internals.h" | 5 #include "content/browser/media/webrtc_internals.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 if (!dict->GetList("log", &log)) { | 32 if (!dict->GetList("log", &log)) { |
| 33 log = new base::ListValue(); | 33 log = new base::ListValue(); |
| 34 if (log) | 34 if (log) |
| 35 dict->Set("log", log); | 35 dict->Set("log", log); |
| 36 } | 36 } |
| 37 return log; | 37 return log; |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 WebRTCInternals::WebRTCInternals() | 42 WebRTCInternals::PendingUpdate::PendingUpdate( |
| 43 const std::string& command, scoped_ptr<base::Value> value) |
| 44 : command_(command), value_(std::move(value)) {} |
| 45 |
| 46 WebRTCInternals::PendingUpdate::PendingUpdate(PendingUpdate&& other) |
| 47 : command_(std::move(other.command_)), |
| 48 value_(std::move(other.value_)) {} |
| 49 |
| 50 WebRTCInternals::PendingUpdate::~PendingUpdate() { |
| 51 DCHECK(thread_checker_.CalledOnValidThread()); |
| 52 } |
| 53 |
| 54 const std::string& WebRTCInternals::PendingUpdate::command() const { |
| 55 DCHECK(thread_checker_.CalledOnValidThread()); |
| 56 return command_; |
| 57 } |
| 58 |
| 59 const base::Value* WebRTCInternals::PendingUpdate::value() const { |
| 60 DCHECK(thread_checker_.CalledOnValidThread()); |
| 61 return value_.get(); |
| 62 } |
| 63 |
| 64 WebRTCInternals::WebRTCInternals() : WebRTCInternals(500) {} |
| 65 |
| 66 WebRTCInternals::WebRTCInternals(int aggregate_updates_ms) |
| 43 : audio_debug_recordings_(false), | 67 : audio_debug_recordings_(false), |
| 44 event_log_recordings_(false), | 68 event_log_recordings_(false), |
| 45 selecting_event_log_(false) { | 69 selecting_event_log_(false), |
| 70 aggregate_updates_ms_(aggregate_updates_ms), |
| 71 weak_factory_(this) { |
| 46 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the | 72 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the |
| 47 // build if WebRTC is disabled? | 73 // build if WebRTC is disabled? |
| 48 #if defined(ENABLE_WEBRTC) | 74 #if defined(ENABLE_WEBRTC) |
| 49 audio_debug_recordings_file_path_ = | 75 audio_debug_recordings_file_path_ = |
| 50 GetContentClient()->browser()->GetDefaultDownloadDirectory(); | 76 GetContentClient()->browser()->GetDefaultDownloadDirectory(); |
| 51 event_log_recordings_file_path_ = audio_debug_recordings_file_path_; | 77 event_log_recordings_file_path_ = audio_debug_recordings_file_path_; |
| 52 | 78 |
| 53 if (audio_debug_recordings_file_path_.empty()) { | 79 if (audio_debug_recordings_file_path_.empty()) { |
| 54 // In this case the default path (|audio_debug_recordings_file_path_|) will | 80 // In this case the default path (|audio_debug_recordings_file_path_|) will |
| 55 // be empty and the platform default path will be used in the file dialog | 81 // be empty and the platform default path will be used in the file dialog |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 | 101 |
| 76 void WebRTCInternals::OnAddPeerConnection(int render_process_id, | 102 void WebRTCInternals::OnAddPeerConnection(int render_process_id, |
| 77 ProcessId pid, | 103 ProcessId pid, |
| 78 int lid, | 104 int lid, |
| 79 const string& url, | 105 const string& url, |
| 80 const string& rtc_configuration, | 106 const string& rtc_configuration, |
| 81 const string& constraints) { | 107 const string& constraints) { |
| 82 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 108 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 83 | 109 |
| 84 base::DictionaryValue* dict = new base::DictionaryValue(); | 110 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 85 if (!dict) | |
| 86 return; | |
| 87 | |
| 88 dict->SetInteger("rid", render_process_id); | 111 dict->SetInteger("rid", render_process_id); |
| 89 dict->SetInteger("pid", static_cast<int>(pid)); | 112 dict->SetInteger("pid", static_cast<int>(pid)); |
| 90 dict->SetInteger("lid", lid); | 113 dict->SetInteger("lid", lid); |
| 91 dict->SetString("rtcConfiguration", rtc_configuration); | 114 dict->SetString("rtcConfiguration", rtc_configuration); |
| 92 dict->SetString("constraints", constraints); | 115 dict->SetString("constraints", constraints); |
| 93 dict->SetString("url", url); | 116 dict->SetString("url", url); |
| 94 peer_connection_data_.Append(dict); | 117 peer_connection_data_.Append(dict); |
| 95 CreateOrReleasePowerSaveBlocker(); | 118 CreateOrReleasePowerSaveBlocker(); |
| 96 | 119 |
| 97 if (observers_.might_have_observers()) | 120 if (observers_.might_have_observers()) |
| 98 SendUpdate("addPeerConnection", dict); | 121 SendUpdate("addPeerConnection", dict->CreateDeepCopy()); |
| 99 | 122 |
| 100 if (render_process_id_set_.insert(render_process_id).second) { | 123 if (render_process_id_set_.insert(render_process_id).second) { |
| 101 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); | 124 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); |
| 102 if (host) | 125 if (host) |
| 103 host->AddObserver(this); | 126 host->AddObserver(this); |
| 104 } | 127 } |
| 105 } | 128 } |
| 106 | 129 |
| 107 void WebRTCInternals::OnRemovePeerConnection(ProcessId pid, int lid) { | 130 void WebRTCInternals::OnRemovePeerConnection(ProcessId pid, int lid) { |
| 108 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 109 for (size_t i = 0; i < peer_connection_data_.GetSize(); ++i) { | 132 for (size_t i = 0; i < peer_connection_data_.GetSize(); ++i) { |
| 110 base::DictionaryValue* dict = NULL; | 133 base::DictionaryValue* dict = NULL; |
| 111 peer_connection_data_.GetDictionary(i, &dict); | 134 peer_connection_data_.GetDictionary(i, &dict); |
| 112 | 135 |
| 113 int this_pid = 0; | 136 int this_pid = 0; |
| 114 int this_lid = 0; | 137 int this_lid = 0; |
| 115 dict->GetInteger("pid", &this_pid); | 138 dict->GetInteger("pid", &this_pid); |
| 116 dict->GetInteger("lid", &this_lid); | 139 dict->GetInteger("lid", &this_lid); |
| 117 | 140 |
| 118 if (this_pid != static_cast<int>(pid) || this_lid != lid) | 141 if (this_pid != static_cast<int>(pid) || this_lid != lid) |
| 119 continue; | 142 continue; |
| 120 | 143 |
| 121 peer_connection_data_.Remove(i, NULL); | 144 peer_connection_data_.Remove(i, NULL); |
| 122 CreateOrReleasePowerSaveBlocker(); | 145 CreateOrReleasePowerSaveBlocker(); |
| 123 | 146 |
| 124 if (observers_.might_have_observers()) { | 147 if (observers_.might_have_observers()) { |
| 125 base::DictionaryValue id; | 148 scoped_ptr<base::DictionaryValue> id(new base::DictionaryValue()); |
| 126 id.SetInteger("pid", static_cast<int>(pid)); | 149 id->SetInteger("pid", static_cast<int>(pid)); |
| 127 id.SetInteger("lid", lid); | 150 id->SetInteger("lid", lid); |
| 128 SendUpdate("removePeerConnection", &id); | 151 SendUpdate("removePeerConnection", std::move(id)); |
| 129 } | 152 } |
| 130 break; | 153 break; |
| 131 } | 154 } |
| 132 } | 155 } |
| 133 | 156 |
| 134 void WebRTCInternals::OnUpdatePeerConnection( | 157 void WebRTCInternals::OnUpdatePeerConnection( |
| 135 ProcessId pid, int lid, const string& type, const string& value) { | 158 ProcessId pid, int lid, const string& type, const string& value) { |
| 136 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 159 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 137 | 160 |
| 138 for (size_t i = 0; i < peer_connection_data_.GetSize(); ++i) { | 161 for (size_t i = 0; i < peer_connection_data_.GetSize(); ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 156 return; | 179 return; |
| 157 | 180 |
| 158 double epoch_time = base::Time::Now().ToJsTime(); | 181 double epoch_time = base::Time::Now().ToJsTime(); |
| 159 string time = base::DoubleToString(epoch_time); | 182 string time = base::DoubleToString(epoch_time); |
| 160 log_entry->SetString("time", time); | 183 log_entry->SetString("time", time); |
| 161 log_entry->SetString("type", type); | 184 log_entry->SetString("type", type); |
| 162 log_entry->SetString("value", value); | 185 log_entry->SetString("value", value); |
| 163 log->Append(log_entry); | 186 log->Append(log_entry); |
| 164 | 187 |
| 165 if (observers_.might_have_observers()) { | 188 if (observers_.might_have_observers()) { |
| 166 base::DictionaryValue update; | 189 scoped_ptr<base::DictionaryValue> update(new base::DictionaryValue()); |
| 167 update.SetInteger("pid", static_cast<int>(pid)); | 190 update->SetInteger("pid", static_cast<int>(pid)); |
| 168 update.SetInteger("lid", lid); | 191 update->SetInteger("lid", lid); |
| 169 update.MergeDictionary(log_entry); | 192 update->MergeDictionary(log_entry); |
| 170 | 193 |
| 171 SendUpdate("updatePeerConnection", &update); | 194 SendUpdate("updatePeerConnection", std::move(update)); |
| 172 } | 195 } |
| 173 return; | 196 return; |
| 174 } | 197 } |
| 175 } | 198 } |
| 176 | 199 |
| 177 void WebRTCInternals::OnAddStats(base::ProcessId pid, int lid, | 200 void WebRTCInternals::OnAddStats(base::ProcessId pid, int lid, |
| 178 const base::ListValue& value) { | 201 const base::ListValue& value) { |
| 179 if (!observers_.might_have_observers()) | 202 if (!observers_.might_have_observers()) |
| 180 return; | 203 return; |
| 181 | 204 |
| 182 base::DictionaryValue dict; | 205 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 183 dict.SetInteger("pid", static_cast<int>(pid)); | 206 dict->SetInteger("pid", static_cast<int>(pid)); |
| 184 dict.SetInteger("lid", lid); | 207 dict->SetInteger("lid", lid); |
| 185 | 208 |
| 186 base::ListValue* list = value.DeepCopy(); | 209 dict->Set("reports", value.CreateDeepCopy()); |
| 187 if (!list) | |
| 188 return; | |
| 189 | 210 |
| 190 dict.Set("reports", list); | 211 SendUpdate("addStats", std::move(dict)); |
| 191 | |
| 192 SendUpdate("addStats", &dict); | |
| 193 } | 212 } |
| 194 | 213 |
| 195 void WebRTCInternals::OnGetUserMedia(int rid, | 214 void WebRTCInternals::OnGetUserMedia(int rid, |
| 196 base::ProcessId pid, | 215 base::ProcessId pid, |
| 197 const std::string& origin, | 216 const std::string& origin, |
| 198 bool audio, | 217 bool audio, |
| 199 bool video, | 218 bool video, |
| 200 const std::string& audio_constraints, | 219 const std::string& audio_constraints, |
| 201 const std::string& video_constraints) { | 220 const std::string& video_constraints) { |
| 202 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 221 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 203 | 222 |
| 204 base::DictionaryValue* dict = new base::DictionaryValue(); | 223 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 205 dict->SetInteger("rid", rid); | 224 dict->SetInteger("rid", rid); |
| 206 dict->SetInteger("pid", static_cast<int>(pid)); | 225 dict->SetInteger("pid", static_cast<int>(pid)); |
| 207 dict->SetString("origin", origin); | 226 dict->SetString("origin", origin); |
| 208 if (audio) | 227 if (audio) |
| 209 dict->SetString("audio", audio_constraints); | 228 dict->SetString("audio", audio_constraints); |
| 210 if (video) | 229 if (video) |
| 211 dict->SetString("video", video_constraints); | 230 dict->SetString("video", video_constraints); |
| 212 | 231 |
| 213 get_user_media_requests_.Append(dict); | 232 get_user_media_requests_.Append(dict); |
| 214 | 233 |
| 215 if (observers_.might_have_observers()) | 234 if (observers_.might_have_observers()) |
| 216 SendUpdate("addGetUserMedia", dict); | 235 SendUpdate("addGetUserMedia", dict->CreateDeepCopy()); |
| 217 | 236 |
| 218 if (render_process_id_set_.insert(rid).second) { | 237 if (render_process_id_set_.insert(rid).second) { |
| 219 RenderProcessHost* host = RenderProcessHost::FromID(rid); | 238 RenderProcessHost* host = RenderProcessHost::FromID(rid); |
| 220 if (host) | 239 if (host) |
| 221 host->AddObserver(this); | 240 host->AddObserver(this); |
| 222 } | 241 } |
| 223 } | 242 } |
| 224 | 243 |
| 225 void WebRTCInternals::AddObserver(WebRTCInternalsUIObserver *observer) { | 244 void WebRTCInternals::AddObserver(WebRTCInternalsUIObserver* observer) { |
| 226 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 245 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 227 observers_.AddObserver(observer); | 246 observers_.AddObserver(observer); |
| 228 } | 247 } |
| 229 | 248 |
| 230 void WebRTCInternals::RemoveObserver(WebRTCInternalsUIObserver *observer) { | 249 void WebRTCInternals::RemoveObserver(WebRTCInternalsUIObserver* observer) { |
| 231 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 250 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 232 observers_.RemoveObserver(observer); | 251 observers_.RemoveObserver(observer); |
| 233 | 252 |
| 234 // Disables audio debug recordings if it is enabled and the last | 253 // Disables audio debug recordings if it is enabled and the last |
| 235 // webrtc-internals page is going away. | 254 // webrtc-internals page is going away. |
| 236 if (audio_debug_recordings_ && !observers_.might_have_observers()) | 255 if (audio_debug_recordings_ && !observers_.might_have_observers()) |
| 237 DisableAudioDebugRecordings(); | 256 DisableAudioDebugRecordings(); |
| 238 } | 257 } |
| 239 | 258 |
| 240 void WebRTCInternals::UpdateObserver(WebRTCInternalsUIObserver* observer) { | 259 void WebRTCInternals::UpdateObserver(WebRTCInternalsUIObserver* observer) { |
| 241 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 260 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 242 if (peer_connection_data_.GetSize() > 0) | 261 if (peer_connection_data_.GetSize() > 0) |
| 243 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_); | 262 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_); |
| 244 | 263 |
| 245 for (base::ListValue::iterator it = get_user_media_requests_.begin(); | 264 for (base::ListValue::iterator it = get_user_media_requests_.begin(); |
| 246 it != get_user_media_requests_.end(); | 265 it != get_user_media_requests_.end(); |
| 247 ++it) { | 266 ++it) { |
| 248 observer->OnUpdate("addGetUserMedia", *it); | 267 observer->OnUpdate("addGetUserMedia", *it); |
| 249 } | 268 } |
| 250 } | 269 } |
| 251 | 270 |
| 252 void WebRTCInternals::EnableAudioDebugRecordings( | 271 void WebRTCInternals::EnableAudioDebugRecordings( |
| 253 content::WebContents* web_contents) { | 272 content::WebContents* web_contents) { |
| 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 254 #if defined(ENABLE_WEBRTC) | 274 #if defined(ENABLE_WEBRTC) |
| 255 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 256 #if defined(OS_ANDROID) | 275 #if defined(OS_ANDROID) |
| 257 EnableAudioDebugRecordingsOnAllRenderProcessHosts(); | 276 EnableAudioDebugRecordingsOnAllRenderProcessHosts(); |
| 258 #else | 277 #else |
| 259 selecting_event_log_ = false; | 278 selecting_event_log_ = false; |
| 260 DCHECK(select_file_dialog_ == nullptr); | 279 DCHECK(select_file_dialog_ == nullptr); |
| 261 select_file_dialog_ = ui::SelectFileDialog::Create(this, NULL); | 280 select_file_dialog_ = ui::SelectFileDialog::Create(this, NULL); |
| 262 select_file_dialog_->SelectFile( | 281 select_file_dialog_->SelectFile( |
| 263 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 282 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
| 264 base::string16(), | 283 base::string16(), |
| 265 audio_debug_recordings_file_path_, | 284 audio_debug_recordings_file_path_, |
| 266 NULL, | 285 NULL, |
| 267 0, | 286 0, |
| 268 FILE_PATH_LITERAL(""), | 287 FILE_PATH_LITERAL(""), |
| 269 web_contents->GetTopLevelNativeWindow(), | 288 web_contents->GetTopLevelNativeWindow(), |
| 270 NULL); | 289 NULL); |
| 271 #endif | 290 #endif |
| 272 #endif | 291 #endif |
| 273 } | 292 } |
| 274 | 293 |
| 275 void WebRTCInternals::DisableAudioDebugRecordings() { | 294 void WebRTCInternals::DisableAudioDebugRecordings() { |
| 295 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 276 #if defined(ENABLE_WEBRTC) | 296 #if defined(ENABLE_WEBRTC) |
| 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 278 audio_debug_recordings_ = false; | 297 audio_debug_recordings_ = false; |
| 279 | 298 |
| 280 // Tear down the dialog since the user has unchecked the audio debug | 299 // Tear down the dialog since the user has unchecked the audio debug |
| 281 // recordings box. | 300 // recordings box. |
| 282 select_file_dialog_ = NULL; | 301 select_file_dialog_ = NULL; |
| 283 | 302 |
| 284 for (RenderProcessHost::iterator i( | 303 for (RenderProcessHost::iterator i( |
| 285 content::RenderProcessHost::AllHostsIterator()); | 304 content::RenderProcessHost::AllHostsIterator()); |
| 286 !i.IsAtEnd(); i.Advance()) { | 305 !i.IsAtEnd(); i.Advance()) { |
| 287 i.GetCurrentValue()->DisableAudioDebugRecordings(); | 306 i.GetCurrentValue()->DisableAudioDebugRecordings(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 bool WebRTCInternals::IsEventLogRecordingsEnabled() const { | 355 bool WebRTCInternals::IsEventLogRecordingsEnabled() const { |
| 337 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 356 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 338 return event_log_recordings_; | 357 return event_log_recordings_; |
| 339 } | 358 } |
| 340 | 359 |
| 341 const base::FilePath& WebRTCInternals::GetEventLogRecordingsFilePath() const { | 360 const base::FilePath& WebRTCInternals::GetEventLogRecordingsFilePath() const { |
| 342 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 361 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 343 return event_log_recordings_file_path_; | 362 return event_log_recordings_file_path_; |
| 344 } | 363 } |
| 345 | 364 |
| 346 void WebRTCInternals::ResetForTesting() { | 365 void WebRTCInternals::SendUpdate(const string& command, |
| 366 scoped_ptr<base::Value> value) { |
| 347 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 367 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 348 observers_.Clear(); | |
| 349 peer_connection_data_.Clear(); | |
| 350 CreateOrReleasePowerSaveBlocker(); | |
| 351 get_user_media_requests_.Clear(); | |
| 352 audio_debug_recordings_ = false; | |
| 353 } | |
| 354 | |
| 355 void WebRTCInternals::SendUpdate(const string& command, base::Value* value) { | |
| 356 DCHECK(observers_.might_have_observers()); | 368 DCHECK(observers_.might_have_observers()); |
| 357 | 369 |
| 358 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, | 370 bool queue_was_empty = pending_updates_.empty(); |
| 359 observers_, | 371 pending_updates_.push(PendingUpdate(command, std::move(value))); |
| 360 OnUpdate(command, value)); | 372 |
| 373 if (queue_was_empty) { |
| 374 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| 375 base::Bind(&WebRTCInternals::ProcessPendingUpdates, |
| 376 weak_factory_.GetWeakPtr()), |
| 377 base::TimeDelta::FromMilliseconds(aggregate_updates_ms_)); |
| 378 } |
| 361 } | 379 } |
| 362 | 380 |
| 363 void WebRTCInternals::RenderProcessHostDestroyed(RenderProcessHost* host) { | 381 void WebRTCInternals::RenderProcessHostDestroyed(RenderProcessHost* host) { |
| 364 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 382 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 365 OnRendererExit(host->GetID()); | 383 OnRendererExit(host->GetID()); |
| 366 | 384 |
| 367 render_process_id_set_.erase(host->GetID()); | 385 render_process_id_set_.erase(host->GetID()); |
| 368 host->RemoveObserver(this); | 386 host->RemoveObserver(this); |
| 369 } | 387 } |
| 370 | 388 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 423 |
| 406 int this_rid = 0; | 424 int this_rid = 0; |
| 407 record->GetInteger("rid", &this_rid); | 425 record->GetInteger("rid", &this_rid); |
| 408 | 426 |
| 409 if (this_rid == render_process_id) { | 427 if (this_rid == render_process_id) { |
| 410 if (observers_.might_have_observers()) { | 428 if (observers_.might_have_observers()) { |
| 411 int lid = 0, pid = 0; | 429 int lid = 0, pid = 0; |
| 412 record->GetInteger("lid", &lid); | 430 record->GetInteger("lid", &lid); |
| 413 record->GetInteger("pid", &pid); | 431 record->GetInteger("pid", &pid); |
| 414 | 432 |
| 415 base::DictionaryValue update; | 433 scoped_ptr<base::DictionaryValue> update(new base::DictionaryValue()); |
| 416 update.SetInteger("lid", lid); | 434 update->SetInteger("lid", lid); |
| 417 update.SetInteger("pid", pid); | 435 update->SetInteger("pid", pid); |
| 418 SendUpdate("removePeerConnection", &update); | 436 SendUpdate("removePeerConnection", std::move(update)); |
| 419 } | 437 } |
| 420 peer_connection_data_.Remove(i, NULL); | 438 peer_connection_data_.Remove(i, NULL); |
| 421 } | 439 } |
| 422 } | 440 } |
| 423 CreateOrReleasePowerSaveBlocker(); | 441 CreateOrReleasePowerSaveBlocker(); |
| 424 | 442 |
| 425 bool found_any = false; | 443 bool found_any = false; |
| 426 // Iterates from the end of the list to remove the getUserMedia requests | 444 // Iterates from the end of the list to remove the getUserMedia requests |
| 427 // created by the exiting renderer. | 445 // created by the exiting renderer. |
| 428 for (int i = get_user_media_requests_.GetSize() - 1; i >= 0; --i) { | 446 for (int i = get_user_media_requests_.GetSize() - 1; i >= 0; --i) { |
| 429 base::DictionaryValue* record = NULL; | 447 base::DictionaryValue* record = NULL; |
| 430 get_user_media_requests_.GetDictionary(i, &record); | 448 get_user_media_requests_.GetDictionary(i, &record); |
| 431 | 449 |
| 432 int this_rid = 0; | 450 int this_rid = 0; |
| 433 record->GetInteger("rid", &this_rid); | 451 record->GetInteger("rid", &this_rid); |
| 434 | 452 |
| 435 if (this_rid == render_process_id) { | 453 if (this_rid == render_process_id) { |
| 436 get_user_media_requests_.Remove(i, NULL); | 454 get_user_media_requests_.Remove(i, NULL); |
| 437 found_any = true; | 455 found_any = true; |
| 438 } | 456 } |
| 439 } | 457 } |
| 440 | 458 |
| 441 if (found_any && observers_.might_have_observers()) { | 459 if (found_any && observers_.might_have_observers()) { |
| 442 base::DictionaryValue update; | 460 scoped_ptr<base::DictionaryValue> update(new base::DictionaryValue()); |
| 443 update.SetInteger("rid", render_process_id); | 461 update->SetInteger("rid", render_process_id); |
| 444 SendUpdate("removeGetUserMediaForRenderer", &update); | 462 SendUpdate("removeGetUserMediaForRenderer", std::move(update)); |
| 445 } | 463 } |
| 446 } | 464 } |
| 447 | 465 |
| 448 #if defined(ENABLE_WEBRTC) | 466 #if defined(ENABLE_WEBRTC) |
| 449 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { | 467 void WebRTCInternals::EnableAudioDebugRecordingsOnAllRenderProcessHosts() { |
| 450 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 468 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 451 | 469 |
| 452 audio_debug_recordings_ = true; | 470 audio_debug_recordings_ = true; |
| 453 for (RenderProcessHost::iterator i( | 471 for (RenderProcessHost::iterator i( |
| 454 content::RenderProcessHost::AllHostsIterator()); | 472 content::RenderProcessHost::AllHostsIterator()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 480 power_save_blocker_.reset(); | 498 power_save_blocker_.reset(); |
| 481 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { | 499 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { |
| 482 DVLOG(1) << ("Preventing the application from being suspended while one or " | 500 DVLOG(1) << ("Preventing the application from being suspended while one or " |
| 483 "more PeerConnections are active."); | 501 "more PeerConnections are active."); |
| 484 power_save_blocker_ = content::PowerSaveBlocker::Create( | 502 power_save_blocker_ = content::PowerSaveBlocker::Create( |
| 485 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 503 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 486 PowerSaveBlocker::kReasonOther, "WebRTC has active PeerConnections"); | 504 PowerSaveBlocker::kReasonOther, "WebRTC has active PeerConnections"); |
| 487 } | 505 } |
| 488 } | 506 } |
| 489 | 507 |
| 508 void WebRTCInternals::ProcessPendingUpdates() { |
| 509 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 510 while (!pending_updates_.empty()) { |
| 511 const auto& update = pending_updates_.front(); |
| 512 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, |
| 513 observers_, |
| 514 OnUpdate(update.command(), update.value())); |
| 515 pending_updates_.pop(); |
| 516 } |
| 517 } |
| 518 |
| 490 } // namespace content | 519 } // namespace content |
| OLD | NEW |