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

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

Issue 1415603018: OOPIF: Support session restore by combining/splitting frame states. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up and fix bugs 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
« no previous file with comments | « content/renderer/history_serialization.cc ('k') | content/test/test_render_view_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 351
352 bool IsBrowserInitiated(NavigationParams* pending) { 352 bool IsBrowserInitiated(NavigationParams* pending) {
353 // A navigation resulting from loading a javascript URL should not be treated 353 // A navigation resulting from loading a javascript URL should not be treated
354 // as a browser initiated event. Instead, we want it to look as if the page 354 // as a browser initiated event. Instead, we want it to look as if the page
355 // initiated any load resulting from JS execution. 355 // initiated any load resulting from JS execution.
356 return pending && 356 return pending &&
357 !pending->common_params.url.SchemeIs(url::kJavaScriptScheme); 357 !pending->common_params.url.SchemeIs(url::kJavaScriptScheme);
358 } 358 }
359 359
360 bool IsHistoryNavigation(const PageState& page_state,
361 const ExplodedFrameState& frame_state) {
362 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
363 return frame_state.item_sequence_number != 0;
364
365 return page_state.IsValid();
366 }
367
360 NOINLINE void CrashIntentionally() { 368 NOINLINE void CrashIntentionally() {
361 // NOTE(shess): Crash directly rather than using NOTREACHED() so 369 // NOTE(shess): Crash directly rather than using NOTREACHED() so
362 // that the signature is easier to triage in crash reports. 370 // that the signature is easier to triage in crash reports.
363 // 371 //
364 // Linker's ICF feature may merge this function with other functions with the 372 // Linker's ICF feature may merge this function with other functions with the
365 // same definition and it may confuse the crash report processing system. 373 // same definition and it may confuse the crash report processing system.
366 static int static_variable_to_make_this_function_unique = 0; 374 static int static_variable_to_make_this_function_unique = 0;
367 base::debug::Alias(&static_variable_to_make_this_function_unique); 375 base::debug::Alias(&static_variable_to_make_this_function_unique);
368 376
369 volatile int* zero = nullptr; 377 volatile int* zero = nullptr;
(...skipping 3870 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 if (entry) { 4248 if (entry) {
4241 params.page_state = HistoryEntryToPageState(entry); 4249 params.page_state = HistoryEntryToPageState(entry);
4242 post_id = ExtractPostId(entry->root()); 4250 post_id = ExtractPostId(entry->root());
4243 } else { 4251 } else {
4244 params.page_state = PageState::CreateFromURL(request.url()); 4252 params.page_state = PageState::CreateFromURL(request.url());
4245 } 4253 }
4246 } else { 4254 } else {
4247 // In --site-per-process, just send a single HistoryItem for this frame, 4255 // In --site-per-process, just send a single HistoryItem for this frame,
4248 // rather than the whole tree. It will be stored in the corresponding 4256 // rather than the whole tree. It will be stored in the corresponding
4249 // FrameNavigationEntry. 4257 // FrameNavigationEntry.
4250 params.page_state = SingleHistoryItemToPageState(item); 4258 params.frame_state = HistoryItemToFrameState(item);
4251 post_id = ExtractPostId(item); 4259 post_id = ExtractPostId(item);
4252 } 4260 }
4253 params.frame_unique_name = item.target().utf8(); 4261 params.frame_unique_name = item.target().utf8();
4254 params.item_sequence_number = item.itemSequenceNumber(); 4262 params.item_sequence_number = item.itemSequenceNumber();
4255 params.document_sequence_number = item.documentSequenceNumber(); 4263 params.document_sequence_number = item.documentSequenceNumber();
4256 4264
4257 if (!frame->parent()) { 4265 if (!frame->parent()) {
4258 // Top-level navigation. 4266 // Top-level navigation.
4259 4267
4260 // Reset the zoom limits in case a plugin had changed them previously. This 4268 // Reset the zoom limits in case a plugin had changed them previously. This
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 NavigateInternal(common_params, StartNavigationParams(), request_params, 4427 NavigateInternal(common_params, StartNavigationParams(), request_params,
4420 stream_override.Pass()); 4428 stream_override.Pass());
4421 } 4429 }
4422 4430
4423 void RenderFrameImpl::OnFailedNavigation( 4431 void RenderFrameImpl::OnFailedNavigation(
4424 const CommonNavigationParams& common_params, 4432 const CommonNavigationParams& common_params,
4425 const RequestNavigationParams& request_params, 4433 const RequestNavigationParams& request_params,
4426 bool has_stale_copy_in_cache, 4434 bool has_stale_copy_in_cache,
4427 int error_code) { 4435 int error_code) {
4428 bool is_reload = IsReload(common_params.navigation_type); 4436 bool is_reload = IsReload(common_params.navigation_type);
4429 bool is_history_navigation = request_params.page_state.IsValid(); 4437 bool is_history_navigation = IsHistoryNavigation(request_params.page_state,
4438 request_params.frame_state);
4430 WebURLRequest::CachePolicy cache_policy = 4439 WebURLRequest::CachePolicy cache_policy =
4431 WebURLRequest::UseProtocolCachePolicy; 4440 WebURLRequest::UseProtocolCachePolicy;
4432 RenderFrameImpl::PrepareRenderViewForNavigation( 4441 RenderFrameImpl::PrepareRenderViewForNavigation(
4433 common_params.url, request_params, &is_reload, &cache_policy); 4442 common_params.url, request_params, &is_reload, &cache_policy);
4434 4443
4435 GetContentClient()->SetActiveURL(common_params.url); 4444 GetContentClient()->SetActiveURL(common_params.url);
4436 4445
4437 pending_navigation_params_.reset(new NavigationParams( 4446 pending_navigation_params_.reset(new NavigationParams(
4438 common_params, StartNavigationParams(), request_params)); 4447 common_params, StartNavigationParams(), request_params));
4439 4448
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
4749 const StartNavigationParams& start_params, 4758 const StartNavigationParams& start_params,
4750 const RequestNavigationParams& request_params, 4759 const RequestNavigationParams& request_params,
4751 scoped_ptr<StreamOverrideParameters> stream_params) { 4760 scoped_ptr<StreamOverrideParameters> stream_params) {
4752 bool browser_side_navigation = 4761 bool browser_side_navigation =
4753 base::CommandLine::ForCurrentProcess()->HasSwitch( 4762 base::CommandLine::ForCurrentProcess()->HasSwitch(
4754 switches::kEnableBrowserSideNavigation); 4763 switches::kEnableBrowserSideNavigation);
4755 4764
4756 // Lower bound for browser initiated navigation start time. 4765 // Lower bound for browser initiated navigation start time.
4757 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 4766 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
4758 bool is_reload = IsReload(common_params.navigation_type); 4767 bool is_reload = IsReload(common_params.navigation_type);
4759 bool is_history_navigation = request_params.page_state.IsValid(); 4768 bool is_history_navigation = IsHistoryNavigation(request_params.page_state,
4769 request_params.frame_state);
4760 WebURLRequest::CachePolicy cache_policy = 4770 WebURLRequest::CachePolicy cache_policy =
4761 WebURLRequest::UseProtocolCachePolicy; 4771 WebURLRequest::UseProtocolCachePolicy;
4762 RenderFrameImpl::PrepareRenderViewForNavigation( 4772 RenderFrameImpl::PrepareRenderViewForNavigation(
4763 common_params.url, request_params, &is_reload, &cache_policy); 4773 common_params.url, request_params, &is_reload, &cache_policy);
4764 4774
4765 GetContentClient()->SetActiveURL(common_params.url); 4775 GetContentClient()->SetActiveURL(common_params.url);
4766 4776
4767 // If this frame isn't in the same process as the main frame, it may naively 4777 // If this frame isn't in the same process as the main frame, it may naively
4768 // assume that this is the first navigation in the iframe, but this may not 4778 // assume that this is the first navigation in the iframe, but this may not
4769 // actually be the case. Inform the frame's state machine if this frame has 4779 // actually be the case. Inform the frame's state machine if this frame has
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
4835 request = frame_->requestForReload(load_type, override_url); 4845 request = frame_->requestForReload(load_type, override_url);
4836 } 4846 }
4837 should_load_request = true; 4847 should_load_request = true;
4838 } else if (is_history_navigation) { 4848 } else if (is_history_navigation) {
4839 // We must know the page ID of the page we are navigating back to. 4849 // We must know the page ID of the page we are navigating back to.
4840 DCHECK_NE(request_params.page_id, -1); 4850 DCHECK_NE(request_params.page_id, -1);
4841 // We must know the nav entry ID of the page we are navigating back to, 4851 // We must know the nav entry ID of the page we are navigating back to,
4842 // which should be the case because history navigations are routed via the 4852 // which should be the case because history navigations are routed via the
4843 // browser. 4853 // browser.
4844 DCHECK_NE(0, request_params.nav_entry_id); 4854 DCHECK_NE(0, request_params.nav_entry_id);
4845 scoped_ptr<HistoryEntry> entry =
4846 PageStateToHistoryEntry(request_params.page_state);
4847 if (entry) {
4848 // Ensure we didn't save the swapped out URL in UpdateState, since the
4849 // browser should never be telling us to navigate to swappedout://.
4850 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
4851 4855
4852 if (!browser_side_navigation) { 4856 scoped_ptr<NavigationParams> navigation_params(
4853 scoped_ptr<NavigationParams> navigation_params( 4857 new NavigationParams(*pending_navigation_params_.get()));
4854 new NavigationParams(*pending_navigation_params_.get())); 4858
4855 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { 4859 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4860 !browser_side_navigation) {
4861 // In --site-per-process, the browser process sends a WebHistoryItem
4862 // destined for this frame.
4863 SetPendingNavigationParams(navigation_params.Pass());
4864 blink::WebHistoryItem history_item =
4865 FrameStateToHistoryItem(request_params.frame_state);
4866 blink::WebHistoryLoadType load_type =
4867 request_params.is_same_document_history_load
4868 ? blink::WebHistorySameDocumentLoad
4869 : blink::WebHistoryDifferentDocumentLoad;
4870
4871 // Navigate the frame directly.
4872 // TODO(creis): Use InitialHistoryLoad rather than BackForward for a
4873 // history navigation in a newly created subframe.
4874 WebURLRequest request =
4875 frame_->requestFromHistoryItem(history_item, cache_policy);
4876 frame_->load(request, blink::WebFrameLoadType::BackForward, history_item,
4877 load_type);
4878 } else {
4879 scoped_ptr<HistoryEntry> entry =
4880 PageStateToHistoryEntry(request_params.page_state);
4881 if (entry) {
4882 // Ensure we didn't save the swapped out URL in UpdateState, since the
4883 // browser should never be telling us to navigate to swappedout://.
4884 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
4885
4886 if (!browser_side_navigation) {
4856 // By default, tell the HistoryController to go the deserialized 4887 // By default, tell the HistoryController to go the deserialized
4857 // HistoryEntry. This only works if all frames are in the same 4888 // HistoryEntry. This only works if all frames are in the same
4858 // process. 4889 // process.
4859 DCHECK(!frame_->parent()); 4890 DCHECK(!frame_->parent());
4860 render_view_->history_controller()->GoToEntry( 4891 render_view_->history_controller()->GoToEntry(
4861 frame_, entry.Pass(), navigation_params.Pass(), cache_policy); 4892 frame_, entry.Pass(), navigation_params.Pass(), cache_policy);
4862 } else { 4893 } else {
4863 // In --site-per-process, the browser process sends a single 4894 // TODO(clamy): this should be set to the HistoryItem sent by the
4864 // WebHistoryItem destined for this frame. 4895 // browser once the HistoryController has moved to the browser.
4865 // TODO(creis): Change PageState to FrameState. In the meantime, we 4896 // TODO(clamy): distinguish between different document and same
4866 // store the relevant frame's WebHistoryItem in the root of the 4897 // document
4867 // PageState. 4898 // loads.
4868 SetPendingNavigationParams(navigation_params.Pass()); 4899 // TODO(clamy): update this for subframes history loads.
4869 blink::WebHistoryItem history_item = entry->root(); 4900 item_for_history_navigation =
4870 blink::WebHistoryLoadType load_type = 4901 entry->GetHistoryNodeForFrame(this)->item();
4871 request_params.is_same_document_history_load 4902 load_type = blink::WebFrameLoadType::BackForward;
4872 ? blink::WebHistorySameDocumentLoad 4903 should_load_request = true;
4873 : blink::WebHistoryDifferentDocumentLoad;
4874
4875 // Navigate the frame directly.
4876 // TODO(creis): Use InitialHistoryLoad rather than BackForward for a
4877 // history navigation in a newly created subframe.
4878 WebURLRequest request =
4879 frame_->requestFromHistoryItem(history_item, cache_policy);
4880 frame_->load(request, blink::WebFrameLoadType::BackForward,
4881 history_item, load_type);
4882 } 4904 }
4883 } else {
4884 // TODO(clamy): this should be set to the HistoryItem sent by the
4885 // browser once the HistoryController has moved to the browser.
4886 // TODO(clamy): distinguish between different document and same document
4887 // loads.
4888 // TODO(clamy): update this for subframes history loads.
4889 item_for_history_navigation =
4890 entry->GetHistoryNodeForFrame(this)->item();
4891 load_type = blink::WebFrameLoadType::BackForward;
4892 should_load_request = true;
4893 } 4905 }
4894 } 4906 }
4895 } else { 4907 } else {
4896 // Navigate to the given URL. 4908 // Navigate to the given URL.
4897 if (!start_params.extra_headers.empty() && !browser_side_navigation) { 4909 if (!start_params.extra_headers.empty() && !browser_side_navigation) {
4898 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), 4910 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(),
4899 start_params.extra_headers.end(), 4911 start_params.extra_headers.end(),
4900 "\n"); 4912 "\n");
4901 i.GetNext();) { 4913 i.GetNext();) {
4902 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 4914 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5197 << params.url.possibly_invalid_spec(); 5209 << params.url.possibly_invalid_spec();
5198 } 5210 }
5199 } 5211 }
5200 5212
5201 void RenderFrameImpl::SendUpdateState() { 5213 void RenderFrameImpl::SendUpdateState() {
5202 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); 5214 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
5203 if (current_history_item_.isNull()) 5215 if (current_history_item_.isNull())
5204 return; 5216 return;
5205 5217
5206 Send(new FrameHostMsg_UpdateState( 5218 Send(new FrameHostMsg_UpdateState(
5207 routing_id_, SingleHistoryItemToPageState(current_history_item_))); 5219 routing_id_, HistoryItemToFrameState(current_history_item_)));
5208 } 5220 }
5209 5221
5210 void RenderFrameImpl::SendFailedProvisionalLoad( 5222 void RenderFrameImpl::SendFailedProvisionalLoad(
5211 const blink::WebURLRequest& request, 5223 const blink::WebURLRequest& request,
5212 const blink::WebURLError& error, 5224 const blink::WebURLError& error,
5213 blink::WebLocalFrame* frame) { 5225 blink::WebLocalFrame* frame) {
5214 bool show_repost_interstitial = 5226 bool show_repost_interstitial =
5215 (error.reason == net::ERR_CACHE_MISS && 5227 (error.reason == net::ERR_CACHE_MISS &&
5216 base::EqualsASCII(base::StringPiece16(request.httpMethod()), "POST")); 5228 base::EqualsASCII(base::StringPiece16(request.httpMethod()), "POST"));
5217 5229
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5283 // from the network. 5295 // from the network.
5284 // 5296 //
5285 // TODO(davidben): Remove this in favor of passing a cache policy to the 5297 // TODO(davidben): Remove this in favor of passing a cache policy to the
5286 // loadHistoryItem call in OnNavigate. That requires not overloading 5298 // loadHistoryItem call in OnNavigate. That requires not overloading
5287 // UseProtocolCachePolicy to mean both "normal load" and "determine cache 5299 // UseProtocolCachePolicy to mean both "normal load" and "determine cache
5288 // policy based on load type, etc". 5300 // policy based on load type, etc".
5289 internal_data->set_cache_policy_override( 5301 internal_data->set_cache_policy_override(
5290 WebURLRequest::UseProtocolCachePolicy); 5302 WebURLRequest::UseProtocolCachePolicy);
5291 } 5303 }
5292 5304
5293 if (IsReload(pending_navigation_params_->common_params.navigation_type)) 5305 if (IsReload(pending_navigation_params_->common_params.navigation_type)) {
5294 document_state->set_load_type(DocumentState::RELOAD); 5306 document_state->set_load_type(DocumentState::RELOAD);
5295 else if (pending_navigation_params_->request_params.page_state.IsValid()) 5307 } else if (IsHistoryNavigation(
5308 pending_navigation_params_->request_params.page_state,
5309 pending_navigation_params_->request_params.frame_state)) {
5296 document_state->set_load_type(DocumentState::HISTORY_LOAD); 5310 document_state->set_load_type(DocumentState::HISTORY_LOAD);
5297 else 5311 } else {
5298 document_state->set_load_type(DocumentState::NORMAL_LOAD); 5312 document_state->set_load_type(DocumentState::NORMAL_LOAD);
5313 }
5299 5314
5300 internal_data->set_is_overriding_user_agent( 5315 internal_data->set_is_overriding_user_agent(
5301 pending_navigation_params_->request_params.is_overriding_user_agent); 5316 pending_navigation_params_->request_params.is_overriding_user_agent);
5302 internal_data->set_must_reset_scroll_and_scale_state( 5317 internal_data->set_must_reset_scroll_and_scale_state(
5303 pending_navigation_params_->common_params.navigation_type == 5318 pending_navigation_params_->common_params.navigation_type ==
5304 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 5319 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
5305 document_state->set_can_load_local_resources( 5320 document_state->set_can_load_local_resources(
5306 pending_navigation_params_->request_params.can_load_local_resources); 5321 pending_navigation_params_->request_params.can_load_local_resources);
5307 } 5322 }
5308 5323
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
5492 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5507 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5493 scoped_refptr<media::AudioOutputDevice> device = 5508 scoped_refptr<media::AudioOutputDevice> device =
5494 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5509 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5495 security_origin); 5510 security_origin);
5496 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5511 media::OutputDeviceStatus status = device->GetDeviceStatus();
5497 device->Stop(); 5512 device->Stop();
5498 callback.Run(status); 5513 callback.Run(status);
5499 } 5514 }
5500 5515
5501 } // namespace content 5516 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/history_serialization.cc ('k') | content/test/test_render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698