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

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

Issue 141163002: Make PrerenderTracker's resource_throttle_io_thread_map_ use RenderFrame IDs instead of RenderView … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify code Created 6 years, 11 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_resource_throttle.cc
===================================================================
--- chrome/browser/prerender/prerender_resource_throttle.cc (revision 245386)
+++ chrome/browser/prerender/prerender_resource_throttle.cc (working copy)
@@ -6,7 +6,6 @@
#include "chrome/browser/prerender/prerender_final_status.h"
#include "chrome/browser/prerender/prerender_manager.h"
-#include "chrome/browser/prerender/prerender_tracker.h"
#include "chrome/browser/prerender/prerender_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@@ -29,24 +28,13 @@
g_prerender_contents_for_testing = contents;
}
-PrerenderResourceThrottle::PrerenderResourceThrottle(
- net::URLRequest* request,
- PrerenderTracker* tracker)
- : request_(request),
- tracker_(tracker) {
+PrerenderResourceThrottle::PrerenderResourceThrottle(net::URLRequest* request)
+ : request_(request) {
}
void PrerenderResourceThrottle::WillStartRequest(bool* defer) {
const content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request_);
- int child_id = info->GetChildID();
- int route_id = info->GetRouteID();
-
- // If the prerender was used since the throttle was added, leave it
- // alone.
- if (!tracker_->IsPrerenderingOnIOThread(child_id, route_id))
- return;
-
*defer = true;
content::BrowserThread::PostTask(
content::BrowserThread::UI,
@@ -60,14 +48,6 @@
bool* defer) {
const content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request_);
- int child_id = info->GetChildID();
- int route_id = info->GetRouteID();
-
- // If the prerender was used since the throttle was added, leave it
- // alone.
- if (!tracker_->IsPrerenderingOnIOThread(child_id, route_id))
- return;
-
*defer = true;
std::string header;
request_->GetResponseHeaderByName(kFollowOnlyWhenPrerenderShown, &header);
@@ -148,16 +128,8 @@
prerender_contents->Destroy(FINAL_STATUS_BAD_DEFERRED_REDIRECT);
cancel = true;
} else {
- // Defer the redirect until the prerender is used or
- // canceled. It is possible for the UI thread to used the
- // prerender at the same time. But then |tracker_| will resume
- // the request soon in
- // PrerenderTracker::RemovePrerenderOnIOThread.
- content::BrowserThread::PostTask(
- content::BrowserThread::IO,
- FROM_HERE,
- base::Bind(&PrerenderResourceThrottle::AddResourceThrottle,
- throttle));
+ // Defer the redirect until the prerender is used or canceled.
+ prerender_contents->AddResourceThrottle(throttle);
davidben 2014/01/20 20:51:57 This is fine (the assumption the code is making is
jam 2014/01/21 00:30:08 yep precisely, I was worried about this case as we
return;
}
}
@@ -181,12 +153,4 @@
return PrerenderContents::FromWebContents(web_contents);
}
-void PrerenderResourceThrottle::AddResourceThrottle() {
- const content::ResourceRequestInfo* info =
- content::ResourceRequestInfo::ForRequest(request_);
- int child_id = info->GetChildID();
- int route_id = info->GetRouteID();
- tracker_->AddResourceThrottleOnIOThread(child_id, route_id, AsWeakPtr());
-}
-
} // namespace prerender

Powered by Google App Engine
This is Rietveld 408576698