| 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/devtools_manager.h" | 5 #include "content/browser/devtools/devtools_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 TestWebContentsDelegate delegate; | 138 TestWebContentsDelegate delegate; |
| 139 contents()->SetDelegate(&delegate); | 139 contents()->SetDelegate(&delegate); |
| 140 | 140 |
| 141 TestDevToolsClientHost client_host; | 141 TestDevToolsClientHost client_host; |
| 142 scoped_refptr<DevToolsAgentHost> agent_host(DevToolsAgentHost::GetOrCreateFor( | 142 scoped_refptr<DevToolsAgentHost> agent_host(DevToolsAgentHost::GetOrCreateFor( |
| 143 WebContents::FromRenderViewHost(inspected_rvh))); | 143 WebContents::FromRenderViewHost(inspected_rvh))); |
| 144 client_host.InspectAgentHost(agent_host.get()); | 144 client_host.InspectAgentHost(agent_host.get()); |
| 145 | 145 |
| 146 // Start with a short timeout. | 146 // Start with a short timeout. |
| 147 inspected_rvh->GetWidget()->StartHangMonitorTimeout( | 147 inspected_rvh->GetWidget()->StartHangMonitorTimeout( |
| 148 TimeDelta::FromMilliseconds(10)); | 148 TimeDelta::FromMilliseconds(10), |
| 149 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN); |
| 149 // Wait long enough for first timeout and see if it fired. | 150 // Wait long enough for first timeout and see if it fired. |
| 150 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 151 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 152 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 152 TimeDelta::FromMilliseconds(10)); | 153 TimeDelta::FromMilliseconds(10)); |
| 153 base::RunLoop().Run(); | 154 base::RunLoop().Run(); |
| 154 EXPECT_FALSE(delegate.renderer_unresponsive_received()); | 155 EXPECT_FALSE(delegate.renderer_unresponsive_received()); |
| 155 | 156 |
| 156 // Now close devtools and check that the notification is delivered. | 157 // Now close devtools and check that the notification is delivered. |
| 157 client_host.Close(); | 158 client_host.Close(); |
| 158 // Start with a short timeout. | 159 // Start with a short timeout. |
| 159 inspected_rvh->GetWidget()->StartHangMonitorTimeout( | 160 inspected_rvh->GetWidget()->StartHangMonitorTimeout( |
| 160 TimeDelta::FromMilliseconds(10)); | 161 TimeDelta::FromMilliseconds(10), |
| 162 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN); |
| 161 // Wait long enough for first timeout and see if it fired. | 163 // Wait long enough for first timeout and see if it fired. |
| 162 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 164 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 163 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 165 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 164 TimeDelta::FromMilliseconds(10)); | 166 TimeDelta::FromMilliseconds(10)); |
| 165 base::RunLoop().Run(); | 167 base::RunLoop().Run(); |
| 166 EXPECT_TRUE(delegate.renderer_unresponsive_received()); | 168 EXPECT_TRUE(delegate.renderer_unresponsive_received()); |
| 167 | 169 |
| 168 contents()->SetDelegate(NULL); | 170 contents()->SetDelegate(NULL); |
| 169 } | 171 } |
| 170 | 172 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 TestDevToolsClientHost client_host; | 251 TestDevToolsClientHost client_host; |
| 250 client_host.InspectAgentHost(agent_host.get()); | 252 client_host.InspectAgentHost(agent_host.get()); |
| 251 agent_host->DispatchProtocolMessage(&client_host, "message1"); | 253 agent_host->DispatchProtocolMessage(&client_host, "message1"); |
| 252 agent_host->DispatchProtocolMessage(&client_host, "message2"); | 254 agent_host->DispatchProtocolMessage(&client_host, "message2"); |
| 253 agent_host->DispatchProtocolMessage(&client_host, "message2"); | 255 agent_host->DispatchProtocolMessage(&client_host, "message2"); |
| 254 | 256 |
| 255 client_host.Close(); | 257 client_host.Close(); |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace content | 260 } // namespace content |
| OLD | NEW |