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

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

Issue 537703003: 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 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 // Received a redirect on the main frame. 1999 // Received a redirect on the main frame.
2000 WebDataSource* data_source = frame->provisionalDataSource(); 2000 WebDataSource* data_source = frame->provisionalDataSource();
2001 if (!data_source) { 2001 if (!data_source) {
2002 // Should only be invoked when we have a data source. 2002 // Should only be invoked when we have a data source.
2003 NOTREACHED(); 2003 NOTREACHED();
2004 return; 2004 return;
2005 } 2005 }
2006 std::vector<GURL> redirects; 2006 std::vector<GURL> redirects;
2007 GetRedirectChain(data_source, &redirects); 2007 GetRedirectChain(data_source, &redirects);
2008 if (redirects.size() >= 2) { 2008 if (redirects.size() >= 2) {
2009 CHECK(!render_view_->page_id_not_yet_reported_);
2009 Send(new FrameHostMsg_DidRedirectProvisionalLoad( 2010 Send(new FrameHostMsg_DidRedirectProvisionalLoad(
2010 routing_id_, 2011 routing_id_,
2011 render_view_->page_id_, 2012 render_view_->page_id_,
2012 redirects[redirects.size() - 2], 2013 redirects[redirects.size() - 2],
2013 redirects.back())); 2014 redirects.back()));
2014 } 2015 }
2015 } 2016 }
2016 2017
2017 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame, 2018 void RenderFrameImpl::didFailProvisionalLoad(blink::WebLocalFrame* frame,
2018 const blink::WebURLError& error) { 2019 const blink::WebURLError& error) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 if (internal_data->must_reset_scroll_and_scale_state()) { 2149 if (internal_data->must_reset_scroll_and_scale_state()) {
2149 render_view_->webview()->resetScrollAndScaleState(); 2150 render_view_->webview()->resetScrollAndScaleState();
2150 internal_data->set_must_reset_scroll_and_scale_state(false); 2151 internal_data->set_must_reset_scroll_and_scale_state(false);
2151 } 2152 }
2152 internal_data->set_use_error_page(false); 2153 internal_data->set_use_error_page(false);
2153 2154
2154 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2155 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2155 if (is_new_navigation) { 2156 if (is_new_navigation) {
2156 // We bump our Page ID to correspond with the new session history entry. 2157 // We bump our Page ID to correspond with the new session history entry.
2157 render_view_->page_id_ = render_view_->next_page_id_++; 2158 render_view_->page_id_ = render_view_->next_page_id_++;
2159 render_view_->page_id_not_yet_reported_ = true;
2158 2160
2159 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since 2161 // Don't update history_page_ids_ (etc) for kSwappedOutURL, since
2160 // we don't want to forget the entry that was there, and since we will 2162 // we don't want to forget the entry that was there, and since we will
2161 // never come back to kSwappedOutURL. Note that we have to call 2163 // never come back to kSwappedOutURL. Note that we have to call
2162 // UpdateSessionHistory and update page_id_ even in this case, so that 2164 // UpdateSessionHistory and update page_id_ even in this case, so that
2163 // the current entry gets a state update and so that we don't send a 2165 // the current entry gets a state update and so that we don't send a
2164 // state update to the wrong entry when we swap back in. 2166 // state update to the wrong entry when we swap back in.
2165 if (GetLoadingUrl() != GURL(kSwappedOutURL)) { 2167 if (GetLoadingUrl() != GURL(kSwappedOutURL)) {
2166 // Advance our offset in session history, applying the length limit. 2168 // Advance our offset in session history, applying the length limit.
2167 // There is now no forward history. 2169 // There is now no forward history.
(...skipping 16 matching lines...) Expand all
2184 // per navigation. 2186 // per navigation.
2185 // 2187 //
2186 // Note that we need to check if the page ID changed. In the case of a 2188 // Note that we need to check if the page ID changed. In the case of a
2187 // reload, the page ID doesn't change, and UpdateSessionHistory gets the 2189 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2188 // previous URL and the current page ID, which would be wrong. 2190 // previous URL and the current page ID, which would be wrong.
2189 if (navigation_state->pending_page_id() != -1 && 2191 if (navigation_state->pending_page_id() != -1 &&
2190 navigation_state->pending_page_id() != render_view_->page_id_ && 2192 navigation_state->pending_page_id() != render_view_->page_id_ &&
2191 !navigation_state->request_committed()) { 2193 !navigation_state->request_committed()) {
2192 // This is a successful session history navigation! 2194 // This is a successful session history navigation!
2193 render_view_->page_id_ = navigation_state->pending_page_id(); 2195 render_view_->page_id_ = navigation_state->pending_page_id();
2196 render_view_->page_id_not_yet_reported_ = true;
2194 2197
2195 render_view_->history_list_offset_ = 2198 render_view_->history_list_offset_ =
2196 navigation_state->pending_history_list_offset(); 2199 navigation_state->pending_history_list_offset();
2197 2200
2198 // If the history list is valid, our list of page IDs should be correct. 2201 // If the history list is valid, our list of page IDs should be correct.
2199 DCHECK(render_view_->history_list_length_ <= 0 || 2202 DCHECK(render_view_->history_list_length_ <= 0 ||
2200 render_view_->history_list_offset_ < 0 || 2203 render_view_->history_list_offset_ < 0 ||
2201 render_view_->history_list_offset_ >= 2204 render_view_->history_list_offset_ >=
2202 render_view_->history_list_length_ || 2205 render_view_->history_list_length_ ||
2203 render_view_->history_page_ids_[render_view_->history_list_offset_] 2206 render_view_->history_page_ids_[render_view_->history_list_offset_]
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 const blink::WebString& title, 2277 const blink::WebString& title,
2275 blink::WebTextDirection direction) { 2278 blink::WebTextDirection direction) {
2276 DCHECK(!frame_ || frame_ == frame); 2279 DCHECK(!frame_ || frame_ == frame);
2277 // Ignore all but top level navigations. 2280 // Ignore all but top level navigations.
2278 if (!frame->parent()) { 2281 if (!frame->parent()) {
2279 base::string16 title16 = title; 2282 base::string16 title16 = title;
2280 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( 2283 base::debug::TraceLog::GetInstance()->UpdateProcessLabel(
2281 routing_id_, base::UTF16ToUTF8(title16)); 2284 routing_id_, base::UTF16ToUTF8(title16));
2282 2285
2283 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); 2286 base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
2287 CHECK(!render_view_->page_id_not_yet_reported_);
2284 Send(new FrameHostMsg_UpdateTitle(routing_id_, 2288 Send(new FrameHostMsg_UpdateTitle(routing_id_,
2285 render_view_->page_id_, 2289 render_view_->page_id_,
2286 shortened_title, direction)); 2290 shortened_title, direction));
2287 } 2291 }
2288 2292
2289 // Also check whether we have new encoding name. 2293 // Also check whether we have new encoding name.
2290 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 2294 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
2291 } 2295 }
2292 2296
2293 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, 2297 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame,
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 else 3364 else
3361 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 3365 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
3362 3366
3363 DCHECK(!navigation_state->history_list_was_cleared()); 3367 DCHECK(!navigation_state->history_list_was_cleared());
3364 params.history_list_was_cleared = false; 3368 params.history_list_was_cleared = false;
3365 3369
3366 // Don't send this message while the subframe is swapped out. 3370 // Don't send this message while the subframe is swapped out.
3367 if (!is_swapped_out()) 3371 if (!is_swapped_out())
3368 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3372 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3369 } 3373 }
3374 render_view_->page_id_not_yet_reported_ = false;
3370 3375
3371 render_view_->last_page_id_sent_to_browser_ = 3376 render_view_->last_page_id_sent_to_browser_ =
3372 std::max(render_view_->last_page_id_sent_to_browser_, 3377 std::max(render_view_->last_page_id_sent_to_browser_,
3373 render_view_->page_id_); 3378 render_view_->page_id_);
3374 3379
3375 // If we end up reusing this WebRequest (for example, due to a #ref click), 3380 // If we end up reusing this WebRequest (for example, due to a #ref click),
3376 // we don't want the transition type to persist. Just clear it. 3381 // we don't want the transition type to persist. Just clear it.
3377 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 3382 navigation_state->set_transition_type(PAGE_TRANSITION_LINK);
3378 } 3383 }
3379 3384
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3849 3854
3850 #if defined(ENABLE_BROWSER_CDMS) 3855 #if defined(ENABLE_BROWSER_CDMS)
3851 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3856 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3852 if (!cdm_manager_) 3857 if (!cdm_manager_)
3853 cdm_manager_ = new RendererCdmManager(this); 3858 cdm_manager_ = new RendererCdmManager(this);
3854 return cdm_manager_; 3859 return cdm_manager_;
3855 } 3860 }
3856 #endif // defined(ENABLE_BROWSER_CDMS) 3861 #endif // defined(ENABLE_BROWSER_CDMS)
3857 3862
3858 } // namespace content 3863 } // 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