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

Unified Diff: chrome/renderer/extensions/request_sender.h

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/request_sender.h
===================================================================
--- chrome/renderer/extensions/request_sender.h (revision 246091)
+++ chrome/renderer/extensions/request_sender.h (working copy)
@@ -42,6 +42,20 @@
const std::string& error) = 0;
};
+ // Helper class to (re)set the |source_tab_id_| below.
+ class ScopedTabID {
+ public:
+ ScopedTabID(RequestSender* request_sender, int tab_id);
+ ~ScopedTabID();
+
+ private:
+ RequestSender* const request_sender_;
+ const int tab_id_;
+ const int previous_tab_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTabID);
+ };
+
explicit RequestSender(Dispatcher* dispatcher);
~RequestSender();
@@ -60,6 +74,7 @@
int request_id,
bool has_callback,
bool for_io_thread,
+ int source_tab_id,
base::ListValue* value_args);
// Handles responses from the extension host to calls made by StartRequest().
@@ -72,7 +87,12 @@
// TODO(kalman): Do this in a generic/safe way.
void InvalidateSource(Source* source);
+ int sender_tab_id() const {
not at google - send to devlin 2014/01/28 18:45:45 (see comment in request_sender.cc; does this need
+ return sender_tab_id_;
+ }
+
private:
+ friend class ScopedTabID;
typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap;
void InsertRequest(int request_id, PendingRequest* pending_request);
@@ -81,6 +101,8 @@
Dispatcher* dispatcher_;
PendingRequestMap pending_requests_;
+ int sender_tab_id_; // Id of the tab sending the request, or -1 if no tab.
+
DISALLOW_COPY_AND_ASSIGN(RequestSender);
};

Powered by Google App Engine
This is Rietveld 408576698