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

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

Issue 2331263002: [Extensions] Finish making port creation asynchronous (Closed)
Patch Set: 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 #include "extensions/renderer/extension_frame_helper.h" 5 #include "extensions/renderer/extension_frame_helper.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
10 #include "extensions/common/api/messaging/message.h" 10 #include "extensions/common/api/messaging/message.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 pending_port_requests_[port_request_id] = callback; 183 pending_port_requests_[port_request_id] = callback;
184 { 184 {
185 SCOPED_UMA_HISTOGRAM_TIMER( 185 SCOPED_UMA_HISTOGRAM_TIMER(
186 "Extensions.Messaging.GetPortIdSyncTime.Extension"); 186 "Extensions.Messaging.GetPortIdSyncTime.Extension");
187 render_frame()->Send(new ExtensionHostMsg_OpenChannelToExtension( 187 render_frame()->Send(new ExtensionHostMsg_OpenChannelToExtension(
188 render_frame()->GetRoutingID(), info, channel_name, 188 render_frame()->GetRoutingID(), info, channel_name,
189 include_tls_channel_id, port_request_id)); 189 include_tls_channel_id, port_request_id));
190 } 190 }
191 } 191 }
192 192
193 void ExtensionFrameHelper::RequestTabPortId(
194 const ExtensionMsg_TabTargetConnectionInfo& info,
195 const std::string& extension_id,
196 const std::string& channel_name,
197 const base::Callback<void(int)>& callback) {
198 int port_request_id = next_port_request_id_++;
199 pending_port_requests_[port_request_id] = callback;
200 {
201 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.Messaging.GetPortIdSyncTime.Tab");
202 render_frame()->Send(new ExtensionHostMsg_OpenChannelToTab(
203 render_frame()->GetRoutingID(), info, extension_id, channel_name,
204 port_request_id));
205 }
206 }
207
208 void ExtensionFrameHelper::RequestNativePortId(
lazyboy 2016/09/13 00:34:39 nit: RequestNativeAppPortId
Devlin 2016/09/13 16:49:55 Done.
209 const std::string& native_app_name,
210 const base::Callback<void(int)>& callback) {
211 int port_request_id = next_port_request_id_++;
212 pending_port_requests_[port_request_id] = callback;
213 {
214 SCOPED_UMA_HISTOGRAM_TIMER(
215 "Extensions.Messaging.GetPortIdSyncTime.NativeApp");
216 // TODO(devlin): Make this async. crbug.com/642380
lazyboy 2016/09/13 00:34:39 Remove.
Devlin 2016/09/13 16:49:55 Whoops, done.
217 render_frame()->Send(new ExtensionHostMsg_OpenChannelToNativeApp(
218 render_frame()->GetRoutingID(), native_app_name, port_request_id));
219 }
220 }
221
193 void ExtensionFrameHelper::DidMatchCSS( 222 void ExtensionFrameHelper::DidMatchCSS(
194 const blink::WebVector<blink::WebString>& newly_matching_selectors, 223 const blink::WebVector<blink::WebString>& newly_matching_selectors,
195 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 224 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
196 extension_dispatcher_->content_watcher()->DidMatchCSS( 225 extension_dispatcher_->content_watcher()->DidMatchCSS(
197 render_frame()->GetWebFrame(), newly_matching_selectors, 226 render_frame()->GetWebFrame(), newly_matching_selectors,
198 stopped_matching_selectors); 227 stopped_matching_selectors);
199 } 228 }
200 229
201 void ExtensionFrameHelper::DidCreateScriptContext( 230 void ExtensionFrameHelper::DidCreateScriptContext(
202 v8::Local<v8::Context> context, 231 v8::Local<v8::Context> context,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 DCHECK(iter != pending_port_requests_.end()); 344 DCHECK(iter != pending_port_requests_.end());
316 iter->second.Run(port_id); 345 iter->second.Run(port_id);
317 pending_port_requests_.erase(iter); 346 pending_port_requests_.erase(iter);
318 } 347 }
319 348
320 void ExtensionFrameHelper::OnDestruct() { 349 void ExtensionFrameHelper::OnDestruct() {
321 delete this; 350 delete this;
322 } 351 }
323 352
324 } // namespace extensions 353 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698