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

Unified Diff: chrome/renderer/extensions/dispatcher.cc

Issue 145463002: Extensions: Send the tab id to platform apps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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: chrome/renderer/extensions/dispatcher.cc
===================================================================
--- chrome/renderer/extensions/dispatcher.cc (revision 246091)
+++ chrome/renderer/extensions/dispatcher.cc (working copy)
@@ -587,6 +587,11 @@
const base::DictionaryValue& source_tab,
const ExtensionMsg_ExternalConnectionInfo& info,
const std::string& tls_channel_id) {
+ DCHECK(!ContainsKey(port_to_tab_id_map_, target_port_id));
+ int sender_tab_id = -1;
+ source_tab.GetInteger("id", &sender_tab_id);
+ port_to_tab_id_map_[target_port_id] = sender_tab_id;
+
MessagingBindings::DispatchOnConnect(
v8_context_set_.GetAll(),
target_port_id, channel_name, source_tab,
@@ -597,6 +602,11 @@
void Dispatcher::OnDeliverMessage(int target_port_id,
const Message& message) {
+ std::map<int, int>::const_iterator it =
+ port_to_tab_id_map_.find(target_port_id);
+ DCHECK(it != port_to_tab_id_map_.end());
+ RequestSender::ScopedTabID scoped_tab_id(request_sender(), it->second);
+
MessagingBindings::DeliverMessage(
v8_context_set_.GetAll(),
target_port_id,
@@ -606,6 +616,9 @@
void Dispatcher::OnDispatchOnDisconnect(int port_id,
const std::string& error_message) {
+ int target_port = port_id ^ 1;
+ port_to_tab_id_map_.erase(target_port);
not at google - send to devlin 2014/01/28 18:45:45 maybe you could also DCHECK(port_to_tab_id_map_.fi
Lei Zhang 2014/01/28 22:52:27 Done... and the DCHECK fails. It turns out in this
+
MessagingBindings::DispatchOnDisconnect(
v8_context_set_.GetAll(),
port_id, error_message,

Powered by Google App Engine
This is Rietveld 408576698