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

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

Issue 6099013: Fix race condition where chrome.tabs.executeScript sometimes wouldn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 9 years, 11 months 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 | « chrome/renderer/render_view.cc ('k') | 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 #ifndef CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_ 5 #ifndef CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_
6 #define CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_ 6 #define CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/task.h" 9 #include "base/task.h"
10 10
(...skipping 13 matching lines...) Expand all
24 // The intent of this mechanism is to prevent user scripts from slowing down 24 // The intent of this mechanism is to prevent user scripts from slowing down
25 // fast pages (run after load), while still allowing them to run relatively 25 // fast pages (run after load), while still allowing them to run relatively
26 // timely for pages with lots of slow subresources. 26 // timely for pages with lots of slow subresources.
27 class UserScriptIdleScheduler { 27 class UserScriptIdleScheduler {
28 public: 28 public:
29 UserScriptIdleScheduler(RenderView* view, WebKit::WebFrame* frame); 29 UserScriptIdleScheduler(RenderView* view, WebKit::WebFrame* frame);
30 ~UserScriptIdleScheduler(); 30 ~UserScriptIdleScheduler();
31 31
32 bool has_run() { return has_run_; } 32 bool has_run() { return has_run_; }
33 33
34 void set_has_run(bool has_run) { has_run_ = has_run; }
35
36 // Called when the DOM has been completely constructed. 34 // Called when the DOM has been completely constructed.
37 void DidFinishDocumentLoad(); 35 void DidFinishDocumentLoad();
38 36
39 // Called when the document has completed loading. 37 // Called when the document has completed loading.
40 void DidFinishLoad(); 38 void DidFinishLoad();
41 39
42 // Called when the client has gone away and we should no longer run scripts. 40 // Called when the client has gone away and we should no longer run scripts.
43 void Cancel(); 41 void Cancel();
44 42
45 private: 43 private:
46 // Run user scripts, except if they've already run for this frame, or the 44 // Run user scripts, except if they've already run for this frame, or the
47 // frame has been destroyed. 45 // frame has been destroyed.
48 void MaybeRun(); 46 void MaybeRun();
49 47
50 ScopedRunnableMethodFactory<UserScriptIdleScheduler> method_factory_; 48 ScopedRunnableMethodFactory<UserScriptIdleScheduler> method_factory_;
51 49
52 // The RenderView we will call back to when it is time to run scripts. 50 // The RenderView we will call back to when it is time to run scripts.
53 RenderView* view_; 51 RenderView* view_;
54 52
55 // The Frame we will run scripts in. 53 // The Frame we will run scripts in.
56 WebKit::WebFrame* frame_; 54 WebKit::WebFrame* frame_;
57 55
58 // Whether we have already run scripts. 56 // Whether we have already run scripts.
59 bool has_run_; 57 bool has_run_;
60 }; 58 };
61 59
62 #endif // CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_ 60 #endif // CHROME_RENDERER_USER_SCRIPT_IDLE_SCHEDULER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698