Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / frame_host / render_frame_host_manager.h
index a28cb08..768532a 100644 (file)
@@ -12,6 +12,7 @@
 #include "content/browser/renderer_host/render_view_host_delegate.h"
 #include "content/browser/site_instance_impl.h"
 #include "content/common/content_export.h"
+#include "content/public/browser/global_request_id.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
 #include "content/public/common/referrer.h"
@@ -20,6 +21,7 @@
 namespace content {
 class BrowserContext;
 class CrossProcessFrameConnector;
+class CrossSiteTransferringRequest;
 class InterstitialPageImpl;
 class FrameTreeNode;
 class NavigationControllerImpl;
@@ -238,7 +240,7 @@ class CONTENT_EXPORT RenderFrameHostManager
   virtual void OnCrossSiteResponse(
       RenderViewHost* pending_render_view_host,
       const GlobalRequestID& global_request_id,
-      bool is_transfer,
+      scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
       const std::vector<GURL>& transfer_url_chain,
       const Referrer& referrer,
       PageTransition page_transition,
@@ -269,50 +271,56 @@ class CONTENT_EXPORT RenderFrameHostManager
   // to a new process after this completes or times out.
   void SwapOutOldPage();
 
+  // Deletes a RenderFrameHost that was pending shutdown.
+  void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id,
+                                              RenderFrameHostImpl* rfh);
+
  private:
   friend class RenderFrameHostManagerTest;
   friend class TestWebContents;
 
   // Tracks information about a navigation while a cross-process transition is
   // in progress, in case we need to transfer it to a new RenderFrameHost.
+  // When a request is being transferred, deleting the PendingNavigationParams,
+  // and thus |cross_site_transferring_request|, will cancel the request being
+  // transferred, unless its ReleaseRequest method has been called.
   struct PendingNavigationParams {
-    PendingNavigationParams();
-    PendingNavigationParams(const GlobalRequestID& global_request_id,
-                            bool is_transfer,
-                            const std::vector<GURL>& transfer_url,
-                            Referrer referrer,
-                            PageTransition page_transition,
-                            int64 frame_id,
-                            bool should_replace_current_entry);
+    PendingNavigationParams(
+        const GlobalRequestID& global_request_id,
+        scoped_ptr<CrossSiteTransferringRequest>
+            cross_site_transferring_request,
+        const std::vector<GURL>& transfer_url,
+        Referrer referrer,
+        PageTransition page_transition,
+        int64 frame_id,
+        bool should_replace_current_entry);
     ~PendingNavigationParams();
 
     // The child ID and request ID for the pending navigation.  Present whether
-    // |is_transfer| is true or false.
+    // |request_transfer| is NULL or not.
     GlobalRequestID global_request_id;
 
-    // Whether this pending navigation needs to be transferred to another
-    // process than the one it was going to commit in.  If so, the
-    // |transfer_url|, |referrer|, and |frame_id| parameters will be set.
-    bool is_transfer;
+    // If a pending request needs to be transferred to another process, this
+    // owns the request until it's transferred to the new process, so it will be
+    // cleaned up if the navigation is cancelled.  Otherwise, this is NULL.
+    scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request;
+
+    // If |request_transfer| is non-NULL, the values below are all set.
 
-    // If |is_transfer|, this is the URL chain of the request.  The first entry
-    // is the original request URL, and the last entry is the destination URL to
-    // request in the new process.
+    // The first entry is the original request URL, and the last entry is the
+    // destination URL to request in the new process.
     std::vector<GURL> transfer_url_chain;
 
-    // If |is_transfer|, this is the referrer to use for the request in the new
-    // process.
+    // This is the referrer to use for the request in the new process.
     Referrer referrer;
 
-    // If |is_transfer|, this is the transition type for the original
-    // navigation.
+    // This is the transition type for the original navigation.
     PageTransition page_transition;
 
-    // If |is_transfer|, this is the frame ID to use in RequestTransferURL.
+    // This is the frame ID to use in RequestTransferURL.
     int64 frame_id;
 
-    // If |is_transfer|, this is whether the navigation should replace the
-    // current history entry.
+    // This is whether the navigation should replace the current history entry.
     bool should_replace_current_entry;
   };
 
@@ -437,6 +445,11 @@ class CONTENT_EXPORT RenderFrameHostManager
   typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap;
   RenderFrameHostMap swapped_out_hosts_;
 
+  // A map of RenderFrameHosts pending shutdown.
+  typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> >
+      RFHPendingDeleteMap;
+  RFHPendingDeleteMap pending_delete_hosts_;
+
   // The intersitial page currently shown if any, not own by this class
   // (the InterstitialPage is self-owned, it deletes itself when hidden).
   InterstitialPageImpl* interstitial_page_;
@@ -450,6 +463,8 @@ class CONTENT_EXPORT RenderFrameHostManager
   // process as its parent.
   CrossProcessFrameConnector* cross_process_frame_connector_;
 
+  base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
+
   DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
 };