Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: content/browser/media/webrtc/webrtc_internals.cc

Issue 1855193002: Move the call to enable the WebRTC event log from PeerConnectionFactory to PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from Henrik and enabled logging for newly created render processes. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/webrtc_internals.h" 5 #include "content/browser/media/webrtc/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"
11 #include "content/browser/media/webrtc/webrtc_internals_ui_observer.h" 11 #include "content/browser/media/webrtc/webrtc_internals_ui_observer.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h"
12 #include "content/browser/web_contents/web_contents_view.h" 13 #include "content/browser/web_contents/web_contents_view.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/content_browser_client.h" 15 #include "content/public/browser/content_browser_client.h"
15 #include "content/public/browser/power_save_blocker.h" 16 #include "content/public/browser/power_save_blocker.h"
16 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "ipc/ipc_platform_file.h"
19
20 #if defined(OS_WIN)
21 #define IntToStringType base::IntToString16
22 #else
23 #define IntToStringType base::IntToString
24 #endif
18 25
19 using base::ProcessId; 26 using base::ProcessId;
20 using std::string; 27 using std::string;
21 28
22 namespace content { 29 namespace content {
23 30
24 namespace { 31 namespace {
25 32
26 static base::LazyInstance<WebRTCInternals>::Leaky g_webrtc_internals = 33 static base::LazyInstance<WebRTCInternals>::Leaky g_webrtc_internals =
27 LAZY_INSTANCE_INITIALIZER; 34 LAZY_INSTANCE_INITIALIZER;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 252
246 void WebRTCInternals::AddObserver(WebRTCInternalsUIObserver* observer) { 253 void WebRTCInternals::AddObserver(WebRTCInternalsUIObserver* observer) {
247 DCHECK_CURRENTLY_ON(BrowserThread::UI); 254 DCHECK_CURRENTLY_ON(BrowserThread::UI);
248 observers_.AddObserver(observer); 255 observers_.AddObserver(observer);
249 } 256 }
250 257
251 void WebRTCInternals::RemoveObserver(WebRTCInternalsUIObserver* observer) { 258 void WebRTCInternals::RemoveObserver(WebRTCInternalsUIObserver* observer) {
252 DCHECK_CURRENTLY_ON(BrowserThread::UI); 259 DCHECK_CURRENTLY_ON(BrowserThread::UI);
253 observers_.RemoveObserver(observer); 260 observers_.RemoveObserver(observer);
254 261
255 // Disables audio debug recordings if it is enabled and the last 262 // Disables event log and audio debug recordings if enabled and the last
256 // webrtc-internals page is going away. 263 // webrtc-internals page is going away.
257 if (audio_debug_recordings_ && !observers_.might_have_observers()) 264 if (!observers_.might_have_observers()) {
258 DisableAudioDebugRecordings(); 265 if (audio_debug_recordings_)
266 DisableAudioDebugRecordings();
267 DisableEventLogRecordings();
268 }
259 } 269 }
260 270
261 void WebRTCInternals::UpdateObserver(WebRTCInternalsUIObserver* observer) { 271 void WebRTCInternals::UpdateObserver(WebRTCInternalsUIObserver* observer) {
262 DCHECK_CURRENTLY_ON(BrowserThread::UI); 272 DCHECK_CURRENTLY_ON(BrowserThread::UI);
263 if (peer_connection_data_.GetSize() > 0) 273 if (peer_connection_data_.GetSize() > 0)
264 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_); 274 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_);
265 275
266 for (base::ListValue::iterator it = get_user_media_requests_.begin(); 276 for (base::ListValue::iterator it = get_user_media_requests_.begin();
267 it != get_user_media_requests_.end(); 277 it != get_user_media_requests_.end();
268 ++it) { 278 ++it) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const { 323 bool WebRTCInternals::IsAudioDebugRecordingsEnabled() const {
314 DCHECK_CURRENTLY_ON(BrowserThread::UI); 324 DCHECK_CURRENTLY_ON(BrowserThread::UI);
315 return audio_debug_recordings_; 325 return audio_debug_recordings_;
316 } 326 }
317 327
318 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const { 328 const base::FilePath& WebRTCInternals::GetAudioDebugRecordingsFilePath() const {
319 DCHECK_CURRENTLY_ON(BrowserThread::UI); 329 DCHECK_CURRENTLY_ON(BrowserThread::UI);
320 return audio_debug_recordings_file_path_; 330 return audio_debug_recordings_file_path_;
321 } 331 }
322 332
323 void WebRTCInternals::SetEventLogRecordings( 333 void WebRTCInternals::EnableEventLogRecordings(
324 bool enable,
325 content::WebContents* web_contents) { 334 content::WebContents* web_contents) {
326 DCHECK_CURRENTLY_ON(BrowserThread::UI); 335 DCHECK_CURRENTLY_ON(BrowserThread::UI);
327 #if defined(ENABLE_WEBRTC) 336 #if defined(ENABLE_WEBRTC)
328 if (enable) {
329 #if defined(OS_ANDROID) 337 #if defined(OS_ANDROID)
330 EnableEventLogRecordingsOnAllRenderProcessHosts(); 338 EnableEventLogRecordingsOnAllRenderProcessHosts();
331 #else 339 #else
332 DCHECK(web_contents); 340 DCHECK(web_contents);
333 DCHECK(select_file_dialog_ == nullptr); 341 DCHECK(select_file_dialog_ == nullptr);
334 selecting_event_log_ = true; 342 selecting_event_log_ = true;
335 select_file_dialog_ = ui::SelectFileDialog::Create(this, nullptr); 343 select_file_dialog_ = ui::SelectFileDialog::Create(this, nullptr);
336 select_file_dialog_->SelectFile( 344 select_file_dialog_->SelectFile(
337 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(), 345 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(),
338 event_log_recordings_file_path_, nullptr, 0, FILE_PATH_LITERAL(""), 346 event_log_recordings_file_path_, nullptr, 0, FILE_PATH_LITERAL(""),
339 web_contents->GetTopLevelNativeWindow(), nullptr); 347 web_contents->GetTopLevelNativeWindow(), nullptr);
340 #endif 348 #endif
341 } else {
342 event_log_recordings_ = false;
343 // Tear down the dialog since the user has unchecked the audio debug
344 // recordings box.
345 select_file_dialog_ = nullptr;
346 DCHECK(select_file_dialog_->HasOneRef());
347
348 for (RenderProcessHost::iterator i(
349 content::RenderProcessHost::AllHostsIterator());
350 !i.IsAtEnd(); i.Advance()) {
351 i.GetCurrentValue()->DisableEventLogRecordings();
352 }
353 }
354 #endif 349 #endif
355 } 350 }
356 351
352 void WebRTCInternals::DisableEventLogRecordings() {
353 #if defined(ENABLE_WEBRTC)
354 event_log_recordings_ = false;
355 // Tear down the dialog since the user has unchecked the event log checkbox.
Henrik Grunell 2016/06/03 07:40:53 Nit: Is the DCHECK for one ref not useful anymore?
Ivo-OOO until feb 6 2016/06/03 16:07:02 The DCHECK is problematic because the file dialog
Henrik Grunell 2016/06/08 10:08:50 Acknowledged.
356 select_file_dialog_ = nullptr;
357 for (RenderProcessHost::iterator i(
358 content::RenderProcessHost::AllHostsIterator());
359 !i.IsAtEnd(); i.Advance())
360 i.GetCurrentValue()->StopWebRTCEventLog();
361 #endif
362 }
363
357 bool WebRTCInternals::IsEventLogRecordingsEnabled() const { 364 bool WebRTCInternals::IsEventLogRecordingsEnabled() const {
358 DCHECK_CURRENTLY_ON(BrowserThread::UI); 365 DCHECK_CURRENTLY_ON(BrowserThread::UI);
359 return event_log_recordings_; 366 return event_log_recordings_;
360 } 367 }
361 368
362 const base::FilePath& WebRTCInternals::GetEventLogRecordingsFilePath() const { 369 const base::FilePath& WebRTCInternals::GetEventLogFilePath() const {
363 DCHECK_CURRENTLY_ON(BrowserThread::UI); 370 DCHECK_CURRENTLY_ON(BrowserThread::UI);
364 return event_log_recordings_file_path_; 371 return event_log_recordings_file_path_;
365 } 372 }
366 373
367 void WebRTCInternals::SendUpdate(const string& command, 374 void WebRTCInternals::SendUpdate(const string& command,
368 std::unique_ptr<base::Value> value) { 375 std::unique_ptr<base::Value> value) {
369 DCHECK_CURRENTLY_ON(BrowserThread::UI); 376 DCHECK_CURRENTLY_ON(BrowserThread::UI);
370 DCHECK(observers_.might_have_observers()); 377 DCHECK(observers_.might_have_observers());
371 378
372 bool queue_was_empty = pending_updates_.empty(); 379 bool queue_was_empty = pending_updates_.empty();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 audio_debug_recordings_file_path_); 485 audio_debug_recordings_file_path_);
479 } 486 }
480 } 487 }
481 488
482 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { 489 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() {
483 DCHECK_CURRENTLY_ON(BrowserThread::UI); 490 DCHECK_CURRENTLY_ON(BrowserThread::UI);
484 491
485 event_log_recordings_ = true; 492 event_log_recordings_ = true;
486 for (RenderProcessHost::iterator i( 493 for (RenderProcessHost::iterator i(
487 content::RenderProcessHost::AllHostsIterator()); 494 content::RenderProcessHost::AllHostsIterator());
488 !i.IsAtEnd(); i.Advance()) { 495 !i.IsAtEnd(); i.Advance())
489 i.GetCurrentValue()->EnableEventLogRecordings( 496 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_);
490 event_log_recordings_file_path_);
491 }
492 } 497 }
493 #endif 498 #endif
494 499
495 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { 500 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() {
496 DCHECK_CURRENTLY_ON(BrowserThread::UI); 501 DCHECK_CURRENTLY_ON(BrowserThread::UI);
497 502
498 if (peer_connection_data_.empty() && power_save_blocker_) { 503 if (peer_connection_data_.empty() && power_save_blocker_) {
499 DVLOG(1) << ("Releasing the block on application suspension since no " 504 DVLOG(1) << ("Releasing the block on application suspension since no "
500 "PeerConnections are active anymore."); 505 "PeerConnections are active anymore.");
501 power_save_blocker_.reset(); 506 power_save_blocker_.reset();
(...skipping 11 matching lines...) Expand all
513 while (!pending_updates_.empty()) { 518 while (!pending_updates_.empty()) {
514 const auto& update = pending_updates_.front(); 519 const auto& update = pending_updates_.front();
515 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, 520 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver,
516 observers_, 521 observers_,
517 OnUpdate(update.command(), update.value())); 522 OnUpdate(update.command(), update.value()));
518 pending_updates_.pop(); 523 pending_updates_.pop();
519 } 524 }
520 } 525 }
521 526
522 } // namespace content 527 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698