Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 701953006: PlzNavigate: Speculatively spawns a renderer process for navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated tests and refactored code based on CR comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); 747 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params));
748 748
749 info->first_party_for_cookies = 749 info->first_party_for_cookies =
750 frame_tree_node->IsMainFrame() 750 frame_tree_node->IsMainFrame()
751 ? navigation_request->common_params().url 751 ? navigation_request->common_params().url
752 : frame_tree_node->frame_tree()->root()->current_url(); 752 : frame_tree_node->frame_tree()->root()->current_url();
753 info->is_main_frame = frame_tree_node->IsMainFrame(); 753 info->is_main_frame = frame_tree_node->IsMainFrame();
754 info->parent_is_main_frame = !frame_tree_node->parent() ? 754 info->parent_is_main_frame = !frame_tree_node->parent() ?
755 false : frame_tree_node->parent()->IsMainFrame(); 755 false : frame_tree_node->parent()->IsMainFrame();
756 756
757 // TODO(clamy): Inform the RenderFrameHostManager that a navigation is about 757 // First starts the IO/net requests.
clamy 2014/12/09 15:09:52 nit: I would rephrase as "First start the request
carlosk 2014/12/16 01:53:47 Done.
758 // to begin, so that it can speculatively spawn a new renderer if needed.
759
760 navigation_request->BeginNavigation(info.Pass(), params.request_body); 758 navigation_request->BeginNavigation(info.Pass(), params.request_body);
759 // Then notify the manager so it can speculatively create a renderer in
clamy 2014/12/09 15:09:52 Please add a line before the comment. nit: s/manag
carlosk 2014/12/16 01:53:47 Done.
760 // parallel.
761 frame_tree_node->render_manager()->BeginNavigation(params, common_params);
761 } 762 }
762 763
763 // PlzNavigate 764 // PlzNavigate
764 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, 765 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node,
765 ResourceResponse* response, 766 ResourceResponse* response,
766 scoped_ptr<StreamHandle> body) { 767 scoped_ptr<StreamHandle> body) {
767 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 768 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
768 switches::kEnableBrowserSideNavigation)); 769 switches::kEnableBrowserSideNavigation));
769 770
770 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not 771 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not
(...skipping 20 matching lines...) Expand all
791 render_frame_host->CommitNavigation(response, body.Pass(), 792 render_frame_host->CommitNavigation(response, body.Pass(),
792 navigation_request->common_params(), 793 navigation_request->common_params(),
793 navigation_request->commit_params()); 794 navigation_request->commit_params());
794 } 795 }
795 796
796 // PlzNavigate 797 // PlzNavigate
797 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { 798 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) {
798 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 799 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
799 switches::kEnableBrowserSideNavigation)); 800 switches::kEnableBrowserSideNavigation));
800 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); 801 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id());
802 frame_tree_node->render_manager()->CleanUpNavigation();
801 } 803 }
802 804
803 // PlzNavigate 805 // PlzNavigate
804 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( 806 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting(
805 FrameTreeNode* frame_tree_node) { 807 FrameTreeNode* frame_tree_node) {
806 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); 808 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
807 } 809 }
808 810
809 void NavigatorImpl::LogResourceRequestTime( 811 void NavigatorImpl::LogResourceRequestTime(
810 base::TimeTicks timestamp, const GURL& url) { 812 base::TimeTicks timestamp, const GURL& url) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", 940 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted",
939 time_to_commit); 941 time_to_commit);
940 UMA_HISTOGRAM_TIMES( 942 UMA_HISTOGRAM_TIMES(
941 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", 943 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted",
942 time_to_network); 944 time_to_network);
943 } 945 }
944 navigation_data_.reset(); 946 navigation_data_.reset();
945 } 947 }
946 948
947 } // namespace content 949 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698