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/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_eventlog_callback_handler.h" |
11 #include "content/browser/media/webrtc/webrtc_internals_ui_observer.h" | 12 #include "content/browser/media/webrtc/webrtc_internals_ui_observer.h" |
| 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
12 #include "content/browser/web_contents/web_contents_view.h" | 14 #include "content/browser/web_contents/web_contents_view.h" |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
15 #include "content/public/browser/power_save_blocker.h" | 17 #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" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "ipc/ipc_platform_file.h" |
| 20 |
| 21 #if defined(OS_WIN) |
| 22 #define IntToStringType base::IntToString16 |
| 23 #else |
| 24 #define IntToStringType base::IntToString |
| 25 #endif |
18 | 26 |
19 using base::ProcessId; | 27 using base::ProcessId; |
20 using std::string; | 28 using std::string; |
21 | 29 |
22 namespace content { | 30 namespace content { |
23 | 31 |
24 namespace { | 32 namespace { |
25 | 33 |
26 static base::LazyInstance<WebRTCInternals>::Leaky g_webrtc_internals = | 34 static base::LazyInstance<WebRTCInternals>::Leaky g_webrtc_internals = |
27 LAZY_INSTANCE_INITIALIZER; | 35 LAZY_INSTANCE_INITIALIZER; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 349 } else { |
342 event_log_recordings_ = false; | 350 event_log_recordings_ = false; |
343 // Tear down the dialog since the user has unchecked the audio debug | 351 // Tear down the dialog since the user has unchecked the audio debug |
344 // recordings box. | 352 // recordings box. |
| 353 DCHECK(select_file_dialog_->HasOneRef()); |
345 select_file_dialog_ = nullptr; | 354 select_file_dialog_ = nullptr; |
346 DCHECK(select_file_dialog_->HasOneRef()); | |
347 | 355 |
348 for (RenderProcessHost::iterator i( | 356 for (RenderProcessHost::iterator i( |
349 content::RenderProcessHost::AllHostsIterator()); | 357 content::RenderProcessHost::AllHostsIterator()); |
350 !i.IsAtEnd(); i.Advance()) { | 358 !i.IsAtEnd(); i.Advance()) { |
351 i.GetCurrentValue()->DisableEventLogRecordings(); | 359 RenderProcessHostImpl* rph = |
| 360 static_cast<RenderProcessHostImpl*>(i.GetCurrentValue()); |
| 361 rph->SignalStopEventLog(); |
352 } | 362 } |
353 } | 363 } |
354 #endif | 364 #endif |
355 } | 365 } |
356 | 366 |
357 bool WebRTCInternals::IsEventLogRecordingsEnabled() const { | 367 bool WebRTCInternals::IsEventLogRecordingsEnabled() const { |
358 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 368 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
359 return event_log_recordings_; | 369 return event_log_recordings_; |
360 } | 370 } |
361 | 371 |
362 const base::FilePath& WebRTCInternals::GetEventLogRecordingsFilePath() const { | |
363 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
364 return event_log_recordings_file_path_; | |
365 } | |
366 | |
367 void WebRTCInternals::SendUpdate(const string& command, | 372 void WebRTCInternals::SendUpdate(const string& command, |
368 std::unique_ptr<base::Value> value) { | 373 std::unique_ptr<base::Value> value) { |
369 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 374 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
370 DCHECK(observers_.might_have_observers()); | 375 DCHECK(observers_.might_have_observers()); |
371 | 376 |
372 bool queue_was_empty = pending_updates_.empty(); | 377 bool queue_was_empty = pending_updates_.empty(); |
373 pending_updates_.push(PendingUpdate(command, std::move(value))); | 378 pending_updates_.push(PendingUpdate(command, std::move(value))); |
374 | 379 |
375 if (queue_was_empty) { | 380 if (queue_was_empty) { |
376 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 381 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 484 } |
480 } | 485 } |
481 | 486 |
482 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { | 487 void WebRTCInternals::EnableEventLogRecordingsOnAllRenderProcessHosts() { |
483 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 488 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
484 | 489 |
485 event_log_recordings_ = true; | 490 event_log_recordings_ = true; |
486 for (RenderProcessHost::iterator i( | 491 for (RenderProcessHost::iterator i( |
487 content::RenderProcessHost::AllHostsIterator()); | 492 content::RenderProcessHost::AllHostsIterator()); |
488 !i.IsAtEnd(); i.Advance()) { | 493 !i.IsAtEnd(); i.Advance()) { |
489 i.GetCurrentValue()->EnableEventLogRecordings( | 494 RenderProcessHostImpl* rph = |
490 event_log_recordings_file_path_); | 495 static_cast<RenderProcessHostImpl*>(i.GetCurrentValue()); |
| 496 rph->SignalStartEventLog(event_log_recordings_file_path_); |
491 } | 497 } |
492 } | 498 } |
493 #endif | 499 #endif |
494 | 500 |
495 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { | 501 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { |
496 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 502 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
497 | 503 |
498 if (peer_connection_data_.empty() && power_save_blocker_) { | 504 if (peer_connection_data_.empty() && power_save_blocker_) { |
499 DVLOG(1) << ("Releasing the block on application suspension since no " | 505 DVLOG(1) << ("Releasing the block on application suspension since no " |
500 "PeerConnections are active anymore."); | 506 "PeerConnections are active anymore."); |
(...skipping 12 matching lines...) Expand all Loading... |
513 while (!pending_updates_.empty()) { | 519 while (!pending_updates_.empty()) { |
514 const auto& update = pending_updates_.front(); | 520 const auto& update = pending_updates_.front(); |
515 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, | 521 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, |
516 observers_, | 522 observers_, |
517 OnUpdate(update.command(), update.value())); | 523 OnUpdate(update.command(), update.value())); |
518 pending_updates_.pop(); | 524 pending_updates_.pop(); |
519 } | 525 } |
520 } | 526 } |
521 | 527 |
522 } // namespace content | 528 } // namespace content |
OLD | NEW |