Commit 5c8bbe3d authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Migrate content::PpapiPluginProcessHost::PluginNetworkObserver to NetworkConnectionTracker

This migrates content::PpapiPluginProcessHost::PluginNetworkObserver
from using NetworkChangeNotifier to NetworkConnectionTracker, which is
backed by the network service.

Bug: 887054
Change-Id: Ieee103c35dd2adde840ea21890c03fe4f0cc76ed
Reviewed-on: https://chromium-review.googlesource.com/c/1238446
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596056}
parent 0d2d2d89
......@@ -23,14 +23,15 @@
#include "content/common/child_process_host_impl.h"
#include "content/common/content_switches_internal.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/pepper_plugin_info.h"
#include "content/public/common/process_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/service_names.mojom.h"
#include "net/base/network_change_notifier.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "services/network/public/cpp/network_connection_tracker.h"
#include "services/service_manager/sandbox/sandbox_type.h"
#include "services/service_manager/sandbox/switches.h"
#include "services/service_manager/zygote/common/zygote_buildflags.h"
......@@ -129,25 +130,38 @@ class PpapiPluginSandboxedProcessLauncherDelegate
};
class PpapiPluginProcessHost::PluginNetworkObserver
: public net::NetworkChangeNotifier::NetworkChangeObserver {
: public network::NetworkConnectionTracker::NetworkConnectionObserver {
public:
explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host)
: process_host_(process_host) {
net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
: process_host_(process_host),
network_connection_tracker_(nullptr),
weak_factory_(this) {
GetNetworkConnectionTrackerFromUIThread(
base::BindOnce(&PluginNetworkObserver::SetNetworkConnectionTracker,
weak_factory_.GetWeakPtr()));
}
void SetNetworkConnectionTracker(
network::NetworkConnectionTracker* network_connection_tracker) {
DCHECK(network_connection_tracker);
network_connection_tracker_ = network_connection_tracker;
network_connection_tracker_->AddNetworkConnectionObserver(this);
}
~PluginNetworkObserver() override {
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
if (network_connection_tracker_)
network_connection_tracker_->RemoveNetworkConnectionObserver(this);
}
void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType type) override {
void OnConnectionChanged(network::mojom::ConnectionType type) override {
process_host_->Send(new PpapiMsg_SetNetworkState(
type != net::NetworkChangeNotifier::CONNECTION_NONE));
type != network::mojom::ConnectionType::CONNECTION_NONE));
}
private:
PpapiPluginProcessHost* const process_host_;
network::NetworkConnectionTracker* network_connection_tracker_;
base::WeakPtrFactory<PluginNetworkObserver> weak_factory_;
};
PpapiPluginProcessHost::~PpapiPluginProcessHost() {
......
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