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

Side by Side Diff: extensions/browser/extension_function_dispatcher.h

Issue 1169223002: [Extensions] Clean up the handling of ExtensionHostMsg_Request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 6 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 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>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<IOThreadExtensionMessageFilter> 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.
94 // - This object outlives any RenderViewHost's passed to created 93 // - This object outlives any RenderViewHost's passed to created
95 // ExtensionFunctions. 94 // ExtensionFunctions.
96 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, 95 explicit ExtensionFunctionDispatcher(
97 Delegate* delegate); 96 content::BrowserContext* browser_context);
98
99 ~ExtensionFunctionDispatcher(); 97 ~ExtensionFunctionDispatcher();
100 98
101 Delegate* delegate() { return delegate_; }
102
103 // Message handlers. 99 // Message handlers.
104 // The response is sent to the corresponding render view in an 100 // The response is sent to the corresponding render view in an
105 // ExtensionMsg_Response message. 101 // ExtensionMsg_Response message.
106 // TODO (jam): convert all callers to use RenderFrameHost. 102 // TODO (jam): convert all callers to use RenderFrameHost.
107 void Dispatch(const ExtensionHostMsg_Request_Params& params, 103 void Dispatch(const ExtensionHostMsg_Request_Params& params,
108 content::RenderViewHost* render_view_host); 104 content::RenderViewHost* render_view_host);
109 105
110 // Called when an ExtensionFunction is done executing, after it has sent 106 // Called when an ExtensionFunction is done executing, after it has sent
111 // a response (if any) to the extension. 107 // a response (if any) to the extension.
112 void OnExtensionFunctionCompleted(const Extension* extension); 108 void OnExtensionFunctionCompleted(const Extension* extension);
113 109
110 // See the Delegate class for documentation on these methods.
111 // TODO(devlin): None of these belong here. We should kill
112 // ExtensionFunctionDispatcher::Delegate.
113 WindowController* GetExtensionWindowController() const;
114 content::WebContents* GetAssociatedWebContents() const;
115 content::WebContents* GetVisibleWebContents() const;
116
114 // The BrowserContext that this dispatcher is associated with. 117 // The BrowserContext that this dispatcher is associated with.
115 content::BrowserContext* browser_context() { return browser_context_; } 118 content::BrowserContext* browser_context() { return browser_context_; }
116 119
120 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
121
117 private: 122 private:
118 // For a given RenderViewHost instance, UIThreadResponseCallbackWrapper 123 // For a given RenderViewHost instance, UIThreadResponseCallbackWrapper
119 // creates ExtensionFunction::ResponseCallback instances which send responses 124 // creates ExtensionFunction::ResponseCallback instances which send responses
120 // to the corresponding render view in ExtensionMsg_Response messages. 125 // to the corresponding render view in ExtensionMsg_Response messages.
121 // This class tracks the lifespan of the RenderViewHost instance, and will be 126 // This class tracks the lifespan of the RenderViewHost instance, and will be
122 // destroyed automatically when it goes away. 127 // destroyed automatically when it goes away.
123 class UIThreadResponseCallbackWrapper; 128 class UIThreadResponseCallbackWrapper;
124 129
125 // Helper to check whether an ExtensionFunction has the required permissions. 130 // Helper to check whether an ExtensionFunction has the required permissions.
126 // This should be called after the function is fully initialized. 131 // This should be called after the function is fully initialized.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // instance goes away, the corresponding entry in this map (if exists) will be 168 // instance goes away, the corresponding entry in this map (if exists) will be
164 // removed. 169 // removed.
165 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> 170 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*>
166 UIThreadResponseCallbackWrapperMap; 171 UIThreadResponseCallbackWrapperMap;
167 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; 172 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_;
168 }; 173 };
169 174
170 } // namespace extensions 175 } // namespace extensions
171 176
172 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_ 177 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_DISPATCHER_H_
OLDNEW
« no previous file with comments | « extensions/browser/extension_function.cc ('k') | extensions/browser/extension_function_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698