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 // Set time_when_considered_hung_ if it's null. | |
510 Time requested_end_time = Time::Now() + delay; | |
511 if (time_when_considered_hung_.is_null()) | |
512 time_when_considered_hung_ = requested_end_time; | |
513 | |
509 // If we already have a timer that will expire at or before the given delay, | 514 // If we already have a timer that will expire at or before the given delay, |
Charlie Reis
2011/11/11 02:20:10
Maybe we can update this comment to reflect what y
jbates
2011/11/11 02:40:13
Done.
| |
510 // then we have nothing more to do now. If we have set our end time to null | 515 // then we have nothing more to do now. |
511 // by calling StopHangMonitorTimeout, though, we will need to restart the | |
512 // timer. | |
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()) { | |
516 return; | 518 return; |
517 } | 519 } |
518 | 520 |
519 // Either the timer is not yet running, or we need to adjust the timer to | 521 // Either the timer is not yet running, or we need to adjust the timer to |
520 // fire sooner. | 522 // fire sooner. |
521 time_when_considered_hung_ = Time::Now() + delay; | 523 time_when_considered_hung_ = requested_end_time; |
522 hung_renderer_timer_.Stop(); | 524 hung_renderer_timer_.Stop(); |
523 hung_renderer_timer_.Start(FROM_HERE, delay, this, | 525 hung_renderer_timer_.Start(FROM_HERE, delay, this, |
524 &RenderWidgetHost::CheckRendererIsUnresponsive); | 526 &RenderWidgetHost::CheckRendererIsUnresponsive); |
525 } | 527 } |
526 | 528 |
527 void RenderWidgetHost::RestartHangMonitorTimeout() { | 529 void RenderWidgetHost::RestartHangMonitorTimeout() { |
528 // Setting to null will cause StartHangMonitorTimeout to restart the timer. | 530 // Setting to null will cause StartHangMonitorTimeout to restart the timer. |
529 time_when_considered_hung_ = Time(); | 531 time_when_considered_hung_ = Time(); |
530 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); | 532 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); |
531 } | 533 } |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 pending_mouse_lock_request_ = false; | 1464 pending_mouse_lock_request_ = false; |
1463 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { | 1465 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
1464 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1466 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1465 return false; | 1467 return false; |
1466 } else { | 1468 } else { |
1467 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1469 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
1468 return true; | 1470 return true; |
1469 } | 1471 } |
1470 } | 1472 } |
1471 } | 1473 } |
OLD | NEW |