Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: content/browser/renderer_host/render_widget_host.cc

Issue 8510038: Fix hung renderer timer code in RenderWidgetHost (task spam bug) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simpler fix Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698