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

Unified Diff: chrome/browser/prerender/prerender_contents.cc

Issue 6459005: Cancel prerender when we discover a download starting from a page we are prer... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Now with conflicts resolved Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_contents.cc
===================================================================
--- chrome/browser/prerender/prerender_contents.cc (revision 74377)
+++ chrome/browser/prerender/prerender_contents.cc (working copy)
@@ -11,6 +11,7 @@
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/renderer_host/resource_request_details.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/login/login_prompt.h"
@@ -82,6 +83,10 @@
registrar_.Add(this, NotificationType::AUTH_CANCELLED,
NotificationService::AllSources());
+ // Register all responses to see if we should cancel.
+ registrar_.Add(this, NotificationType::DOWNLOAD_INITIATED,
+ Source<RenderViewHostDelegate>(this));
+
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
@@ -95,6 +100,7 @@
void PrerenderContents::set_final_status(FinalStatus final_status) {
DCHECK(final_status >= FINAL_STATUS_USED && final_status < FINAL_STATUS_MAX);
DCHECK_EQ(FINAL_STATUS_MAX, final_status_);
+
final_status_ = final_status;
}
@@ -186,6 +192,7 @@
case NotificationType::PROFILE_DESTROYED:
Destroy(FINAL_STATUS_PROFILE_DESTROYED);
return;
+
case NotificationType::APP_TERMINATING:
Destroy(FINAL_STATUS_APP_TERMINATING);
return;
@@ -201,11 +208,22 @@
LoginHandler* handler = details_ptr->handler();
DCHECK(handler != NULL);
RenderViewHostDelegate* delegate = handler->GetRenderViewHostDelegate();
- if (controller == NULL && delegate == this)
+ if (controller == NULL && delegate == this) {
Destroy(FINAL_STATUS_AUTH_NEEDED);
+ return;
+ }
break;
}
+ case NotificationType::DOWNLOAD_INITIATED: {
+ // If the download is started from a RenderViewHost that we are
+ // delegating, kill the prerender. This will also stop the download and
Randy Smith (Not in Mondays) 2011/02/10 16:57:10 Can you give me the context for how killing the pr
dominich 2011/02/10 18:46:22 You're right - changed the comment to reflect that
+ // navigating to the page will restart it as expected.
+ DCHECK(Source<RenderViewHostDelegate>(source).ptr() == this);
+ Destroy(FINAL_STATUS_DOWNLOAD);
+ return;
+ }
+
default:
NOTREACHED() << "Unexpected notification sent.";
break;

Powered by Google App Engine
This is Rietveld 408576698