| 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); | 769 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); |
| 770 | 770 |
| 771 info->first_party_for_cookies = | 771 info->first_party_for_cookies = |
| 772 frame_tree_node->IsMainFrame() | 772 frame_tree_node->IsMainFrame() |
| 773 ? navigation_request->common_params().url | 773 ? navigation_request->common_params().url |
| 774 : frame_tree_node->frame_tree()->root()->current_url(); | 774 : frame_tree_node->frame_tree()->root()->current_url(); |
| 775 info->is_main_frame = frame_tree_node->IsMainFrame(); | 775 info->is_main_frame = frame_tree_node->IsMainFrame(); |
| 776 info->parent_is_main_frame = !frame_tree_node->parent() ? | 776 info->parent_is_main_frame = !frame_tree_node->parent() ? |
| 777 false : frame_tree_node->parent()->IsMainFrame(); | 777 false : frame_tree_node->parent()->IsMainFrame(); |
| 778 | 778 |
| 779 // TODO(clamy): Inform the RenderFrameHostManager that a navigation is about | 779 // First start the request on the IO thread. |
| 780 // to begin, so that it can speculatively spawn a new renderer if needed. | 780 navigation_request->BeginNavigation(info.Pass(), params.request_body); |
| 781 | 781 |
| 782 navigation_request->BeginNavigation(info.Pass(), params.request_body); | 782 // Then notify the RenderFrameHostManager so it can speculatively create a |
| 783 // renderer in parallel. |
| 784 frame_tree_node->render_manager()->BeginNavigation(common_params); |
| 783 } | 785 } |
| 784 | 786 |
| 785 // PlzNavigate | 787 // PlzNavigate |
| 786 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, | 788 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, |
| 787 ResourceResponse* response, | 789 ResourceResponse* response, |
| 788 scoped_ptr<StreamHandle> body) { | 790 scoped_ptr<StreamHandle> body) { |
| 789 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 791 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 790 switches::kEnableBrowserSideNavigation)); | 792 switches::kEnableBrowserSideNavigation)); |
| 791 | 793 |
| 792 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 794 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
| (...skipping 20 matching lines...) Expand all Loading... |
| 813 render_frame_host->CommitNavigation(response, body.Pass(), | 815 render_frame_host->CommitNavigation(response, body.Pass(), |
| 814 navigation_request->common_params(), | 816 navigation_request->common_params(), |
| 815 navigation_request->commit_params()); | 817 navigation_request->commit_params()); |
| 816 } | 818 } |
| 817 | 819 |
| 818 // PlzNavigate | 820 // PlzNavigate |
| 819 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { | 821 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { |
| 820 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 822 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 821 switches::kEnableBrowserSideNavigation)); | 823 switches::kEnableBrowserSideNavigation)); |
| 822 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 824 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
| 825 // TODO(carlosk): move this cleanup into the NavigationRequest destructor once |
| 826 // we properly cancel ongoing navigations. |
| 827 frame_tree_node->render_manager()->CleanUpNavigation(); |
| 823 } | 828 } |
| 824 | 829 |
| 825 // PlzNavigate | 830 // PlzNavigate |
| 826 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( | 831 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( |
| 827 FrameTreeNode* frame_tree_node) { | 832 FrameTreeNode* frame_tree_node) { |
| 828 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 833 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
| 829 } | 834 } |
| 830 | 835 |
| 831 void NavigatorImpl::LogResourceRequestTime( | 836 void NavigatorImpl::LogResourceRequestTime( |
| 832 base::TimeTicks timestamp, const GURL& url) { | 837 base::TimeTicks timestamp, const GURL& url) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 967 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 963 time_to_commit); | 968 time_to_commit); |
| 964 UMA_HISTOGRAM_TIMES( | 969 UMA_HISTOGRAM_TIMES( |
| 965 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 970 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 966 time_to_network); | 971 time_to_network); |
| 967 } | 972 } |
| 968 navigation_data_.reset(); | 973 navigation_data_.reset(); |
| 969 } | 974 } |
| 970 | 975 |
| 971 } // namespace content | 976 } // namespace content |
| OLD | NEW |