Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / renderer / extensions / request_sender.h
index 618a967..1f59ab8 100644 (file)
@@ -42,6 +42,20 @@ class RequestSender {
                                     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();
 
@@ -73,6 +87,7 @@ class RequestSender {
   void InvalidateSource(Source* source);
 
  private:
+  friend class ScopedTabID;
   typedef std::map<int, linked_ptr<PendingRequest> > PendingRequestMap;
 
   void InsertRequest(int request_id, PendingRequest* pending_request);
@@ -81,6 +96,8 @@ class RequestSender {
   Dispatcher* dispatcher_;
   PendingRequestMap pending_requests_;
 
+  int source_tab_id_;  // Id of the tab sending the request, or -1 if no tab.
+
   DISALLOW_COPY_AND_ASSIGN(RequestSender);
 };