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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 526493004: Revert of Keep a copy of page id in RenderViewHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 // Received a redirect on the main frame. 1990 // Received a redirect on the main frame.
1991 WebDataSource* data_source = frame->provisionalDataSource(); 1991 WebDataSource* data_source = frame->provisionalDataSource();
1992 if (!data_source) { 1992 if (!data_source) {
1993 // Should only be invoked when we have a data source. 1993 // Should only be invoked when we have a data source.
1994 NOTREACHED(); 1994 NOTREACHED();
1995 return; 1995 return;
1996 } 1996 }
1997 std::vector<GURL> redirects; 1997 std::vector<GURL> redirects;
1998 GetRedirectChain(data_source, &redirects); 1998 GetRedirectChain(data_source, &redirects);
1999 if (redirects.size() >= 2) { 1999 if (redirects.size() >= 2) {
2000 CHECK(!render_view_->page_id_not_yet_reported_);
2001 Send(new FrameHostMsg_DidRedirectProvisionalLoad( 2000 Send(new FrameHostMsg_DidRedirectProvisionalLoad(
2002 routing_id_, 2001 routing_id_,
2003 render_view_->page_id_, 2002 render_view_->page_id_,
2004 redirects[redirects.size() - 2], 2003 redirects[redirects.size() - 2],
2005 redirects.back())); 2004 redirects.back()));
2006 } 2005 }
2007 } 2006 }
2008 2007
2009 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, 2008 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame,
2010 const blink::WebURLError& error) { 2009 const blink::WebURLError& error) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 if (internal_data->must_reset_scroll_and_scale_state()) { 2139 if (internal_data->must_reset_scroll_and_scale_state()) {
2141 render_view_->webview()->resetScrollAndScaleState(); 2140 render_view_->webview()->resetScrollAndScaleState();
2142 internal_data->set_must_reset_scroll_and_scale_state(false); 2141 internal_data->set_must_reset_scroll_and_scale_state(false);
2143 } 2142 }
2144 internal_data->set_use_error_page(false); 2143 internal_data->set_use_error_page(false);
2145 2144
2146 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2145 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2147 if (is_new_navigation) { 2146 if (is_new_navigation) {
2148 // We bump our Page ID to correspond with the new session history entry. 2147 // We bump our Page ID to correspond with the new session history entry.
2149 render_view_->page_id_ = render_view_->next_page_id_++; 2148 render_view_->page_id_ = render_view_->next_page_id_++;
2150 render_view_->page_id_not_yet_reported_ = true;
2151 2149
2152 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since 2150 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since
2153 // we don't want to forget the entry that was there, and since we will 2151 // we don't want to forget the entry that was there, and since we will
2154 // never come back to kSwappedOutURL. Note that we have to call 2152 // never come back to kSwappedOutURL. Note that we have to call
2155 // UpdateSessionHistory and update page_id_ even in this case, so that 2153 // UpdateSessionHistory and update page_id_ even in this case, so that
2156 // the current entry gets a state update and so that we don't send a 2154 // the current entry gets a state update and so that we don't send a
2157 // state update to the wrong entry when we swap back in. 2155 // state update to the wrong entry when we swap back in.
2158 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { 2156 if (GetLoadingUrl() != GURL(kSwappedOutURL)) {
2159 // Advance our offset in session history, applying the length limit. 2157 // Advance our offset in session history, applying the length limit.
2160 // There is now no forward history. 2158 // There is now no forward history.
(...skipping 16 matching lines...) Expand all
2177 // per navigation. 2175 // per navigation.
2178 // 2176 //
2179 // Note that we need to check if the page ID changed. In the case of a 2177 // Note that we need to check if the page ID changed. In the case of a
2180 // reload, the page ID doesn't change, and UpdateSessionHistory gets the 2178 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2181 // previous URL and the current page ID, which would be wrong. 2179 // previous URL and the current page ID, which would be wrong.
2182 if (navigation_state->pending_page_id() != -1 && 2180 if (navigation_state->pending_page_id() != -1 &&
2183 navigation_state->pending_page_id() != render_view_->page_id_ && 2181 navigation_state->pending_page_id() != render_view_->page_id_ &&
2184 !navigation_state->request_committed()) { 2182 !navigation_state->request_committed()) {
2185 // This is a successful session history navigation! 2183 // This is a successful session history navigation!
2186 render_view_->page_id_ = navigation_state->pending_page_id(); 2184 render_view_->page_id_ = navigation_state->pending_page_id();
2187 render_view_->page_id_not_yet_reported_ = true;
2188 2185
2189 render_view_->history_list_offset_ = 2186 render_view_->history_list_offset_ =
2190 navigation_state->pending_history_list_offset(); 2187 navigation_state->pending_history_list_offset();
2191 2188
2192 // If the history list is valid, our list of page IDs should be correct. 2189 // If the history list is valid, our list of page IDs should be correct.
2193 DCHECK(render_view_->history_list_length_ <= 0 || 2190 DCHECK(render_view_->history_list_length_ <= 0 ||
2194 render_view_->history_list_offset_ < 0 || 2191 render_view_->history_list_offset_ < 0 ||
2195 render_view_->history_list_offset_ >= 2192 render_view_->history_list_offset_ >=
2196 render_view_->history_list_length_ || 2193 render_view_->history_list_length_ ||
2197 render_view_->history_page_ids_[render_view_->history_list_offset_] 2194 render_view_->history_page_ids_[render_view_->history_list_offset_]
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 const blink::WebString& title, 2265 const blink::WebString& title,
2269 blink::WebTextDirection direction) { 2266 blink::WebTextDirection direction) {
2270 DCHECK(!frame_ || frame_ == frame); 2267 DCHECK(!frame_ || frame_ == frame);
2271 // Ignore all but top level navigations. 2268 // Ignore all but top level navigations.
2272 if (!frame->parent()) { 2269 if (!frame->parent()) {
2273 base::string16 title16 = title; 2270 base::string16 title16 = title;
2274 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( 2271 base::debug::TraceLog::GetInstance()->UpdateProcessLabel(
2275 routing_id_, base::UTF16ToUTF8(title16)); 2272 routing_id_, base::UTF16ToUTF8(title16));
2276 2273
2277 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); 2274 base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
2278 CHECK(!render_view_->page_id_not_yet_reported_);
2279 Send(new FrameHostMsg_UpdateTitle(routing_id_, 2275 Send(new FrameHostMsg_UpdateTitle(routing_id_,
2280 render_view_->page_id_, 2276 render_view_->page_id_,
2281 shortened_title, direction)); 2277 shortened_title, direction));
2282 } 2278 }
2283 2279
2284 // Also check whether we have new encoding name. 2280 // Also check whether we have new encoding name.
2285 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 2281 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
2286 } 2282 }
2287 2283
2288 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, 2284 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame,
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 else 3351 else
3356 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 3352 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
3357 3353
3358 DCHECK(!navigation_state->history_list_was_cleared()); 3354 DCHECK(!navigation_state->history_list_was_cleared());
3359 params.history_list_was_cleared = false; 3355 params.history_list_was_cleared = false;
3360 3356
3361 // Don't send this message while the subframe is swapped out. 3357 // Don't send this message while the subframe is swapped out.
3362 if (!is_swapped_out()) 3358 if (!is_swapped_out())
3363 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3359 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3364 } 3360 }
3365 render_view_->page_id_not_yet_reported_ = false;
3366 3361
3367 render_view_->last_page_id_sent_to_browser_ = 3362 render_view_->last_page_id_sent_to_browser_ =
3368 std::max(render_view_->last_page_id_sent_to_browser_, 3363 std::max(render_view_->last_page_id_sent_to_browser_,
3369 render_view_->page_id_); 3364 render_view_->page_id_);
3370 3365
3371 // If we end up reusing this WebRequest (for example, due to a #ref click), 3366 // If we end up reusing this WebRequest (for example, due to a #ref click),
3372 // we don't want the transition type to persist. Just clear it. 3367 // we don't want the transition type to persist. Just clear it.
3373 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 3368 navigation_state->set_transition_type(PAGE_TRANSITION_LINK);
3374 } 3369 }
3375 3370
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3845 3840
3846 #if defined(ENABLE_BROWSER_CDMS) 3841 #if defined(ENABLE_BROWSER_CDMS)
3847 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3842 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3848 if (!cdm_manager_) 3843 if (!cdm_manager_)
3849 cdm_manager_ = new RendererCdmManager(this); 3844 cdm_manager_ = new RendererCdmManager(this);
3850 return cdm_manager_; 3845 return cdm_manager_;
3851 } 3846 }
3852 #endif // defined(ENABLE_BROWSER_CDMS) 3847 #endif // defined(ENABLE_BROWSER_CDMS)
3853 3848
3854 } // namespace content 3849 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_unittest.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698