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

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: Addressed CR comments and removed the weird Observer. Trying to get this CL through and have the mo… 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..1ce5ef238f2103f9bc5d13b641eb9339e1bc875c 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -13,25 +13,35 @@ namespace content {
namespace {
+// The next available browser-global navigation request ID.
+static int64 next_navigation_request_id_ = 0;
+
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 CancelNavigationRequest(int64 navigation_request_id,
+ int64 frame_node_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ ResourceDispatcherHostImpl::Get()->CancelNavigationRequest(
+ navigation_request_id, frame_node_id);
}
} // namespace
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.
}
void NavigationRequest::BeginNavigation(
@@ -40,7 +50,20 @@ 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_));
+}
+
+void NavigationRequest::CancelNavigation() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&CancelNavigationRequest,
+ navigation_request_id_, frame_node_id_));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698