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

Side by Side Diff: extensions/renderer/extension_frame_helper.h

Issue 2300453002: [Extensions] Begin making Extension port initialization asynchronous (Closed)
Patch Set: Rebase Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RENDERER_EXTENSION_FRAME_HELPER_H_ 5 #ifndef EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
6 #define EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ 6 #define EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Schedule a callback, to be run at the next RunScriptsAtDocumentStart 74 // Schedule a callback, to be run at the next RunScriptsAtDocumentStart
75 // notification. Only call this when you are certain that there will be such a 75 // notification. Only call this when you are certain that there will be such a
76 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement. 76 // notification, e.g. from RenderFrameObserver::DidCreateDocumentElement.
77 // Otherwise the callback is never invoked, or invoked for a document that you 77 // Otherwise the callback is never invoked, or invoked for a document that you
78 // were not expecting. 78 // were not expecting.
79 void ScheduleAtDocumentStart(const base::Closure& callback); 79 void ScheduleAtDocumentStart(const base::Closure& callback);
80 80
81 // Schedule a callback, to be run at the next RunScriptsAtDocumentEnd call. 81 // Schedule a callback, to be run at the next RunScriptsAtDocumentEnd call.
82 void ScheduleAtDocumentEnd(const base::Closure& callback); 82 void ScheduleAtDocumentEnd(const base::Closure& callback);
83 83
84 // Sends a message to the browser requesting a port id. |callback| will be
85 // invoked with the global port id when the browser responds.
86 void RequestPortId(const ExtensionMsg_ExternalConnectionInfo& info,
87 const std::string& channel_name,
88 bool include_tls_channel_id,
89 const base::Callback<void(int)>& callback);
90
84 private: 91 private:
85 // RenderFrameObserver implementation. 92 // RenderFrameObserver implementation.
86 void DidCreateDocumentElement() override; 93 void DidCreateDocumentElement() override;
87 void DidCreateNewDocument() override; 94 void DidCreateNewDocument() override;
88 void DidMatchCSS( 95 void DidMatchCSS(
89 const blink::WebVector<blink::WebString>& newly_matching_selectors, 96 const blink::WebVector<blink::WebString>& newly_matching_selectors,
90 const blink::WebVector<blink::WebString>& stopped_matching_selectors) 97 const blink::WebVector<blink::WebString>& stopped_matching_selectors)
91 override; 98 override;
92 void DidCreateScriptContext(v8::Local<v8::Context>, 99 void DidCreateScriptContext(v8::Local<v8::Context>,
93 int extension_group, 100 int extension_group,
(...skipping 20 matching lines...) Expand all
114 void OnNotifyRendererViewType(ViewType view_type); 121 void OnNotifyRendererViewType(ViewType view_type);
115 void OnExtensionResponse(int request_id, 122 void OnExtensionResponse(int request_id,
116 bool success, 123 bool success,
117 const base::ListValue& response, 124 const base::ListValue& response,
118 const std::string& error); 125 const std::string& error);
119 void OnExtensionMessageInvoke(const std::string& extension_id, 126 void OnExtensionMessageInvoke(const std::string& extension_id,
120 const std::string& module_name, 127 const std::string& module_name,
121 const std::string& function_name, 128 const std::string& function_name,
122 const base::ListValue& args, 129 const base::ListValue& args,
123 bool user_gesture); 130 bool user_gesture);
131 void OnAssignPortId(int port_id, int request_id);
124 132
125 // Type of view associated with the RenderFrame. 133 // Type of view associated with the RenderFrame.
126 ViewType view_type_; 134 ViewType view_type_;
127 135
128 // The id of the tab the render frame is attached to. 136 // The id of the tab the render frame is attached to.
129 int tab_id_; 137 int tab_id_;
130 138
131 // The id of the browser window the render frame is attached to. 139 // The id of the browser window the render frame is attached to.
132 int browser_window_id_; 140 int browser_window_id_;
133 141
134 Dispatcher* extension_dispatcher_; 142 Dispatcher* extension_dispatcher_;
135 143
136 // Whether or not the current document element has been created. 144 // Whether or not the current document element has been created.
137 bool did_create_current_document_element_; 145 bool did_create_current_document_element_;
138 146
139 // Callbacks to be run at the next RunScriptsAtDocumentStart notification. 147 // Callbacks to be run at the next RunScriptsAtDocumentStart notification.
140 std::vector<base::Closure> document_element_created_callbacks_; 148 std::vector<base::Closure> document_element_created_callbacks_;
141 149
142 // Callbacks to be run at the next RunScriptsAtDocumentEnd notification. 150 // Callbacks to be run at the next RunScriptsAtDocumentEnd notification.
143 std::vector<base::Closure> document_load_finished_callbacks_; 151 std::vector<base::Closure> document_load_finished_callbacks_;
144 152
153 // Counter for port requests.
154 int next_port_request_id_;
155
156 // Map of port requests to callbacks.
157 std::map<int, base::Callback<void(int)>> pending_port_requests_;
158
145 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_; 159 base::WeakPtrFactory<ExtensionFrameHelper> weak_ptr_factory_;
146 160
147 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper); 161 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper);
148 }; 162 };
149 163
150 } // namespace extensions 164 } // namespace extensions
151 165
152 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_ 166 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698