| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const std::string& WebRTCInternals::PendingUpdate::command() const { | 62 const std::string& WebRTCInternals::PendingUpdate::command() const { |
| 63 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
| 64 return command_; | 64 return command_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const base::Value* WebRTCInternals::PendingUpdate::value() const { | 67 const base::Value* WebRTCInternals::PendingUpdate::value() const { |
| 68 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 69 return value_.get(); | 69 return value_.get(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 WebRTCInternals::WebRTCInternals() : WebRTCInternals(500) {} | 72 WebRTCInternals::WebRTCInternals() : WebRTCInternals(500, true) {} |
| 73 | 73 |
| 74 WebRTCInternals::WebRTCInternals(int aggregate_updates_ms) | 74 WebRTCInternals::WebRTCInternals(int aggregate_updates_ms, |
| 75 bool should_block_power_saving) |
| 75 : audio_debug_recordings_(false), | 76 : audio_debug_recordings_(false), |
| 76 event_log_recordings_(false), | 77 event_log_recordings_(false), |
| 77 selecting_event_log_(false), | 78 selecting_event_log_(false), |
| 79 should_block_power_saving_(should_block_power_saving), |
| 78 aggregate_updates_ms_(aggregate_updates_ms), | 80 aggregate_updates_ms_(aggregate_updates_ms), |
| 79 weak_factory_(this) { | 81 weak_factory_(this) { |
| 80 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the | 82 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the |
| 81 // build if WebRTC is disabled? | 83 // build if WebRTC is disabled? |
| 82 #if defined(ENABLE_WEBRTC) | 84 #if defined(ENABLE_WEBRTC) |
| 83 audio_debug_recordings_file_path_ = | 85 audio_debug_recordings_file_path_ = |
| 84 GetContentClient()->browser()->GetDefaultDownloadDirectory(); | 86 GetContentClient()->browser()->GetDefaultDownloadDirectory(); |
| 85 event_log_recordings_file_path_ = audio_debug_recordings_file_path_; | 87 event_log_recordings_file_path_ = audio_debug_recordings_file_path_; |
| 86 | 88 |
| 87 if (audio_debug_recordings_file_path_.empty()) { | 89 if (audio_debug_recordings_file_path_.empty()) { |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 event_log_recordings_ = true; | 492 event_log_recordings_ = true; |
| 491 for (RenderProcessHost::iterator i( | 493 for (RenderProcessHost::iterator i( |
| 492 content::RenderProcessHost::AllHostsIterator()); | 494 content::RenderProcessHost::AllHostsIterator()); |
| 493 !i.IsAtEnd(); i.Advance()) | 495 !i.IsAtEnd(); i.Advance()) |
| 494 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); | 496 i.GetCurrentValue()->StartWebRTCEventLog(event_log_recordings_file_path_); |
| 495 } | 497 } |
| 496 #endif | 498 #endif |
| 497 | 499 |
| 498 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { | 500 void WebRTCInternals::CreateOrReleasePowerSaveBlocker() { |
| 499 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 501 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 502 if (!should_block_power_saving_) |
| 503 return; |
| 500 | 504 |
| 501 if (peer_connection_data_.empty() && power_save_blocker_) { | 505 if (peer_connection_data_.empty() && power_save_blocker_) { |
| 502 DVLOG(1) << ("Releasing the block on application suspension since no " | 506 DVLOG(1) << ("Releasing the block on application suspension since no " |
| 503 "PeerConnections are active anymore."); | 507 "PeerConnections are active anymore."); |
| 504 power_save_blocker_.reset(); | 508 power_save_blocker_.reset(); |
| 505 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { | 509 } else if (!peer_connection_data_.empty() && !power_save_blocker_) { |
| 506 DVLOG(1) << ("Preventing the application from being suspended while one or " | 510 DVLOG(1) << ("Preventing the application from being suspended while one or " |
| 507 "more PeerConnections are active."); | 511 "more PeerConnections are active."); |
| 508 power_save_blocker_.reset(new device::PowerSaveBlocker( | 512 power_save_blocker_.reset(new device::PowerSaveBlocker( |
| 509 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 513 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 510 device::PowerSaveBlocker::kReasonOther, | 514 device::PowerSaveBlocker::kReasonOther, |
| 511 "WebRTC has active PeerConnections", | 515 "WebRTC has active PeerConnections", |
| 512 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 516 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 513 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); | 517 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); |
| 514 } | 518 } |
| 515 } | 519 } |
| 516 | 520 |
| 517 void WebRTCInternals::ProcessPendingUpdates() { | 521 void WebRTCInternals::ProcessPendingUpdates() { |
| 518 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 522 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 519 while (!pending_updates_.empty()) { | 523 while (!pending_updates_.empty()) { |
| 520 const auto& update = pending_updates_.front(); | 524 const auto& update = pending_updates_.front(); |
| 521 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, | 525 FOR_EACH_OBSERVER(WebRTCInternalsUIObserver, |
| 522 observers_, | 526 observers_, |
| 523 OnUpdate(update.command(), update.value())); | 527 OnUpdate(update.command(), update.value())); |
| 524 pending_updates_.pop(); | 528 pending_updates_.pop(); |
| 525 } | 529 } |
| 526 } | 530 } |
| 527 | 531 |
| 528 } // namespace content | 532 } // namespace content |
| OLD | NEW |