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

Unified Diff: extensions/browser/extension_function_dispatcher.h

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/extension_function_dispatcher.h
diff --git a/extensions/browser/extension_function_dispatcher.h b/extensions/browser/extension_function_dispatcher.h
index be8132e970e5893ba1a3de9737ab30968a705b0a..2369b2f9287fe7d9de751129133d02f0d7edc1d8 100644
--- a/extensions/browser/extension_function_dispatcher.h
+++ b/extensions/browser/extension_function_dispatcher.h
@@ -96,7 +96,8 @@ class ExtensionFunctionDispatcher
// The response is sent to the corresponding render view in an
// ExtensionMsg_Response message.
void Dispatch(const ExtensionHostMsg_Request_Params& params,
- content::RenderFrameHost* render_frame_host);
+ content::RenderFrameHost* render_frame_host,
+ int render_process_id);
// Called when an ExtensionFunction is done executing, after it has sent
// a response (if any) to the extension.
@@ -122,6 +123,10 @@ class ExtensionFunctionDispatcher
// destroyed automatically when it goes away.
class UIThreadResponseCallbackWrapper;
+ // Same as UIThreadResponseCallbackWrapper above, but applies to an extension
+ // function from an extension Service Worker.
+ class UIThreadWorkerResponseCallbackWrapper;
+
// Helper to check whether an ExtensionFunction has the required permissions.
// This should be called after the function is fully initialized.
// If the check fails, |callback| is run with an access-denied error and false
@@ -152,8 +157,11 @@ class ExtensionFunctionDispatcher
void DispatchWithCallbackInternal(
const ExtensionHostMsg_Request_Params& params,
content::RenderFrameHost* render_frame_host,
+ int render_process_id,
const ExtensionFunction::ResponseCallback& callback);
+ void RemoveWorkerCallbacksForProcess(int render_process_id);
+
content::BrowserContext* browser_context_;
Delegate* delegate_;
@@ -164,6 +172,16 @@ class ExtensionFunctionDispatcher
typedef std::map<content::RenderFrameHost*, UIThreadResponseCallbackWrapper*>
UIThreadResponseCallbackWrapperMap;
UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_;
+
+ // The key is <render process id, embedded worker id>.
+ using UIThreadWorkerResponseCallbackWrapperMapKey = std::pair<int, int>;
dcheng 2016/05/11 23:41:18 This should just be a simple struct. The typedef i
lazyboy 2016/05/12 00:21:22 Done.
+ using UIThreadWorkerResponseCallbackWrapperMap =
+ std::map<UIThreadWorkerResponseCallbackWrapperMapKey,
+ std::unique_ptr<UIThreadWorkerResponseCallbackWrapper>>;
+ // TODO(lazyboy): The map entries are cleared upon RenderProcessHost shutown,
+ // we should really be clearing it on service worker shutdown.
+ UIThreadWorkerResponseCallbackWrapperMap
+ ui_thread_response_callback_wrappers_for_worker_;
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698