Commit 0a98fd2d authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Migrate intranet_redirect_detector to NetworkConnectionTracker.

This migrates IntranetRedirectDetector from using
net::NetworkChangeNotifier to content::NetworkConnectionTracker, which
works with the network service enabled.

Bug: 859131
Change-Id: Iec4c2f7907066d030d8de11d13ac955a558a2415
Reviewed-on: https://chromium-review.googlesource.com/1123332Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572280}
parent be6dcb07
...@@ -48,11 +48,13 @@ IntranetRedirectDetector::IntranetRedirectDetector() ...@@ -48,11 +48,13 @@ IntranetRedirectDetector::IntranetRedirectDetector()
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(kStartFetchDelaySeconds)); base::TimeDelta::FromSeconds(kStartFetchDelaySeconds));
net::NetworkChangeNotifier::AddNetworkChangeObserver(this); g_browser_process->network_connection_tracker()->AddNetworkConnectionObserver(
this);
} }
IntranetRedirectDetector::~IntranetRedirectDetector() { IntranetRedirectDetector::~IntranetRedirectDetector() {
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); g_browser_process->network_connection_tracker()
->RemoveNetworkConnectionObserver(this);
} }
// static // static
...@@ -191,9 +193,9 @@ void IntranetRedirectDetector::OnSimpleLoaderComplete( ...@@ -191,9 +193,9 @@ void IntranetRedirectDetector::OnSimpleLoaderComplete(
redirect_origin_.spec() : std::string()); redirect_origin_.spec() : std::string());
} }
void IntranetRedirectDetector::OnNetworkChanged( void IntranetRedirectDetector::OnConnectionChanged(
net::NetworkChangeNotifier::ConnectionType type) { network::mojom::ConnectionType type) {
if (type == net::NetworkChangeNotifier::CONNECTION_NONE) if (type == network::mojom::ConnectionType::CONNECTION_NONE)
return; return;
// If a request is already scheduled, do not scheduled yet another one. // If a request is already scheduled, do not scheduled yet another one.
if (in_sleep_) if (in_sleep_)
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "content/public/browser/network_connection_tracker.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "net/base/network_change_notifier.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace network { namespace network {
...@@ -40,7 +40,7 @@ class PrefRegistrySimple; ...@@ -40,7 +40,7 @@ class PrefRegistrySimple;
// return a value at all times (even during startup or in unittest mode). If no // return a value at all times (even during startup or in unittest mode). If no
// redirection is in place, the returned GURL will be empty. // redirection is in place, the returned GURL will be empty.
class IntranetRedirectDetector class IntranetRedirectDetector
: public net::NetworkChangeNotifier::NetworkChangeObserver { : public content::NetworkConnectionTracker::NetworkConnectionObserver {
public: public:
// Only the main browser process loop should call this, when setting up // Only the main browser process loop should call this, when setting up
// g_browser_process->intranet_redirect_detector_. No code other than the // g_browser_process->intranet_redirect_detector_. No code other than the
...@@ -66,9 +66,8 @@ class IntranetRedirectDetector ...@@ -66,9 +66,8 @@ class IntranetRedirectDetector
void OnSimpleLoaderComplete(network::SimpleURLLoader* source, void OnSimpleLoaderComplete(network::SimpleURLLoader* source,
std::unique_ptr<std::string> response_body); std::unique_ptr<std::string> response_body);
// NetworkChangeNotifier::NetworkChangeObserver // NetworkConnectionTracker::NetworkConnectionObserver
void OnNetworkChanged( void OnConnectionChanged(network::mojom::ConnectionType type) override;
net::NetworkChangeNotifier::ConnectionType type) override;
GURL redirect_origin_; GURL redirect_origin_;
std::map<network::SimpleURLLoader*, std::unique_ptr<network::SimpleURLLoader>> std::map<network::SimpleURLLoader*, std::unique_ptr<network::SimpleURLLoader>>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment