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

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

Issue 107893003: Make the renderer-side prerendering code use RenderFrames instead of RenderViews. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 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 | Annotate | Revision Log
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
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/favicon/favicon_tab_helper.h" 13 #include "chrome/browser/favicon/favicon_tab_helper.h"
14 #include "chrome/browser/history/history_tab_helper.h" 14 #include "chrome/browser/history/history_tab_helper.h"
15 #include "chrome/browser/history/history_types.h" 15 #include "chrome/browser/history/history_types.h"
16 #include "chrome/browser/prerender/prerender_field_trial.h" 16 #include "chrome/browser/prerender/prerender_field_trial.h"
17 #include "chrome/browser/prerender/prerender_final_status.h" 17 #include "chrome/browser/prerender/prerender_final_status.h"
18 #include "chrome/browser/prerender/prerender_handle.h" 18 #include "chrome/browser/prerender/prerender_handle.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 19 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_tracker.h" 20 #include "chrome/browser/prerender/prerender_tracker.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_tab_contents.h" 23 #include "chrome/browser/ui/browser_tab_contents.h"
24 #include "chrome/common/prerender_messages.h" 24 #include "chrome/common/prerender_messages.h"
25 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "content/public/browser/browser_child_process_host.h" 27 #include "content/public/browser/browser_child_process_host.h"
28 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/resource_request_details.h" 32 #include "content/public/browser/resource_request_details.h"
32 #include "content/public/browser/session_storage_namespace.h" 33 #include "content/public/browser/session_storage_namespace.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "content/public/browser/web_contents_delegate.h" 35 #include "content/public/browser/web_contents_delegate.h"
35 #include "content/public/browser/web_contents_view.h" 36 #include "content/public/browser/web_contents_view.h"
36 #include "content/public/common/favicon_url.h" 37 #include "content/public/common/favicon_url.h"
37 #include "content/public/common/frame_navigate_params.h" 38 #include "content/public/common/frame_navigate_params.h"
38 #include "ui/gfx/rect.h" 39 #include "ui/gfx/rect.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 PrerenderContents::PendingPrerenderInfo::~PendingPrerenderInfo() { 157 PrerenderContents::PendingPrerenderInfo::~PendingPrerenderInfo() {
157 } 158 }
158 159
159 void PrerenderContents::AddPendingPrerender( 160 void PrerenderContents::AddPendingPrerender(
160 scoped_ptr<PendingPrerenderInfo> pending_prerender_info) { 161 scoped_ptr<PendingPrerenderInfo> pending_prerender_info) {
161 pending_prerenders_.push_back(pending_prerender_info.release()); 162 pending_prerenders_.push_back(pending_prerender_info.release());
162 } 163 }
163 164
164 void PrerenderContents::PrepareForUse() { 165 void PrerenderContents::PrepareForUse() {
166 for (std::set<content::RenderFrameHost*>::iterator i =
167 render_frame_hosts_.begin(); i != render_frame_hosts_.end(); ++i) {
168 (*i)->Send(new PrerenderMsg_SetIsPrerendering((*i)->GetRoutingID(), false));
169 }
170 render_frame_hosts_.clear();
171
165 NotifyPrerenderStop(); 172 NotifyPrerenderStop();
166 173
167 SessionStorageNamespace* session_storage_namespace = NULL; 174 SessionStorageNamespace* session_storage_namespace = NULL;
168 if (prerender_contents_) { 175 if (prerender_contents_) {
169 // TODO(ajwong): This does not correctly handle storage for isolated apps. 176 // TODO(ajwong): This does not correctly handle storage for isolated apps.
170 session_storage_namespace = prerender_contents_-> 177 session_storage_namespace = prerender_contents_->
171 GetController().GetDefaultSessionStorageNamespace(); 178 GetController().GetDefaultSessionStorageNamespace();
172 } 179 }
173 prerender_manager_->StartPendingPrerenders( 180 prerender_manager_->StartPendingPrerenders(
174 child_id_, &pending_prerenders_, session_storage_namespace); 181 child_id_, &pending_prerenders_, session_storage_namespace);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return; 401 return;
395 402
396 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { 403 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: {
397 if (prerender_contents_.get()) { 404 if (prerender_contents_.get()) {
398 DCHECK_EQ(content::Source<WebContents>(source).ptr(), 405 DCHECK_EQ(content::Source<WebContents>(source).ptr(),
399 prerender_contents_.get()); 406 prerender_contents_.get());
400 407
401 content::Details<RenderViewHost> new_render_view_host(details); 408 content::Details<RenderViewHost> new_render_view_host(details);
402 OnRenderViewHostCreated(new_render_view_host.ptr()); 409 OnRenderViewHostCreated(new_render_view_host.ptr());
403 410
404 // When a new RenderView is created for a prerendering WebContents,
405 // tell the new RenderView it's being used for prerendering before any
406 // navigations occur. Note that this is always triggered before the
407 // first navigation, so there's no need to send the message just after
408 // the WebContents is created.
409 new_render_view_host->Send(
410 new PrerenderMsg_SetIsPrerendering(
411 new_render_view_host->GetRoutingID(),
412 true));
413
414 // Make sure the size of the RenderViewHost has been passed to the new 411 // Make sure the size of the RenderViewHost has been passed to the new
415 // RenderView. Otherwise, the size may not be sent until the 412 // RenderView. Otherwise, the size may not be sent until the
416 // RenderViewReady event makes it from the render process to the UI 413 // RenderViewReady event makes it from the render process to the UI
417 // thread of the browser process. When the RenderView receives its 414 // thread of the browser process. When the RenderView receives its
418 // size, is also sets itself to be visible, which would then break the 415 // size, is also sets itself to be visible, which would then break the
419 // visibility API. 416 // visibility API.
420 new_render_view_host->WasResized(); 417 new_render_view_host->WasResized();
421 prerender_contents_->WasHidden(); 418 prerender_contents_->WasHidden();
422 } 419 }
423 break; 420 break;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 return false; 538 return false;
542 } 539 }
543 return std::count_if(alias_urls_.begin(), alias_urls_.end(), 540 return std::count_if(alias_urls_.begin(), alias_urls_.end(),
544 std::bind2nd(std::equal_to<GURL>(), url)) != 0; 541 std::bind2nd(std::equal_to<GURL>(), url)) != 0;
545 } 542 }
546 543
547 void PrerenderContents::RenderProcessGone(base::TerminationStatus status) { 544 void PrerenderContents::RenderProcessGone(base::TerminationStatus status) {
548 Destroy(FINAL_STATUS_RENDERER_CRASHED); 545 Destroy(FINAL_STATUS_RENDERER_CRASHED);
549 } 546 }
550 547
548 void PrerenderContents::RenderFrameCreated(
549 content::RenderFrameHost* render_frame_host) {
550 render_frame_hosts_.insert(render_frame_host);
551 // When a new RenderFrame is created for a prerendering WebContents, tell the
552 // new RenderFrame it's being used for prerendering before any navigations
553 // occur. Note that this is always triggered before the first navigation, so
554 // there's no need to send the message just after the WebContents is created.
555 render_frame_host->Send(new PrerenderMsg_SetIsPrerendering(
556 render_frame_host->GetRoutingID(), true));
557 }
558
559 void PrerenderContents::RenderFrameDeleted(
560 content::RenderFrameHost* render_frame_host) {
561 render_frame_hosts_.erase(render_frame_host);
562 }
563
551 void PrerenderContents::DidStopLoading( 564 void PrerenderContents::DidStopLoading(
552 content::RenderViewHost* render_view_host) { 565 content::RenderViewHost* render_view_host) {
553 has_stopped_loading_ = true; 566 has_stopped_loading_ = true;
554 NotifyPrerenderStopLoading(); 567 NotifyPrerenderStopLoading();
555 } 568 }
556 569
557 void PrerenderContents::DidStartProvisionalLoadForFrame( 570 void PrerenderContents::DidStartProvisionalLoadForFrame(
558 int64 frame_id, 571 int64 frame_id,
559 int64 parent_frame_id, 572 int64 parent_frame_id,
560 bool is_main_frame, 573 bool is_main_frame,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return NULL; 761 return NULL;
749 return prerender_contents()->GetController(). 762 return prerender_contents()->GetController().
750 GetDefaultSessionStorageNamespace(); 763 GetDefaultSessionStorageNamespace();
751 } 764 }
752 765
753 void PrerenderContents::OnCancelPrerenderForPrinting() { 766 void PrerenderContents::OnCancelPrerenderForPrinting() {
754 Destroy(FINAL_STATUS_WINDOW_PRINT); 767 Destroy(FINAL_STATUS_WINDOW_PRINT);
755 } 768 }
756 769
757 } // namespace prerender 770 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698