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

Unified Diff: extensions/renderer/messaging_bindings.cc

Issue 2331263002: [Extensions] Finish making port creation asynchronous (Closed)
Patch Set: lazyboy's 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/extension_frame_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/messaging_bindings.cc
diff --git a/extensions/renderer/messaging_bindings.cc b/extensions/renderer/messaging_bindings.cc
index 6f6f938ed4352c8c5b69fc24f38c86676911ea10..a68dcb70cd938c4fec5d7dfc6eb4c353030f37c5 100644
--- a/extensions/renderer/messaging_bindings.cc
+++ b/extensions/renderer/messaging_bindings.cc
@@ -473,22 +473,14 @@ void MessagingBindings::OpenChannelToNativeApp(
std::string native_app_name = *v8::String::Utf8Value(args[0]);
int local_id = GetNextLocalId();
- ExtensionPort* port =
- ports_
- .insert(std::make_pair(
- local_id, base::MakeUnique<ExtensionPort>(context(), local_id)))
- .first->second.get();
-
- int global_id = -1;
- {
- SCOPED_UMA_HISTOGRAM_TIMER(
- "Extensions.Messaging.GetPortIdSyncTime.NativeApp");
- // TODO(devlin): Make this async. crbug.com/642380
- render_frame->Send(new ExtensionHostMsg_OpenChannelToNativeApp(
- render_frame->GetRoutingID(), native_app_name, &global_id));
- }
+ ports_[local_id] = base::MakeUnique<ExtensionPort>(context(), local_id);
- port->SetGlobalId(global_id);
+ ExtensionFrameHelper* frame_helper = ExtensionFrameHelper::Get(render_frame);
+ DCHECK(frame_helper);
+ frame_helper->RequestNativeAppPortId(
+ native_app_name,
+ base::Bind(&MessagingBindings::SetGlobalPortId,
+ weak_ptr_factory_.GetWeakPtr(), local_id));
args.GetReturnValue().Set(static_cast<int32_t>(local_id));
}
@@ -512,26 +504,22 @@ void MessagingBindings::OpenChannelToTab(
CHECK(args[3]->IsString());
int local_id = GetNextLocalId();
- ExtensionPort* port =
- ports_
- .insert(std::make_pair(
- local_id, base::MakeUnique<ExtensionPort>(context(), local_id)))
- .first->second.get();
+ ports_[local_id] = base::MakeUnique<ExtensionPort>(context(), local_id);
ExtensionMsg_TabTargetConnectionInfo info;
info.tab_id = args[0]->Int32Value();
info.frame_id = args[1]->Int32Value();
+ // TODO(devlin): Why is this not part of info?
std::string extension_id = *v8::String::Utf8Value(args[2]);
std::string channel_name = *v8::String::Utf8Value(args[3]);
- int global_id = -1;
- {
- SCOPED_UMA_HISTOGRAM_TIMER("Extensions.Messaging.GetPortIdSyncTime.Tab");
- // TODO(devlin): Make this async. crbug.com/642380
- render_frame->Send(new ExtensionHostMsg_OpenChannelToTab(
- render_frame->GetRoutingID(), info, extension_id, channel_name,
- &global_id));
- }
- port->SetGlobalId(global_id);
+
+ ExtensionFrameHelper* frame_helper = ExtensionFrameHelper::Get(render_frame);
+ DCHECK(frame_helper);
+ frame_helper->RequestTabPortId(
+ info, extension_id, channel_name,
+ base::Bind(&MessagingBindings::SetGlobalPortId,
+ weak_ptr_factory_.GetWeakPtr(), local_id));
+
args.GetReturnValue().Set(static_cast<int32_t>(local_id));
}
« no previous file with comments | « extensions/renderer/extension_frame_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698