Navigation: Move |navigation_id_| from NavigationHandleImpl to NavigationRequest.
This includes renaming it to navigation_handle_id_, which is modified
before creating NavigationHandleImpl.
Bug: 916537
Change-Id: Iea54a45c247b2c1541f56092dc461d749c27f67a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718709
Commit-Queue: Mohamed Abdelhalim <zetamoo@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680878}
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index 1b68c53..b798e7a3 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -44,13 +44,6 @@
// Overrideable via SetCommitTimeoutForTesting.
base::TimeDelta g_commit_timeout = kDefaultCommitTimeout;
-// Use this to get a new unique ID for a NavigationHandle during construction.
-// The returned ID is guaranteed to be nonzero (zero is the "no ID" indicator).
-int64_t CreateUniqueHandleID() {
- static int64_t unique_id_counter = 0;
- return ++unique_id_counter;
-}
-
} // namespace
NavigationHandleImpl::NavigationHandleImpl(
@@ -60,7 +53,6 @@
: navigation_request_(navigation_request),
request_headers_(std::move(request_headers)),
pending_nav_entry_id_(pending_nav_entry_id),
- navigation_id_(CreateUniqueHandleID()),
reload_type_(ReloadType::NONE),
restore_type_(RestoreType::NONE) {
const GURL& url = navigation_request_->common_params().url;
@@ -125,7 +117,7 @@
}
int64_t NavigationHandleImpl::GetNavigationId() {
- return navigation_id_;
+ return navigation_request_->navigation_handle_id();
}
const GURL& NavigationHandleImpl::GetURL() {
diff --git a/content/browser/frame_host/navigation_handle_impl.h b/content/browser/frame_host/navigation_handle_impl.h
index d05091f6..2770c97 100644
--- a/content/browser/frame_host/navigation_handle_impl.h
+++ b/content/browser/frame_host/navigation_handle_impl.h
@@ -268,9 +268,6 @@
// corresponding provider is created in the renderer.
std::unique_ptr<ServiceWorkerNavigationHandle> service_worker_handle_;
- // The unique id to identify this to navigation with.
- int64_t navigation_id_;
-
// Stores the reload type, or NONE if it's not a reload.
ReloadType reload_type_;
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 11b9207..f8d5c526 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -450,6 +450,13 @@
NOTREACHED() << "Invalid page transition: " << transition;
}
+// Use this to get a new unique ID for a NavigationHandle during construction.
+// The returned ID is guaranteed to be nonzero (zero is the "no ID" indicator).
+int64_t CreateUniqueHandleID() {
+ static int64_t unique_id_counter = 0;
+ return ++unique_id_counter;
+}
+
} // namespace
// static
@@ -989,6 +996,7 @@
}
handle_state_ = NavigationRequest::INITIAL;
+ navigation_handle_id_ = CreateUniqueHandleID();
std::unique_ptr<NavigationHandleImpl> navigation_handle = base::WrapUnique(
new NavigationHandleImpl(this, nav_entry_id_, std::move(headers)));
diff --git a/content/browser/frame_host/navigation_request.h b/content/browser/frame_host/navigation_request.h
index ac850a4..67c95139 100644
--- a/content/browser/frame_host/navigation_request.h
+++ b/content/browser/frame_host/navigation_request.h
@@ -459,6 +459,8 @@
const net::ProxyServer& proxy_server() { return proxy_server_; }
+ int64_t navigation_handle_id() { return navigation_handle_id_; }
+
private:
// TODO(clamy): Transform NavigationHandleImplTest into NavigationRequestTest
// once NavigationHandleImpl has become a wrapper around NavigationRequest.
@@ -952,6 +954,9 @@
// Which proxy server was used for this navigation, if any.
net::ProxyServer proxy_server_;
+ // The unique id to identify the NavigationHandle with.
+ int64_t navigation_handle_id_ = 0;
+
base::WeakPtrFactory<NavigationRequest> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NavigationRequest);