| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 0, id); | 1508 0, id); |
| 1509 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); | 1509 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| 1510 return; | 1510 return; |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 #if defined(OS_MACOSX) | 1513 #if defined(OS_MACOSX) |
| 1514 // MacOS version of underlying GrabViewSnapshot() blocks while | 1514 // MacOS version of underlying GrabViewSnapshot() blocks while |
| 1515 // display/GPU are in a power-saving mode, so make sure display | 1515 // display/GPU are in a power-saving mode, so make sure display |
| 1516 // does not go to sleep for the duration of reading a snapshot. | 1516 // does not go to sleep for the duration of reading a snapshot. |
| 1517 if (pending_browser_snapshots_.empty()) | 1517 if (pending_browser_snapshots_.empty()) |
| 1518 GetWakeLockService()->RequestWakeLock(); | 1518 GetWakeLock()->RequestWakeLock(); |
| 1519 #endif | 1519 #endif |
| 1520 pending_browser_snapshots_.insert(std::make_pair(id, callback)); | 1520 pending_browser_snapshots_.insert(std::make_pair(id, callback)); |
| 1521 ui::LatencyInfo latency_info; | 1521 ui::LatencyInfo latency_info; |
| 1522 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, | 1522 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, |
| 1523 id); | 1523 id); |
| 1524 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); | 1524 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 const NativeWebKeyboardEvent* | 1527 const NativeWebKeyboardEvent* |
| 1528 RenderWidgetHostImpl::GetLastKeyboardEvent() const { | 1528 RenderWidgetHostImpl::GetLastKeyboardEvent() const { |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 while (it != pending_browser_snapshots_.end()) { | 2454 while (it != pending_browser_snapshots_.end()) { |
| 2455 if (it->first <= snapshot_id) { | 2455 if (it->first <= snapshot_id) { |
| 2456 it->second.Run(image); | 2456 it->second.Run(image); |
| 2457 pending_browser_snapshots_.erase(it++); | 2457 pending_browser_snapshots_.erase(it++); |
| 2458 } else { | 2458 } else { |
| 2459 ++it; | 2459 ++it; |
| 2460 } | 2460 } |
| 2461 } | 2461 } |
| 2462 #if defined(OS_MACOSX) | 2462 #if defined(OS_MACOSX) |
| 2463 if (pending_browser_snapshots_.empty()) | 2463 if (pending_browser_snapshots_.empty()) |
| 2464 GetWakeLockService()->CancelWakeLock(); | 2464 GetWakeLock()->CancelWakeLock(); |
| 2465 #endif | 2465 #endif |
| 2466 } | 2466 } |
| 2467 | 2467 |
| 2468 // static | 2468 // static |
| 2469 void RenderWidgetHostImpl::OnGpuSwapBuffersCompleted( | 2469 void RenderWidgetHostImpl::OnGpuSwapBuffersCompleted( |
| 2470 const std::vector<ui::LatencyInfo>& latency_info) { | 2470 const std::vector<ui::LatencyInfo>& latency_info) { |
| 2471 for (size_t i = 0; i < latency_info.size(); i++) { | 2471 for (size_t i = 0; i < latency_info.size(); i++) { |
| 2472 std::set<RenderWidgetHostImpl*> rwhi_set; | 2472 std::set<RenderWidgetHostImpl*> rwhi_set; |
| 2473 for (const auto& lc : latency_info[i].latency_components()) { | 2473 for (const auto& lc : latency_info[i].latency_components()) { |
| 2474 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || | 2474 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 RenderProcessHost* rph = GetProcess(); | 2636 RenderProcessHost* rph = GetProcess(); |
| 2637 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); | 2637 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); |
| 2638 i != messages.end(); ++i) { | 2638 i != messages.end(); ++i) { |
| 2639 rph->OnMessageReceived(*i); | 2639 rph->OnMessageReceived(*i); |
| 2640 if (i->dispatch_error()) | 2640 if (i->dispatch_error()) |
| 2641 rph->OnBadMessageReceived(*i); | 2641 rph->OnBadMessageReceived(*i); |
| 2642 } | 2642 } |
| 2643 } | 2643 } |
| 2644 | 2644 |
| 2645 #if defined(OS_MACOSX) | 2645 #if defined(OS_MACOSX) |
| 2646 device::mojom::WakeLockService* RenderWidgetHostImpl::GetWakeLockService() { | 2646 device::mojom::WakeLock* RenderWidgetHostImpl::GetWakeLock() { |
| 2647 // Here is a lazy binding, and will not reconnect after connection error. | 2647 // Here is a lazy binding, and will not reconnect after connection error. |
| 2648 if (!wake_lock_) { | 2648 if (!wake_lock_) { |
| 2649 device::mojom::WakeLockServiceRequest request = | 2649 device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_); |
| 2650 mojo::MakeRequest(&wake_lock_); | |
| 2651 // In some testing contexts, the service manager connection isn't | 2650 // In some testing contexts, the service manager connection isn't |
| 2652 // initialized. | 2651 // initialized. |
| 2653 if (ServiceManagerConnection::GetForProcess()) { | 2652 if (ServiceManagerConnection::GetForProcess()) { |
| 2654 service_manager::Connector* connector = | 2653 service_manager::Connector* connector = |
| 2655 ServiceManagerConnection::GetForProcess()->GetConnector(); | 2654 ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 2656 DCHECK(connector); | 2655 DCHECK(connector); |
| 2657 device::mojom::WakeLockProviderPtr wake_lock_provider; | 2656 device::mojom::WakeLockProviderPtr wake_lock_provider; |
| 2658 connector->BindInterface(device::mojom::kServiceName, | 2657 connector->BindInterface(device::mojom::kServiceName, |
| 2659 mojo::MakeRequest(&wake_lock_provider)); | 2658 mojo::MakeRequest(&wake_lock_provider)); |
| 2660 wake_lock_provider->GetWakeLockWithoutContext( | 2659 wake_lock_provider->GetWakeLockWithoutContext( |
| 2661 device::mojom::WakeLockType::PreventDisplaySleep, | 2660 device::mojom::WakeLockType::PreventDisplaySleep, |
| 2662 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", | 2661 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", |
| 2663 std::move(request)); | 2662 std::move(request)); |
| 2664 } | 2663 } |
| 2665 } | 2664 } |
| 2666 return wake_lock_.get(); | 2665 return wake_lock_.get(); |
| 2667 } | 2666 } |
| 2668 #endif | 2667 #endif |
| 2669 | 2668 |
| 2670 } // namespace content | 2669 } // namespace content |
| OLD | NEW |