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

Side by Side Diff: chrome/renderer/user_script_idle_scheduler.cc

Issue 466079: Fix a bug where content scripts would get run twice in some cases. (Closed)
Patch Set: Created 11 years 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
« 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/renderer/user_script_idle_scheduler.h" 5 #include "chrome/renderer/user_script_idle_scheduler.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/renderer/render_view.h" 8 #include "chrome/renderer/render_view.h"
9 9
10 namespace { 10 namespace {
(...skipping 19 matching lines...) Expand all
30 MessageLoop::current()->PostTask(FROM_HERE, 30 MessageLoop::current()->PostTask(FROM_HERE,
31 method_factory_.NewRunnableMethod(&UserScriptIdleScheduler::MaybeRun)); 31 method_factory_.NewRunnableMethod(&UserScriptIdleScheduler::MaybeRun));
32 } 32 }
33 33
34 void UserScriptIdleScheduler::Cancel() { 34 void UserScriptIdleScheduler::Cancel() {
35 view_ = NULL; 35 view_ = NULL;
36 frame_ = NULL; 36 frame_ = NULL;
37 } 37 }
38 38
39 void UserScriptIdleScheduler::MaybeRun() { 39 void UserScriptIdleScheduler::MaybeRun() {
40 if (!view_) 40 if (!view_ || has_run())
41 return; 41 return;
42 42
43 // Note: we must set this before calling OnUserScriptIdleTriggered, because
44 // that may result in a synchronous call back into MaybeRun if there is a
45 // pending task currently in the queue.
46 // http://code.google.com/p/chromium/issues/detail?id=29644
47 has_run_ = true;
48
43 DCHECK(frame_); 49 DCHECK(frame_);
44 view_->OnUserScriptIdleTriggered(frame_); 50 view_->OnUserScriptIdleTriggered(frame_);
45 Cancel(); 51 Cancel();
46 has_run_ = true;
47 } 52 }
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