fix: navigator.connection not working as intended (#38491)

* fix: navigator.connection not working as intended

* chore: make network quality methods private
This commit is contained in:
Shelley Vohr 2023-05-31 17:06:25 +02:00 committed by GitHub
parent 67f273a6d6
commit 57147d1b8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 0 deletions

View file

@ -25,6 +25,8 @@
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/network_quality_observer_factory.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/content_switches.h"
#include "electron/fuses.h"
#include "extensions/common/constants.h"
@ -125,6 +127,10 @@ void BrowserProcessImpl::PreCreateThreads() {
SystemNetworkContextManager::CreateInstance(local_state_.get());
}
void BrowserProcessImpl::PreMainMessageLoopRun() {
CreateNetworkQualityObserver();
}
void BrowserProcessImpl::PostMainMessageLoopRun() {
if (local_state_)
local_state_->CommitPendingWrite();
@ -333,3 +339,18 @@ void BrowserProcessImpl::SetGeolocationManager(
std::unique_ptr<device::GeolocationManager> geolocation_manager) {
geolocation_manager_ = std::move(geolocation_manager);
}
network::NetworkQualityTracker* BrowserProcessImpl::GetNetworkQualityTracker() {
if (!network_quality_tracker_) {
network_quality_tracker_ = std::make_unique<network::NetworkQualityTracker>(
base::BindRepeating(&content::GetNetworkService));
}
return network_quality_tracker_.get();
}
void BrowserProcessImpl::CreateNetworkQualityObserver() {
DCHECK(!network_quality_observer_);
network_quality_observer_ =
content::CreateNetworkQualityObserver(GetNetworkQualityTracker());
DCHECK(network_quality_observer_);
}