From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexey Kuts Date: Fri, 26 Jul 2019 22:32:54 +0300 Subject: remove references to Profile from PreconnectManager The PreconnectManager in Chrome only depends on Profile for testing purposes; this patch removes that dependency so we can reuse it. Ideally we would change this class in upstream to not depend on Profile. diff --git a/chrome/browser/predictors/preconnect_manager.cc b/chrome/browser/predictors/preconnect_manager.cc index d7e470bbb181b2274584ffc14f2c26625b1d5794..78216f0083281b4f1e0209f766753d0dc9c796c4 100644 --- a/chrome/browser/predictors/preconnect_manager.cc +++ b/chrome/browser/predictors/preconnect_manager.cc @@ -68,7 +68,7 @@ PreresolveJob::PreresolveJob(PreresolveJob&& other) = default; PreresolveJob::~PreresolveJob() = default; PreconnectManager::PreconnectManager(base::WeakPtr delegate, - Profile* profile) + content::BrowserContext* profile) : delegate_(std::move(delegate)), profile_(profile), inflight_preresolves_count_(0) { @@ -327,11 +327,13 @@ network::mojom::NetworkContext* PreconnectManager::GetNetworkContext() const { if (network_context_) return network_context_; +#if 0 if (profile_->AsTestingProfile()) { // We're testing and |network_context_| wasn't set. Return nullptr to avoid // hitting the network. return nullptr; } +#endif return content::BrowserContext::GetDefaultStoragePartition(profile_) ->GetNetworkContext(); diff --git a/chrome/browser/predictors/preconnect_manager.h b/chrome/browser/predictors/preconnect_manager.h index 1cf8e9097afbec8905849ae0b885e9103d3aa1f1..7f51a419e47ab6a52573a7f3fdba016b4edfb07e 100644 --- a/chrome/browser/predictors/preconnect_manager.h +++ b/chrome/browser/predictors/preconnect_manager.h @@ -22,6 +22,10 @@ class Profile; +namespace content { +class BrowserContext; +} + namespace network { namespace mojom { class NetworkContext; @@ -147,7 +151,7 @@ class PreconnectManager { static const size_t kMaxInflightPreresolves = 3; - PreconnectManager(base::WeakPtr delegate, Profile* profile); + PreconnectManager(base::WeakPtr delegate, content::BrowserContext* profile); virtual ~PreconnectManager(); // Starts preconnect and preresolve jobs keyed by |url|. @@ -212,7 +216,7 @@ class PreconnectManager { network::mojom::NetworkContext* GetNetworkContext() const; base::WeakPtr delegate_; - Profile* const profile_; + content::BrowserContext* const profile_; std::list queued_jobs_; PreresolveJobMap preresolve_jobs_; std::map> preresolve_info_;