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

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

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