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

Side by Side Diff: chrome/browser/prerender/prerender_contents.cc

Issue 1519943002: Shortcut cross-process frame transfers to avoid pending NavigationEntries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/prerender/prerender_contents.h" 5 #include "chrome/browser/prerender/prerender_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 public: 85 public:
86 explicit WebContentsDelegateImpl(PrerenderContents* prerender_contents) 86 explicit WebContentsDelegateImpl(PrerenderContents* prerender_contents)
87 : prerender_contents_(prerender_contents) { 87 : prerender_contents_(prerender_contents) {
88 } 88 }
89 89
90 // content::WebContentsDelegate implementation: 90 // content::WebContentsDelegate implementation:
91 WebContents* OpenURLFromTab(WebContents* source, 91 WebContents* OpenURLFromTab(WebContents* source,
92 const OpenURLParams& params) override { 92 const OpenURLParams& params) override {
93 // |OpenURLFromTab| is typically called when a frame performs a navigation 93 // |OpenURLFromTab| is typically called when a frame performs a navigation
94 // that requires the browser to perform the transition instead of WebKit. 94 // that requires the browser to perform the transition instead of WebKit.
95 // Examples include prerendering a site that redirects to an app URL, or if 95 // Examples include client redirects to hosted app URLs.
96 // --site-per-process is specified and the prerendered frame redirects to a
97 // different origin.
98 // TODO(cbentzel): Consider supporting this for CURRENT_TAB dispositions, if 96 // TODO(cbentzel): Consider supporting this for CURRENT_TAB dispositions, if
99 // it is a common case during prerenders. 97 // it is a common case during prerenders.
100 prerender_contents_->Destroy(FINAL_STATUS_OPEN_URL); 98 prerender_contents_->Destroy(FINAL_STATUS_OPEN_URL);
101 return NULL; 99 return NULL;
102 } 100 }
103 101
102 bool ShouldTransferNavigation() override {
103 // Cancel the prerender if the navigation attempts to transfer to a
104 // different process. Examples include server redirects to privileged pages
105 // or cross-site subframe navigations in --site-per-process.
106 prerender_contents_->Destroy(FINAL_STATUS_OPEN_URL);
107 return false;
108 }
109
104 void CloseContents(content::WebContents* contents) override { 110 void CloseContents(content::WebContents* contents) override {
105 prerender_contents_->Destroy(FINAL_STATUS_CLOSED); 111 prerender_contents_->Destroy(FINAL_STATUS_CLOSED);
106 } 112 }
107 113
108 void CanDownload(const GURL& url, 114 void CanDownload(const GURL& url,
109 const std::string& request_method, 115 const std::string& request_method,
110 const base::Callback<void(bool)>& callback) override { 116 const base::Callback<void(bool)>& callback) override {
111 prerender_contents_->Destroy(FINAL_STATUS_DOWNLOAD); 117 prerender_contents_->Destroy(FINAL_STATUS_DOWNLOAD);
112 // Cancel the download. 118 // Cancel the download.
113 callback.Run(false); 119 callback.Run(false);
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 void PrerenderContents::AddResourceThrottle( 757 void PrerenderContents::AddResourceThrottle(
752 const base::WeakPtr<PrerenderResourceThrottle>& throttle) { 758 const base::WeakPtr<PrerenderResourceThrottle>& throttle) {
753 resource_throttles_.push_back(throttle); 759 resource_throttles_.push_back(throttle);
754 } 760 }
755 761
756 void PrerenderContents::AddNetworkBytes(int64 bytes) { 762 void PrerenderContents::AddNetworkBytes(int64 bytes) {
757 network_bytes_ += bytes; 763 network_bytes_ += bytes;
758 } 764 }
759 765
760 } // namespace prerender 766 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | content/browser/cross_site_transfer_browsertest.cc » ('j') | content/browser/frame_host/navigator_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698