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