OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/renderer_host/render_widget_host.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 499 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 void RenderWidgetHost::StartHangMonitorTimeout(TimeDelta delay) { | 503 void RenderWidgetHost::StartHangMonitorTimeout(TimeDelta delay) { |
504 if (CommandLine::ForCurrentProcess()->HasSwitch( | 504 if (CommandLine::ForCurrentProcess()->HasSwitch( |
505 switches::kDisableHangMonitor)) { | 505 switches::kDisableHangMonitor)) { |
506 return; | 506 return; |
507 } | 507 } |
508 | 508 |
509 // If we already have a timer that will expire at or before the given delay, | 509 // Set time_when_considered_hung_ if it's null. |
510 // then we have nothing more to do now. If we have set our end time to null | 510 Time requested_end_time = Time::Now() + delay; |
511 // by calling StopHangMonitorTimeout, though, we will need to restart the | 511 if (time_when_considered_hung_.is_null()) |
512 // timer. | 512 time_when_considered_hung_ = requested_end_time; |
| 513 |
| 514 // If we already have a timer with the same or shorter duration, then we can |
| 515 // wait for it to finish. |
513 if (hung_renderer_timer_.IsRunning() && | 516 if (hung_renderer_timer_.IsRunning() && |
514 hung_renderer_timer_.GetCurrentDelay() <= delay && | 517 hung_renderer_timer_.GetCurrentDelay() <= delay) { |
515 !time_when_considered_hung_.is_null()) { | 518 // If time_when_considered_hung_ was null, this timer may fire early. |
| 519 // CheckRendererIsUnresponsive handles that by calling |
| 520 // StartHangMonitorTimeout with the remaining time. |
| 521 // If time_when_considered_hung_ was non-null, it means we still haven't |
| 522 // heard from the renderer so we leave time_when_considered_hung_ as is. |
516 return; | 523 return; |
517 } | 524 } |
518 | 525 |
519 // Either the timer is not yet running, or we need to adjust the timer to | 526 // Either the timer is not yet running, or we need to adjust the timer to |
520 // fire sooner. | 527 // fire sooner. |
521 time_when_considered_hung_ = Time::Now() + delay; | 528 time_when_considered_hung_ = requested_end_time; |
522 hung_renderer_timer_.Stop(); | 529 hung_renderer_timer_.Stop(); |
523 hung_renderer_timer_.Start(FROM_HERE, delay, this, | 530 hung_renderer_timer_.Start(FROM_HERE, delay, this, |
524 &RenderWidgetHost::CheckRendererIsUnresponsive); | 531 &RenderWidgetHost::CheckRendererIsUnresponsive); |
525 } | 532 } |
526 | 533 |
527 void RenderWidgetHost::RestartHangMonitorTimeout() { | 534 void RenderWidgetHost::RestartHangMonitorTimeout() { |
528 // Setting to null will cause StartHangMonitorTimeout to restart the timer. | 535 // Setting to null will cause StartHangMonitorTimeout to restart the timer. |
529 time_when_considered_hung_ = Time(); | 536 time_when_considered_hung_ = Time(); |
530 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); | 537 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); |
531 } | 538 } |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 pending_mouse_lock_request_ = false; | 1469 pending_mouse_lock_request_ = false; |
1463 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { | 1470 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
1464 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1471 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1465 return false; | 1472 return false; |
1466 } else { | 1473 } else { |
1467 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1474 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
1468 return true; | 1475 return true; |
1469 } | 1476 } |
1470 } | 1477 } |
1471 } | 1478 } |
OLD | NEW |