Chromium Code Reviews| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 if (!web_contents()) | 499 if (!web_contents()) |
| 500 return; | 500 return; |
| 501 | 501 |
| 502 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); | 502 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); |
| 503 #if defined(OS_ANDROID) | 503 #if defined(OS_ANDROID) |
| 504 power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>( | 504 power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>( |
| 505 CreatePowerSaveBlocker( | 505 CreatePowerSaveBlocker( |
| 506 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 506 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 507 PowerSaveBlocker::kReasonOther, "DevTools") | 507 PowerSaveBlocker::kReasonOther, "DevTools") |
| 508 .release())); | 508 .release())); |
| 509 power_save_blocker_->InitDisplaySleepBlocker(web_contents()); | 509 if (web_contents()->GetNativeView()) { |
| 510 view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>( | |
| 511 web_contents()->GetNativeView())); | |
| 512 power_save_blocker_->InitDisplaySleepBlocker( | |
| 513 view_weak_factory_->GetWeakPtr()); | |
| 514 } | |
| 510 #endif | 515 #endif |
| 511 | 516 |
| 512 // TODO(kaznacheev): Move this call back to DevToolsManager when | 517 // TODO(kaznacheev): Move this call back to DevToolsManager when |
| 513 // extensions::ProcessManager no longer relies on this notification. | 518 // extensions::ProcessManager no longer relies on this notification. |
| 514 DevToolsAgentHostImpl::NotifyCallbacks(this, true); | 519 DevToolsAgentHostImpl::NotifyCallbacks(this, true); |
| 515 } | 520 } |
| 516 | 521 |
| 517 void RenderFrameDevToolsAgentHost::OnClientDetached() { | 522 void RenderFrameDevToolsAgentHost::OnClientDetached() { |
| 518 #if defined(OS_ANDROID) | 523 #if defined(OS_ANDROID) |
| 519 power_save_blocker_.reset(); | 524 power_save_blocker_.reset(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 const GURL& validated_url, | 751 const GURL& validated_url, |
| 747 int error_code, | 752 int error_code, |
| 748 const base::string16& error_description, | 753 const base::string16& error_description, |
| 749 bool was_ignored_by_handler) { | 754 bool was_ignored_by_handler) { |
| 750 if (IsBrowserSideNavigationEnabled()) | 755 if (IsBrowserSideNavigationEnabled()) |
| 751 return; | 756 return; |
| 752 if (pending_ && pending_->host() == render_frame_host) | 757 if (pending_ && pending_->host() == render_frame_host) |
| 753 DiscardPending(); | 758 DiscardPending(); |
| 754 } | 759 } |
| 755 | 760 |
| 761 void RenderFrameDevToolsAgentHost::WebContentsDestroyed() { | |
| 762 #if defined(OS_ANDROID) | |
| 763 if (view_weak_factory_) | |
|
boliu
2016/06/13 14:56:43
view_weak_factory_.reset(); everywhere?
ncarter (slow)
2016/06/13 16:56:20
I agree with boliu; otherwise you have a dangling
scottmg
2016/06/13 18:52:56
Done.
| |
| 764 view_weak_factory_->InvalidateWeakPtrs(); | |
| 765 #endif | |
| 766 } | |
| 767 | |
| 756 void RenderFrameDevToolsAgentHost:: | 768 void RenderFrameDevToolsAgentHost:: |
| 757 DispatchBufferedProtocolMessagesIfNecessary() { | 769 DispatchBufferedProtocolMessagesIfNecessary() { |
| 758 if (navigating_handles_.empty() && | 770 if (navigating_handles_.empty() && |
| 759 in_navigation_protocol_message_buffer_.size()) { | 771 in_navigation_protocol_message_buffer_.size()) { |
| 760 DCHECK(current_); | 772 DCHECK(current_); |
| 761 for (const auto& pair : in_navigation_protocol_message_buffer_) { | 773 for (const auto& pair : in_navigation_protocol_message_buffer_) { |
| 762 current_->DispatchProtocolMessage( | 774 current_->DispatchProtocolMessage( |
| 763 pair.second.session_id, pair.first, pair.second.method, | 775 pair.second.session_id, pair.first, pair.second.method, |
| 764 pair.second.message); | 776 pair.second.message); |
| 765 } | 777 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 RenderFrameHost* host) { | 923 RenderFrameHost* host) { |
| 912 return (current_ && current_->host() == host) || | 924 return (current_ && current_->host() == host) || |
| 913 (pending_ && pending_->host() == host); | 925 (pending_ && pending_->host() == host); |
| 914 } | 926 } |
| 915 | 927 |
| 916 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 928 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 917 return current_ && current_->host()->GetParent(); | 929 return current_ && current_->host()->GetParent(); |
| 918 } | 930 } |
| 919 | 931 |
| 920 } // namespace content | 932 } // namespace content |
| OLD | NEW |