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