2022-10-17 14:22:24 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
|
|
Date: Thu, 13 Oct 2022 20:30:12 +0900
|
|
|
|
Subject: Preconnect manager
|
|
|
|
|
|
|
|
* Patch disables the profile related changes added in
|
|
|
|
https://chromium-review.googlesource.com/c/chromium/src/+/3928470.
|
|
|
|
* Also avoids including chrome/browser/predictors/resource_prefetch_predictor.h
|
|
|
|
in favor of defining PreconnectRequest in this file since we don't build
|
|
|
|
the header.
|
|
|
|
|
|
|
|
diff --git a/chrome/browser/predictors/preconnect_manager.cc b/chrome/browser/predictors/preconnect_manager.cc
|
2024-02-21 20:27:05 +00:00
|
|
|
index a51225da52ea92e39b9d11f48b024e423e6039ac..552f748612f59455b480d62f14c5d49ec752997b 100644
|
2022-10-17 14:22:24 +00:00
|
|
|
--- a/chrome/browser/predictors/preconnect_manager.cc
|
|
|
|
+++ b/chrome/browser/predictors/preconnect_manager.cc
|
|
|
|
@@ -10,9 +10,11 @@
|
2023-02-03 11:43:42 +00:00
|
|
|
#include "base/functional/bind.h"
|
2022-10-17 14:22:24 +00:00
|
|
|
#include "base/metrics/histogram_macros.h"
|
|
|
|
#include "base/trace_event/trace_event.h"
|
|
|
|
+#if 0
|
|
|
|
#include "chrome/browser/predictors/resource_prefetch_predictor.h"
|
2023-09-18 20:44:09 +00:00
|
|
|
#include "chrome/browser/preloading/preloading_prefs.h"
|
2022-10-17 14:22:24 +00:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
|
|
|
+#endif
|
|
|
|
#include "content/public/browser/browser_context.h"
|
|
|
|
#include "content/public/browser/browser_task_traits.h"
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
@@ -23,6 +25,20 @@ namespace predictors {
|
|
|
|
|
|
|
|
const bool kAllowCredentialsOnPreconnectByDefault = true;
|
|
|
|
|
|
|
|
+// NOTE(nornagon): this is copied from
|
|
|
|
+// //chrome/browser/predictors/resource_prefetch_predictor.cc we don't need
|
|
|
|
+// anything in that file other than this constructor.
|
|
|
|
+PreconnectRequest::PreconnectRequest(
|
|
|
|
+ const url::Origin& origin,
|
|
|
|
+ int num_sockets,
|
|
|
|
+ const net::NetworkAnonymizationKey& network_anonymization_key)
|
|
|
|
+ : origin(origin),
|
|
|
|
+ num_sockets(num_sockets),
|
|
|
|
+ network_anonymization_key(network_anonymization_key) {
|
|
|
|
+ DCHECK_GE(num_sockets, 0);
|
|
|
|
+ DCHECK(!network_anonymization_key.IsEmpty());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
PreconnectedRequestStats::PreconnectedRequestStats(const url::Origin& origin,
|
|
|
|
bool was_preconnected)
|
|
|
|
: origin(origin), was_preconnected(was_preconnected) {}
|
2023-01-06 02:35:34 +00:00
|
|
|
@@ -83,12 +99,15 @@ PreconnectManager::PreconnectManager(base::WeakPtr<Delegate> delegate,
|
2022-10-17 14:22:24 +00:00
|
|
|
PreconnectManager::~PreconnectManager() = default;
|
|
|
|
|
|
|
|
bool PreconnectManager::IsEnabled() {
|
|
|
|
+#if 0
|
|
|
|
Profile* profile = Profile::FromBrowserContext(browser_context_);
|
|
|
|
if (!profile) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-01-06 02:35:34 +00:00
|
|
|
return prefetch::IsSomePreloadingEnabled(*profile->GetPrefs()) ==
|
|
|
|
content::PreloadingEligibility::kEligible;
|
2022-10-17 14:22:24 +00:00
|
|
|
+#endif
|
|
|
|
+ return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreconnectManager::Start(const GURL& url,
|
|
|
|
diff --git a/chrome/browser/predictors/preconnect_manager.h b/chrome/browser/predictors/preconnect_manager.h
|
2023-06-09 23:08:36 +00:00
|
|
|
index 2f079f4b9144b3e01749f54f553b06262e38627e..42c6b442f6ddb2cecc7f47ec5f5785f285689efe 100644
|
2022-10-17 14:22:24 +00:00
|
|
|
--- a/chrome/browser/predictors/preconnect_manager.h
|
|
|
|
+++ b/chrome/browser/predictors/preconnect_manager.h
|
2022-11-17 19:59:23 +00:00
|
|
|
@@ -17,7 +17,9 @@
|
2022-10-17 14:22:24 +00:00
|
|
|
#include "base/time/time.h"
|
|
|
|
#include "chrome/browser/predictors/proxy_lookup_client_impl.h"
|
|
|
|
#include "chrome/browser/predictors/resolve_host_client_impl.h"
|
|
|
|
+#if 0
|
|
|
|
#include "chrome/browser/predictors/resource_prefetch_predictor.h"
|
|
|
|
+#endif
|
|
|
|
#include "net/base/network_anonymization_key.h"
|
|
|
|
#include "url/gurl.h"
|
|
|
|
|
2022-11-17 19:59:23 +00:00
|
|
|
@@ -33,7 +35,28 @@ class NetworkContext;
|
2022-10-17 14:22:24 +00:00
|
|
|
|
|
|
|
namespace predictors {
|
|
|
|
|
|
|
|
-struct PreconnectRequest;
|
|
|
|
+// Stores all values needed to trigger a preconnect/preresolve job to a single
|
|
|
|
+// origin.
|
|
|
|
+struct PreconnectRequest {
|
|
|
|
+ // |network_anonymization_key| specifies the key that network requests for the
|
|
|
|
+ // preconnected URL are expected to use. If a request is issued with a
|
|
|
|
+ // different key, it may not use the preconnected socket. It has no effect
|
|
|
|
+ // when |num_sockets| == 0.
|
|
|
|
+ PreconnectRequest(
|
|
|
|
+ const url::Origin& origin,
|
|
|
|
+ int num_sockets,
|
|
|
|
+ const net::NetworkAnonymizationKey& network_anonymization_key);
|
|
|
|
+ PreconnectRequest(const PreconnectRequest&) = default;
|
|
|
|
+ PreconnectRequest(PreconnectRequest&&) = default;
|
|
|
|
+ PreconnectRequest& operator=(const PreconnectRequest&) = default;
|
|
|
|
+ PreconnectRequest& operator=(PreconnectRequest&&) = default;
|
|
|
|
+
|
|
|
|
+ url::Origin origin;
|
|
|
|
+ // A zero-value means that we need to preresolve a host only.
|
|
|
|
+ int num_sockets = 0;
|
|
|
|
+ bool allow_credentials = true;
|
|
|
|
+ net::NetworkAnonymizationKey network_anonymization_key;
|
|
|
|
+};
|
|
|
|
|
|
|
|
struct PreconnectedRequestStats {
|
|
|
|
PreconnectedRequestStats(const url::Origin& origin, bool was_preconnected);
|