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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 475783002: PlzNavigate: add cancel navigation logic for uncommitted requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for the navigation request ID Created 6 years, 4 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: content/browser/frame_host/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index fb46ae59b3d9c10ad87d021dd60dd5010efb342f..0a73afab7c59ce782a7d9ee4bf9c47fcb91c707b 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -15,23 +15,40 @@ namespace {
void OnBeginNavigation(const NavigationRequestInfo& info,
scoped_refptr<ResourceRequestBody> request_body,
+ int64 navigation_request_id,
int64 frame_node_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- ResourceDispatcherHostImpl::Get()->NavigationRequest(
- info, request_body, frame_node_id);
+ ResourceDispatcherHostImpl::Get()->StartNavigationRequest(
+ info, request_body, navigation_request_id, frame_node_id);
+}
+
+void OnDestructNavigationRequest(int64 navigation_request_id,
+ int64 frame_node_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ ResourceDispatcherHostImpl::Get()->CancelNavigationRequest(
+ navigation_request_id, frame_node_id);
}
} // namespace
+int64 NavigationRequest::next_navigation_request_id_ = 0;
+
NavigationRequest::NavigationRequest(const NavigationRequestInfo& info,
int64 frame_node_id)
- : info_(info),
+ : navigation_request_id_(++next_navigation_request_id_),
+ info_(info),
frame_node_id_(frame_node_id) {
}
NavigationRequest::~NavigationRequest() {
- // TODO(clamy): Cancel the corresponding request in ResourceDispatcherHost if
- // it has not commited yet.
+ // TODO(carlosk): Figure out when the navigation actually needs to be
+ // cancelled.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&OnDestructNavigationRequest,
+ navigation_request_id_, frame_node_id_));
}
void NavigationRequest::BeginNavigation(
@@ -40,7 +57,11 @@ void NavigationRequest::BeginNavigation(
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&OnBeginNavigation, info_, request_body, frame_node_id_));
+ base::Bind(&OnBeginNavigation,
+ info_,
+ request_body,
+ navigation_request_id_,
+ frame_node_id_));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698