| 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/devtools/render_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (pending_) | 597 if (pending_) |
| 598 pending_->InspectElement(session->session_id(), x, y); | 598 pending_->InspectElement(session->session_id(), x, y); |
| 599 } | 599 } |
| 600 | 600 |
| 601 void RenderFrameDevToolsAgentHost::OnClientAttached() { | 601 void RenderFrameDevToolsAgentHost::OnClientAttached() { |
| 602 if (!web_contents()) | 602 if (!web_contents()) |
| 603 return; | 603 return; |
| 604 | 604 |
| 605 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); | 605 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); |
| 606 #if defined(OS_ANDROID) | 606 #if defined(OS_ANDROID) |
| 607 GetWakeLockService()->RequestWakeLock(); | 607 GetWakeLock()->RequestWakeLock(); |
| 608 #endif | 608 #endif |
| 609 } | 609 } |
| 610 | 610 |
| 611 void RenderFrameDevToolsAgentHost::OnClientDetached() { | 611 void RenderFrameDevToolsAgentHost::OnClientDetached() { |
| 612 #if defined(OS_ANDROID) | 612 #if defined(OS_ANDROID) |
| 613 GetWakeLockService()->CancelWakeLock(); | 613 GetWakeLock()->CancelWakeLock(); |
| 614 #endif | 614 #endif |
| 615 frame_trace_recorder_.reset(); | 615 frame_trace_recorder_.reset(); |
| 616 in_navigation_protocol_message_buffer_.clear(); | 616 in_navigation_protocol_message_buffer_.clear(); |
| 617 } | 617 } |
| 618 | 618 |
| 619 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 619 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { |
| 620 Instances::iterator it = std::find(g_instances.Get().begin(), | 620 Instances::iterator it = std::find(g_instances.Get().begin(), |
| 621 g_instances.Get().end(), | 621 g_instances.Get().end(), |
| 622 this); | 622 this); |
| 623 if (it != g_instances.Get().end()) | 623 if (it != g_instances.Get().end()) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 if (IsBrowserSideNavigationEnabled()) | 819 if (IsBrowserSideNavigationEnabled()) |
| 820 return true; | 820 return true; |
| 821 if (!frame_tree_node_) | 821 if (!frame_tree_node_) |
| 822 return !handlers_frame_host_; | 822 return !handlers_frame_host_; |
| 823 RenderFrameHostManager* manager = frame_tree_node_->render_manager(); | 823 RenderFrameHostManager* manager = frame_tree_node_->render_manager(); |
| 824 return handlers_frame_host_ == manager->current_frame_host() || | 824 return handlers_frame_host_ == manager->current_frame_host() || |
| 825 handlers_frame_host_ == manager->pending_frame_host(); | 825 handlers_frame_host_ == manager->pending_frame_host(); |
| 826 } | 826 } |
| 827 | 827 |
| 828 #if defined(OS_ANDROID) | 828 #if defined(OS_ANDROID) |
| 829 device::mojom::WakeLockService* | 829 device::mojom::WakeLock* RenderFrameDevToolsAgentHost::GetWakeLock() { |
| 830 RenderFrameDevToolsAgentHost::GetWakeLockService() { | |
| 831 // Here is a lazy binding, and will not reconnect after connection error. | 830 // Here is a lazy binding, and will not reconnect after connection error. |
| 832 if (!wake_lock_) { | 831 if (!wake_lock_) { |
| 833 device::mojom::WakeLockServiceRequest request = | 832 device::mojom::WakeLockRequest request = mojo::MakeRequest(&wake_lock_); |
| 834 mojo::MakeRequest(&wake_lock_); | |
| 835 device::mojom::WakeLockContext* wake_lock_context = | 833 device::mojom::WakeLockContext* wake_lock_context = |
| 836 web_contents()->GetWakeLockContext(); | 834 web_contents()->GetWakeLockContext(); |
| 837 if (wake_lock_context) { | 835 if (wake_lock_context) { |
| 838 wake_lock_context->GetWakeLock( | 836 wake_lock_context->GetWakeLock( |
| 839 device::mojom::WakeLockType::PreventDisplaySleep, | 837 device::mojom::WakeLockType::PreventDisplaySleep, |
| 840 device::mojom::WakeLockReason::ReasonOther, "DevTools", | 838 device::mojom::WakeLockReason::ReasonOther, "DevTools", |
| 841 std::move(request)); | 839 std::move(request)); |
| 842 } | 840 } |
| 843 } | 841 } |
| 844 return wake_lock_.get(); | 842 return wake_lock_.get(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 DCHECK(CheckConsistency()); | 905 DCHECK(CheckConsistency()); |
| 908 } | 906 } |
| 909 | 907 |
| 910 void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() { | 908 void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() { |
| 911 for (auto* page : protocol::PageHandler::ForAgentHost(this)) | 909 for (auto* page : protocol::PageHandler::ForAgentHost(this)) |
| 912 page->DidDetachInterstitialPage(); | 910 page->DidDetachInterstitialPage(); |
| 913 } | 911 } |
| 914 | 912 |
| 915 void RenderFrameDevToolsAgentHost::WasShown() { | 913 void RenderFrameDevToolsAgentHost::WasShown() { |
| 916 #if defined(OS_ANDROID) | 914 #if defined(OS_ANDROID) |
| 917 GetWakeLockService()->RequestWakeLock(); | 915 GetWakeLock()->RequestWakeLock(); |
| 918 #endif | 916 #endif |
| 919 } | 917 } |
| 920 | 918 |
| 921 void RenderFrameDevToolsAgentHost::WasHidden() { | 919 void RenderFrameDevToolsAgentHost::WasHidden() { |
| 922 #if defined(OS_ANDROID) | 920 #if defined(OS_ANDROID) |
| 923 GetWakeLockService()->CancelWakeLock(); | 921 GetWakeLock()->CancelWakeLock(); |
| 924 #endif | 922 #endif |
| 925 } | 923 } |
| 926 | 924 |
| 927 void RenderFrameDevToolsAgentHost::DidReceiveCompositorFrame() { | 925 void RenderFrameDevToolsAgentHost::DidReceiveCompositorFrame() { |
| 928 const cc::CompositorFrameMetadata& metadata = | 926 const cc::CompositorFrameMetadata& metadata = |
| 929 RenderWidgetHostImpl::From( | 927 RenderWidgetHostImpl::From( |
| 930 web_contents()->GetRenderViewHost()->GetWidget()) | 928 web_contents()->GetRenderViewHost()->GetWidget()) |
| 931 ->last_frame_metadata(); | 929 ->last_frame_metadata(); |
| 932 for (auto* page : protocol::PageHandler::ForAgentHost(this)) | 930 for (auto* page : protocol::PageHandler::ForAgentHost(this)) |
| 933 page->OnSwapCompositorFrame(metadata.Clone()); | 931 page->OnSwapCompositorFrame(metadata.Clone()); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 RenderFrameHost* host) { | 1177 RenderFrameHost* host) { |
| 1180 return (current_ && current_->host() == host) || | 1178 return (current_ && current_->host() == host) || |
| 1181 (pending_ && pending_->host() == host); | 1179 (pending_ && pending_->host() == host); |
| 1182 } | 1180 } |
| 1183 | 1181 |
| 1184 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1182 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1185 return current_ && current_->host()->GetParent(); | 1183 return current_ && current_->host()->GetParent(); |
| 1186 } | 1184 } |
| 1187 | 1185 |
| 1188 } // namespace content | 1186 } // namespace content |
| OLD | NEW |