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

Side by Side Diff: chrome/renderer/extensions/user_script_scheduler.h

Issue 10696176: Move UserScript and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_
6 #define CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_ 6 #define CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 10
11 #include "chrome/common/extensions/user_script.h" 11 #include "chrome/common/extensions/user_script.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 14
15 class ExtensionDispatcher; 15 class ExtensionDispatcher;
16 class RenderView; 16 class RenderView;
17 struct ExtensionMsg_ExecuteCode_Params; 17 struct ExtensionMsg_ExecuteCode_Params;
18 18
19 namespace WebKit { 19 namespace WebKit {
20 class WebFrame; 20 class WebFrame;
21 } 21 }
22 22
23 namespace extensions {
24
23 // Implements support for injecting scripts at different times in the document 25 // Implements support for injecting scripts at different times in the document
24 // loading process. The different possible time are described in 26 // loading process. The different possible time are described in
25 // UserScript::RunLocation. 27 // UserScript::RunLocation.
26 // 28 //
27 // Currently, determining idleness is simple: it is whichever of the following 29 // Currently, determining idleness is simple: it is whichever of the following
28 // happens first: 30 // happens first:
29 // 31 //
30 // a) When the initial DOM for a page is complete + kUserScriptIdleTimeout, 32 // a) When the initial DOM for a page is complete + kUserScriptIdleTimeout,
31 // b) or when the page has completely loaded including all subresources. 33 // b) or when the page has completely loaded including all subresources.
32 // 34 //
33 // The intent of this mechanism is to prevent user scripts from slowing down 35 // The intent of this mechanism is to prevent user scripts from slowing down
34 // fast pages (run after load), while still allowing them to run relatively 36 // fast pages (run after load), while still allowing them to run relatively
35 // timely for pages with lots of slow subresources. 37 // timely for pages with lots of slow subresources.
36 // 38 //
37 // NOTE: this class does not inherit from RenderViewObserver on purpose. The 39 // NOTE: this class does not inherit from RenderViewObserver on purpose. The
38 // reason is that this object is per frame, and a frame can move across 40 // reason is that this object is per frame, and a frame can move across
39 // RenderViews thanks to adoptNode. So we have each RenderView's 41 // RenderViews thanks to adoptNode. So we have each RenderView's
40 // ExtensionHelper proxy these calls to the renderer process' 42 // ExtensionHelper proxy these calls to the renderer process'
41 // ExtensionDispatcher, which contains the mapping from WebFrame to us. 43 // ExtensionDispatcher, which contains the mapping from WebFrame to us.
42 class UserScriptScheduler { 44 class UserScriptScheduler {
43 public: 45 public:
44 UserScriptScheduler(WebKit::WebFrame* frame, 46 UserScriptScheduler(WebKit::WebFrame* frame,
45 ExtensionDispatcher* extension_dispatcher); 47 ExtensionDispatcher* extension_dispatcher);
46 ~UserScriptScheduler(); 48 ~UserScriptScheduler();
47 49
48 void ExecuteCode(const ExtensionMsg_ExecuteCode_Params& params); 50 void ExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
49 void DidCreateDocumentElement(); 51 void DidCreateDocumentElement();
50 void DidFinishDocumentLoad(); 52 void DidFinishDocumentLoad();
51 void DidFinishLoad(); 53 void DidFinishLoad();
52 void DidStartProvisionalLoad(); 54 void DidStartProvisionalLoad();
53 55
54 private: 56 private:
55 typedef 57 typedef
(...skipping 26 matching lines...) Expand all
82 84
83 // Whether we have already run the idle scripts. 85 // Whether we have already run the idle scripts.
84 bool has_run_idle_; 86 bool has_run_idle_;
85 87
86 // This is only used if we're for the main frame. 88 // This is only used if we're for the main frame.
87 std::map<UserScript::RunLocation, ExecutionQueue> pending_execution_map_; 89 std::map<UserScript::RunLocation, ExecutionQueue> pending_execution_map_;
88 90
89 ExtensionDispatcher* extension_dispatcher_; 91 ExtensionDispatcher* extension_dispatcher_;
90 }; 92 };
91 93
94 } // namespace extensions
95
92 #endif // CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_ 96 #endif // CHROME_RENDERER_EXTENSIONS_USER_SCRIPT_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698