Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / frame_host / navigator_impl.h
index 1a60e5a..e142b3f 100644 (file)
@@ -5,18 +5,28 @@
 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_
 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_
 
+#include "base/containers/scoped_ptr_hash_map.h"
 #include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/tuple.h"
 #include "content/browser/frame_host/navigation_controller_impl.h"
 #include "content/browser/frame_host/navigator.h"
 #include "content/common/content_export.h"
+#include "url/gurl.h"
 
+class GURL;
 struct FrameMsg_Navigate_Params;
 
 namespace content {
 
 class NavigationControllerImpl;
 class NavigatorDelegate;
+class NavigatorTest;
 struct LoadCommittedDetails;
+struct CommitNavigationParams;
+struct CommonNavigationParams;
+struct RequestNavigationParams;
 
 // This class is an implementation of Navigator, responsible for managing
 // navigations in regular browser tabs.
@@ -25,56 +35,59 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
   NavigatorImpl(NavigationControllerImpl* navigation_controller,
                 NavigatorDelegate* delegate);
 
-  // Fills in |params| based on the content of |entry|.
-  static void MakeNavigateParams(const NavigationEntryImpl& entry,
-                                 const NavigationControllerImpl& controller,
-                                 NavigationController::ReloadType reload_type,
-                                 base::TimeTicks navigation_start,
-                                 FrameMsg_Navigate_Params* params);
-
   // Navigator implementation.
-  virtual NavigationController* GetController() OVERRIDE;
-  virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
-                                       const GURL& url,
-                                       bool is_transition_navigation) OVERRIDE;
-  virtual void DidFailProvisionalLoadWithError(
+  NavigationController* GetController() override;
+  void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
+                               const GURL& url,
+                               bool is_transition_navigation) override;
+  void DidFailProvisionalLoadWithError(
       RenderFrameHostImpl* render_frame_host,
       const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
-      OVERRIDE;
-  virtual void DidFailLoadWithError(
-      RenderFrameHostImpl* render_frame_host,
-      const GURL& url,
-      int error_code,
-      const base::string16& error_description) OVERRIDE;
-  virtual void DidNavigate(
-      RenderFrameHostImpl* render_frame_host,
-      const FrameHostMsg_DidCommitProvisionalLoad_Params&
-          input_params) OVERRIDE;
-  virtual bool NavigateToPendingEntry(
-      RenderFrameHostImpl* render_frame_host,
-      NavigationController::ReloadType reload_type) OVERRIDE;
-  virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
-                              const GURL& url,
-                              const Referrer& referrer,
-                              WindowOpenDisposition disposition,
-                              bool should_replace_current_entry,
-                              bool user_gesture) OVERRIDE;
-  virtual void RequestTransferURL(
-      RenderFrameHostImpl* render_frame_host,
-      const GURL& url,
-      const std::vector<GURL>& redirect_chain,
-      const Referrer& referrer,
-      ui::PageTransition page_transition,
-      WindowOpenDisposition disposition,
-      const GlobalRequestID& transferred_global_request_id,
-      bool should_replace_current_entry,
-      bool user_gesture) OVERRIDE;
-  virtual void CommitNavigation(
+      override;
+  void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
+                            const GURL& url,
+                            int error_code,
+                            const base::string16& error_description) override;
+  void DidNavigate(RenderFrameHostImpl* render_frame_host,
+                   const FrameHostMsg_DidCommitProvisionalLoad_Params&
+                       input_params) override;
+  bool NavigateToPendingEntry(
       RenderFrameHostImpl* render_frame_host,
-      const NavigationBeforeCommitInfo& info) OVERRIDE;
+      NavigationController::ReloadType reload_type) override;
+  void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
+                      const GURL& url,
+                      const Referrer& referrer,
+                      WindowOpenDisposition disposition,
+                      bool should_replace_current_entry,
+                      bool user_gesture) override;
+  void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
+                          const GURL& url,
+                          const std::vector<GURL>& redirect_chain,
+                          const Referrer& referrer,
+                          ui::PageTransition page_transition,
+                          WindowOpenDisposition disposition,
+                          const GlobalRequestID& transferred_global_request_id,
+                          bool should_replace_current_entry,
+                          bool user_gesture) override;
+  void OnBeginNavigation(FrameTreeNode* frame_tree_node,
+                         const FrameHostMsg_BeginNavigation_Params& params,
+                         const CommonNavigationParams& common_params) override;
+  void CommitNavigation(FrameTreeNode* frame_tree_node,
+                        ResourceResponse* response,
+                        scoped_ptr<StreamHandle> body) override;
+  void LogResourceRequestTime(base::TimeTicks timestamp,
+                              const GURL& url) override;
+  void LogBeforeUnloadTime(
+      const base::TimeTicks& renderer_before_unload_start_time,
+      const base::TimeTicks& renderer_before_unload_end_time) override;
+  void CancelNavigation(FrameTreeNode* frame_tree_node) override;
 
  private:
-  virtual ~NavigatorImpl() {}
+  // Holds data used to track browser side navigation metrics.
+  struct NavigationMetricsData;
+
+  friend class NavigatorTest;
+  ~NavigatorImpl() override;
 
   // Navigates to the given entry, which must be the pending entry.  Private
   // because all callers should use NavigateToPendingEntry.
@@ -89,6 +102,19 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
     RenderFrameHostImpl* render_frame_host,
     const GURL& url);
 
+  // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
+  // navigate. If no live renderer is present, then the navigation request will
+  // be sent directly to the ResourceDispatcherHost.
+  bool RequestNavigation(FrameTreeNode* frame_tree_node,
+                         const NavigationEntryImpl& entry,
+                         NavigationController::ReloadType reload_type,
+                         base::TimeTicks navigation_start);
+
+  void RecordNavigationMetrics(
+      const LoadCommittedDetails& details,
+      const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
+      SiteInstance* site_instance);
+
   // The NavigationController that will keep track of session history for all
   // RenderFrameHost objects using this NavigatorImpl.
   // TODO(nasko): Move ownership of the NavigationController from
@@ -99,6 +125,13 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
   // events. Can be NULL in tests.
   NavigatorDelegate* delegate_;
 
+  scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
+
+  // PlzNavigate: used to track the various ongoing NavigationRequests in the
+  // different FrameTreeNodes, based on the frame_tree_node_id.
+  typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
+  NavigationRequestMap navigation_request_map_;
+
   DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
 };