OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "extensions/browser/extension_function.h" | 13 #include "extensions/browser/extension_function.h" |
14 #include "ipc/ipc_sender.h" | 14 #include "ipc/ipc_sender.h" |
15 | 15 |
16 struct ExtensionHostMsg_Request_Params; | 16 struct ExtensionHostMsg_Request_Params; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class BrowserContext; | 19 class BrowserContext; |
20 class RenderFrameHost; | 20 class RenderFrameHost; |
21 class RenderViewHost; | 21 class RenderViewHost; |
22 class WebContents; | 22 class WebContents; |
23 } | 23 } |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
26 | 26 |
27 class Extension; | 27 class Extension; |
28 class ExtensionAPI; | 28 class ExtensionAPI; |
29 class ExtensionMessageFilter; | |
30 class InfoMap; | 29 class InfoMap; |
| 30 class IOThreadExtensionMessageFilter; |
31 class ProcessMap; | 31 class ProcessMap; |
32 class WindowController; | 32 class WindowController; |
33 | 33 |
34 // A factory function for creating new ExtensionFunction instances. | 34 // A factory function for creating new ExtensionFunction instances. |
35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
36 | 36 |
37 // ExtensionFunctionDispatcher receives requests to execute functions from | 37 // ExtensionFunctionDispatcher receives requests to execute functions from |
38 // Chrome extensions running in a RenderViewHost and dispatches them to the | 38 // Chrome extensions running in a RenderViewHost and dispatches them to the |
39 // appropriate handler. It lives entirely on the UI thread. | 39 // appropriate handler. It lives entirely on the UI thread. |
40 // | 40 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // false if no such function was registered. | 78 // false if no such function was registered. |
79 static bool OverrideFunction(const std::string& name, | 79 static bool OverrideFunction(const std::string& name, |
80 ExtensionFunctionFactory factory); | 80 ExtensionFunctionFactory factory); |
81 | 81 |
82 // Dispatches an IO-thread extension function. Only used for specific | 82 // Dispatches an IO-thread extension function. Only used for specific |
83 // functions that must be handled on the IO-thread. | 83 // functions that must be handled on the IO-thread. |
84 static void DispatchOnIOThread( | 84 static void DispatchOnIOThread( |
85 InfoMap* extension_info_map, | 85 InfoMap* extension_info_map, |
86 void* profile_id, | 86 void* profile_id, |
87 int render_process_id, | 87 int render_process_id, |
88 base::WeakPtr<ExtensionMessageFilter> ipc_sender, | 88 base::WeakPtr<IOThreadExtensionMessageFilter> ipc_sender, |
89 int routing_id, | 89 int routing_id, |
90 const ExtensionHostMsg_Request_Params& params); | 90 const ExtensionHostMsg_Request_Params& params); |
91 | 91 |
92 // Public constructor. Callers must ensure that: | 92 // Public constructor. Callers must ensure that: |
93 // - |delegate| outlives this object. | 93 // - |delegate| outlives this object. |
94 // - This object outlives any RenderViewHost's passed to created | 94 // - This object outlives any RenderViewHost's passed to created |
95 // ExtensionFunctions. | 95 // ExtensionFunctions. |
96 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, | 96 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, |
97 Delegate* delegate); | 97 Delegate* delegate); |
98 | 98 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // instance goes away, the corresponding entry in this map (if exists) will be | 162 // instance goes away, the corresponding entry in this map (if exists) will be |
163 // removed. | 163 // removed. |
164 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> | 164 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> |
165 UIThreadResponseCallbackWrapperMap; | 165 UIThreadResponseCallbackWrapperMap; |
166 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; | 166 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; |
167 }; | 167 }; |
168 | 168 |
169 } // namespace extensions | 169 } // namespace extensions |
170 | 170 |
171 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ | 171 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ |
OLD | NEW |