| 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/webrtc/webrtc_internals.h" | 5 #include "content/browser/webrtc/webrtc_internals.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 542 |
| 543 void WebRTCInternals::UpdateWakeLock() { | 543 void WebRTCInternals::UpdateWakeLock() { |
| 544 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 544 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 545 if (!should_block_power_saving_) | 545 if (!should_block_power_saving_) |
| 546 return; | 546 return; |
| 547 | 547 |
| 548 if (num_open_connections_ == 0) { | 548 if (num_open_connections_ == 0) { |
| 549 DVLOG(1) | 549 DVLOG(1) |
| 550 << ("Cancel the wake lock on application suspension since no " | 550 << ("Cancel the wake lock on application suspension since no " |
| 551 "PeerConnections are active anymore."); | 551 "PeerConnections are active anymore."); |
| 552 GetWakeLockService()->CancelWakeLock(); | 552 GetWakeLock()->CancelWakeLock(); |
| 553 } else if (num_open_connections_ != 0) { | 553 } else if (num_open_connections_ != 0) { |
| 554 DVLOG(1) << ("Preventing the application from being suspended while one or " | 554 DVLOG(1) << ("Preventing the application from being suspended while one or " |
| 555 "more PeerConnections are active."); | 555 "more PeerConnections are active."); |
| 556 GetWakeLockService()->RequestWakeLock(); | 556 GetWakeLock()->RequestWakeLock(); |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 device::mojom::WakeLockService* WebRTCInternals::GetWakeLockService() { | 560 device::mojom::WakeLock* WebRTCInternals::GetWakeLock() { |
| 561 // Here is a lazy binding, and will not reconnect after connection error. | 561 // Here is a lazy binding, and will not reconnect after connection error. |
| 562 if (!wake_lock_service_) { | 562 if (!wake_lock_) { |
| 563 device::mojom::WakeLockServiceRequest request = | 563 device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_); |
| 564 mojo::MakeRequest(&wake_lock_service_); | |
| 565 // In some testing contexts, the service manager connection isn't | 564 // In some testing contexts, the service manager connection isn't |
| 566 // initialized. | 565 // initialized. |
| 567 if (ServiceManagerConnection::GetForProcess()) { | 566 if (ServiceManagerConnection::GetForProcess()) { |
| 568 service_manager::Connector* connector = | 567 service_manager::Connector* connector = |
| 569 ServiceManagerConnection::GetForProcess()->GetConnector(); | 568 ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 570 DCHECK(connector); | 569 DCHECK(connector); |
| 571 device::mojom::WakeLockProviderPtr wake_lock_provider; | 570 device::mojom::WakeLockProviderPtr wake_lock_provider; |
| 572 connector->BindInterface(device::mojom::kServiceName, | 571 connector->BindInterface(device::mojom::kServiceName, |
| 573 mojo::MakeRequest(&wake_lock_provider)); | 572 mojo::MakeRequest(&wake_lock_provider)); |
| 574 wake_lock_provider->GetWakeLockWithoutContext( | 573 wake_lock_provider->GetWakeLockWithoutContext( |
| 575 device::mojom::WakeLockType::PreventAppSuspension, | 574 device::mojom::WakeLockType::PreventAppSuspension, |
| 576 device::mojom::WakeLockReason::ReasonOther, | 575 device::mojom::WakeLockReason::ReasonOther, |
| 577 "WebRTC has active PeerConnections", std::move(request)); | 576 "WebRTC has active PeerConnections", std::move(request)); |
| 578 } | 577 } |
| 579 } | 578 } |
| 580 return wake_lock_service_.get(); | 579 return wake_lock_.get(); |
| 581 } | 580 } |
| 582 | 581 |
| 583 void WebRTCInternals::ProcessPendingUpdates() { | 582 void WebRTCInternals::ProcessPendingUpdates() { |
| 584 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 583 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 585 while (!pending_updates_.empty()) { | 584 while (!pending_updates_.empty()) { |
| 586 const auto& update = pending_updates_.front(); | 585 const auto& update = pending_updates_.front(); |
| 587 for (auto& observer : observers_) | 586 for (auto& observer : observers_) |
| 588 observer.OnUpdate(update.command(), update.value()); | 587 observer.OnUpdate(update.command(), update.value()); |
| 589 pending_updates_.pop(); | 588 pending_updates_.pop(); |
| 590 } | 589 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 606 | 605 |
| 607 if (this_pid == static_cast<int>(pid) && this_lid == lid) { | 606 if (this_pid == static_cast<int>(pid) && this_lid == lid) { |
| 608 if (index) | 607 if (index) |
| 609 *index = i; | 608 *index = i; |
| 610 return record; | 609 return record; |
| 611 } | 610 } |
| 612 } | 611 } |
| 613 return nullptr; | 612 return nullptr; |
| 614 } | 613 } |
| 615 } // namespace content | 614 } // namespace content |
| OLD | NEW |