| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); | 771 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); |
| 772 | 772 |
| 773 info->first_party_for_cookies = | 773 info->first_party_for_cookies = |
| 774 frame_tree_node->IsMainFrame() | 774 frame_tree_node->IsMainFrame() |
| 775 ? navigation_request->common_params().url | 775 ? navigation_request->common_params().url |
| 776 : frame_tree_node->frame_tree()->root()->current_url(); | 776 : frame_tree_node->frame_tree()->root()->current_url(); |
| 777 info->is_main_frame = frame_tree_node->IsMainFrame(); | 777 info->is_main_frame = frame_tree_node->IsMainFrame(); |
| 778 info->parent_is_main_frame = !frame_tree_node->parent() ? | 778 info->parent_is_main_frame = !frame_tree_node->parent() ? |
| 779 false : frame_tree_node->parent()->IsMainFrame(); | 779 false : frame_tree_node->parent()->IsMainFrame(); |
| 780 | 780 |
| 781 // TODO(clamy): Inform the RenderFrameHostManager that a navigation is about | 781 // First start the request on the IO thread. |
| 782 // to begin, so that it can speculatively spawn a new renderer if needed. | 782 navigation_request->BeginNavigation(info.Pass(), params.request_body); |
| 783 | 783 |
| 784 navigation_request->BeginNavigation(info.Pass(), params.request_body); | 784 // Then notify the RenderFrameHostManager so it can speculatively create a |
| 785 // RenderFrameHost (and potentially a new renderer process) in parallel. |
| 786 frame_tree_node->render_manager()->BeginNavigation(common_params); |
| 785 } | 787 } |
| 786 | 788 |
| 787 // PlzNavigate | 789 // PlzNavigate |
| 788 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, | 790 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, |
| 789 ResourceResponse* response, | 791 ResourceResponse* response, |
| 790 scoped_ptr<StreamHandle> body) { | 792 scoped_ptr<StreamHandle> body) { |
| 791 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 793 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 792 switches::kEnableBrowserSideNavigation)); | 794 switches::kEnableBrowserSideNavigation)); |
| 793 | 795 |
| 794 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 796 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
| (...skipping 20 matching lines...) Expand all Loading... |
| 815 render_frame_host->CommitNavigation(response, body.Pass(), | 817 render_frame_host->CommitNavigation(response, body.Pass(), |
| 816 navigation_request->common_params(), | 818 navigation_request->common_params(), |
| 817 navigation_request->commit_params()); | 819 navigation_request->commit_params()); |
| 818 } | 820 } |
| 819 | 821 |
| 820 // PlzNavigate | 822 // PlzNavigate |
| 821 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { | 823 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { |
| 822 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 824 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 823 switches::kEnableBrowserSideNavigation)); | 825 switches::kEnableBrowserSideNavigation)); |
| 824 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 826 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
| 827 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once |
| 828 // we properly cancel ongoing navigations. |
| 829 frame_tree_node->render_manager()->CleanUpNavigation(); |
| 825 } | 830 } |
| 826 | 831 |
| 827 // PlzNavigate | 832 // PlzNavigate |
| 828 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( | 833 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( |
| 829 FrameTreeNode* frame_tree_node) { | 834 FrameTreeNode* frame_tree_node) { |
| 830 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 835 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
| 831 } | 836 } |
| 832 | 837 |
| 833 void NavigatorImpl::LogResourceRequestTime( | 838 void NavigatorImpl::LogResourceRequestTime( |
| 834 base::TimeTicks timestamp, const GURL& url) { | 839 base::TimeTicks timestamp, const GURL& url) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 969 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 965 time_to_commit); | 970 time_to_commit); |
| 966 UMA_HISTOGRAM_TIMES( | 971 UMA_HISTOGRAM_TIMES( |
| 967 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 972 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 968 time_to_network); | 973 time_to_network); |
| 969 } | 974 } |
| 970 navigation_data_.reset(); | 975 navigation_data_.reset(); |
| 971 } | 976 } |
| 972 | 977 |
| 973 } // namespace content | 978 } // namespace content |
| OLD | NEW |