Commit 23085cc7 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Onion soup content/renderer/p2p/empty_network_manager.cc|h

This CL corresponds to phase 3.6 on the design document [1].

[1] https://docs.google.com/document/d/1AJKVA5U4nDkyDB9p4ROrggWXadCxyy-grKaE9KS5vOU/

BUG=787254
R=guidou@chromium.org, haraken@chromium.org

Change-Id: I9925a69727b19631188f21671ae41e12982c0517
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1792849
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695111}
parent eb6f6e59
...@@ -240,8 +240,6 @@ target(link_target_type, "renderer") { ...@@ -240,8 +240,6 @@ target(link_target_type, "renderer") {
"navigation_state.h", "navigation_state.h",
"net_info_helper.cc", "net_info_helper.cc",
"net_info_helper.h", "net_info_helper.h",
"p2p/empty_network_manager.cc",
"p2p/empty_network_manager.h",
"p2p/filtering_network_manager.cc", "p2p/filtering_network_manager.cc",
"p2p/filtering_network_manager.h", "p2p/filtering_network_manager.h",
"p2p/host_address_request.cc", "p2p/host_address_request.cc",
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/media/webrtc/rtc_peer_connection_handler.h" #include "content/renderer/media/webrtc/rtc_peer_connection_handler.h"
#include "content/renderer/media/webrtc/stun_field_trial.h" #include "content/renderer/media/webrtc/stun_field_trial.h"
#include "content/renderer/p2p/empty_network_manager.h"
#include "content/renderer/p2p/filtering_network_manager.h" #include "content/renderer/p2p/filtering_network_manager.h"
#include "content/renderer/p2p/ipc_network_manager.h" #include "content/renderer/p2p/ipc_network_manager.h"
#include "content/renderer/p2p/ipc_socket_factory.h" #include "content/renderer/p2p/ipc_socket_factory.h"
...@@ -45,6 +44,7 @@ ...@@ -45,6 +44,7 @@
#include "media/video/gpu_video_accelerator_factories.h" #include "media/video/gpu_video_accelerator_factories.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/modules/mediastream/webrtc_uma_histograms.h" #include "third_party/blink/public/platform/modules/mediastream/webrtc_uma_histograms.h"
#include "third_party/blink/public/platform/modules/p2p/empty_network_manager.h"
#include "third_party/blink/public/platform/modules/peerconnection/audio_codec_factory.h" #include "third_party/blink/public/platform/modules/peerconnection/audio_codec_factory.h"
#include "third_party/blink/public/platform/modules/peerconnection/video_codec_factory.h" #include "third_party/blink/public/platform/modules/peerconnection/video_codec_factory.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h" #include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
...@@ -475,7 +475,7 @@ PeerConnectionDependencyFactory::CreatePortAllocator( ...@@ -475,7 +475,7 @@ PeerConnectionDependencyFactory::CreatePortAllocator(
network_manager_.get(), requesting_origin, media_permission); network_manager_.get(), requesting_origin, media_permission);
} else { } else {
network_manager = network_manager =
std::make_unique<EmptyNetworkManager>(network_manager_.get()); std::make_unique<blink::EmptyNetworkManager>(network_manager_.get());
} }
auto port_allocator = std::make_unique<P2PPortAllocator>( auto port_allocator = std::make_unique<P2PPortAllocator>(
p2p_socket_dispatcher_, std::move(network_manager), socket_factory_.get(), p2p_socket_dispatcher_, std::move(network_manager), socket_factory_.get(),
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/test/test_simple_task_runner.h" #include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/renderer/p2p/empty_network_manager.h"
#include "media/base/media_permission.h" #include "media/base/media_permission.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/modules/p2p/empty_network_manager.h"
#include "third_party/webrtc/rtc_base/ip_address.h" #include "third_party/webrtc/rtc_base/ip_address.h"
using NetworkList = rtc::NetworkManager::NetworkList; using NetworkList = rtc::NetworkManager::NetworkList;
...@@ -174,8 +174,8 @@ class FilteringNetworkManagerTest : public testing::Test, ...@@ -174,8 +174,8 @@ class FilteringNetworkManagerTest : public testing::Test,
base_network_manager_.get(), GURL(), media_permission_.get()); base_network_manager_.get(), GURL(), media_permission_.get());
network_manager_->Initialize(); network_manager_->Initialize();
} else { } else {
network_manager_ = network_manager_ = std::make_unique<blink::EmptyNetworkManager>(
std::make_unique<EmptyNetworkManager>(base_network_manager_.get()); base_network_manager_.get());
} }
network_manager_->SignalNetworksChanged.connect( network_manager_->SignalNetworksChanged.connect(
this, &FilteringNetworkManagerTest::OnNetworksChanged); this, &FilteringNetworkManagerTest::OnNetworksChanged);
......
...@@ -149,6 +149,7 @@ source_set("blink_headers") { ...@@ -149,6 +149,7 @@ source_set("blink_headers") {
"platform/modules/mediastream/web_platform_media_stream_source.h", "platform/modules/mediastream/web_platform_media_stream_source.h",
"platform/modules/mediastream/web_platform_media_stream_track.h", "platform/modules/mediastream/web_platform_media_stream_track.h",
"platform/modules/mediastream/webrtc_uma_histograms.h", "platform/modules/mediastream/webrtc_uma_histograms.h",
"platform/modules/p2p/empty_network_manager.h",
"platform/modules/p2p/network_list_manager.h", "platform/modules/p2p/network_list_manager.h",
"platform/modules/p2p/network_list_observer.h", "platform/modules/p2p/network_list_observer.h",
"platform/modules/p2p/network_manager_uma.h", "platform/modules/p2p/network_manager_uma.h",
...@@ -561,6 +562,9 @@ source_set("blink_headers") { ...@@ -561,6 +562,9 @@ source_set("blink_headers") {
"//third_party/webrtc/pc:peerconnection", "//third_party/webrtc/pc:peerconnection",
"//third_party/webrtc/rtc_base:rtc_base", "//third_party/webrtc/rtc_base:rtc_base",
"//third_party/webrtc/rtc_base:rtc_task_queue", "//third_party/webrtc/rtc_base:rtc_task_queue",
# TODO(titovartem) remove dependency on WebRTC internals.
"//third_party/webrtc/rtc_base/third_party/sigslot:sigslot",
"//third_party/webrtc_overrides:init_webrtc", "//third_party/webrtc_overrides:init_webrtc",
"//ui/base:base", "//ui/base:base",
"//v8:v8_headers", "//v8:v8_headers",
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_EMPTY_NETWORK_MANAGER_H_
#define CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_EMPTY_NETWORK_MANAGER_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "content/common/content_export.h" #include "third_party/blink/public/platform/web_common.h"
#include "third_party/webrtc/rtc_base/network.h" #include "third_party/webrtc/rtc_base/network.h"
#include "third_party/webrtc/rtc_base/third_party/sigslot/sigslot.h" #include "third_party/webrtc/rtc_base/third_party/sigslot/sigslot.h"
...@@ -16,19 +16,22 @@ namespace rtc { ...@@ -16,19 +16,22 @@ namespace rtc {
class IPAddress; class IPAddress;
} // namespace rtc } // namespace rtc
namespace content { namespace blink {
// A NetworkManager implementation which handles the case where local address // A NetworkManager implementation which handles the case where local address
// enumeration is not requested and just returns empty network lists. This class // enumeration is not requested and just returns empty network lists. This class
// is not thread safe and should only be used by WebRTC's network thread. // is not thread safe and should only be used by WebRTC's network thread.
//
// TODO(crbug.com/787254): Move this class out of the Blink exposed API when
// all users of it have been Onion souped. Also, move it away from std::vector.
class EmptyNetworkManager : public rtc::NetworkManagerBase, class EmptyNetworkManager : public rtc::NetworkManagerBase,
public sigslot::has_slots<> { public sigslot::has_slots<> {
public: public:
// This class is created by WebRTC's signaling thread but used by WebRTC's // This class is created by WebRTC's signaling thread but used by WebRTC's
// worker thread |task_runner|. // worker thread |task_runner|.
CONTENT_EXPORT explicit EmptyNetworkManager( BLINK_PLATFORM_EXPORT explicit EmptyNetworkManager(
rtc::NetworkManager* network_manager); rtc::NetworkManager* network_manager);
CONTENT_EXPORT ~EmptyNetworkManager() override; BLINK_PLATFORM_EXPORT ~EmptyNetworkManager() override;
// rtc::NetworkManager: // rtc::NetworkManager:
void StartUpdating() override; void StartUpdating() override;
...@@ -45,7 +48,7 @@ class EmptyNetworkManager : public rtc::NetworkManagerBase, ...@@ -45,7 +48,7 @@ class EmptyNetworkManager : public rtc::NetworkManagerBase,
// default IP addresses. // default IP addresses.
void OnNetworksChanged(); void OnNetworksChanged();
base::ThreadChecker thread_checker_; THREAD_CHECKER(thread_checker_);
// Whether we have fired the first SignalNetworksChanged. // Whether we have fired the first SignalNetworksChanged.
// Used to ensure we only report metrics once. // Used to ensure we only report metrics once.
...@@ -64,6 +67,6 @@ class EmptyNetworkManager : public rtc::NetworkManagerBase, ...@@ -64,6 +67,6 @@ class EmptyNetworkManager : public rtc::NetworkManagerBase,
DISALLOW_COPY_AND_ASSIGN(EmptyNetworkManager); DISALLOW_COPY_AND_ASSIGN(EmptyNetworkManager);
}; };
} // namespace content } // namespace blink
#endif // CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_P2P_EMPTY_NETWORK_MANAGER_H_
...@@ -1227,6 +1227,7 @@ jumbo_component("platform") { ...@@ -1227,6 +1227,7 @@ jumbo_component("platform") {
"mojo/revocable_strong_binding.h", "mojo/revocable_strong_binding.h",
"mojo/string16_mojom_traits.cc", "mojo/string16_mojom_traits.cc",
"mojo/string16_mojom_traits.h", "mojo/string16_mojom_traits.h",
"p2p/empty_network_manager.cc",
"p2p/network_manager_uma.cc", "p2p/network_manager_uma.cc",
"peerconnection/audio_codec_factory.cc", "peerconnection/audio_codec_factory.cc",
"peerconnection/rtc_answer_options_platform.h", "peerconnection/rtc_answer_options_platform.h",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/renderer/p2p/empty_network_manager.h" #include "third_party/blink/public/platform/modules/p2p/empty_network_manager.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
...@@ -10,36 +10,36 @@ ...@@ -10,36 +10,36 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "third_party/blink/public/platform/modules/p2p/network_manager_uma.h" #include "third_party/blink/public/platform/modules/p2p/network_manager_uma.h"
namespace content { namespace blink {
EmptyNetworkManager::EmptyNetworkManager(rtc::NetworkManager* network_manager) EmptyNetworkManager::EmptyNetworkManager(rtc::NetworkManager* network_manager)
: network_manager_(network_manager) { : network_manager_(network_manager) {
DCHECK(network_manager); DCHECK(network_manager);
thread_checker_.DetachFromThread(); DETACH_FROM_THREAD(thread_checker_);
set_enumeration_permission(ENUMERATION_BLOCKED); set_enumeration_permission(ENUMERATION_BLOCKED);
network_manager_->SignalNetworksChanged.connect( network_manager_->SignalNetworksChanged.connect(
this, &EmptyNetworkManager::OnNetworksChanged); this, &EmptyNetworkManager::OnNetworksChanged);
} }
EmptyNetworkManager::~EmptyNetworkManager() { EmptyNetworkManager::~EmptyNetworkManager() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
} }
void EmptyNetworkManager::StartUpdating() { void EmptyNetworkManager::StartUpdating() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
++start_count_; ++start_count_;
network_manager_->StartUpdating(); network_manager_->StartUpdating();
} }
void EmptyNetworkManager::StopUpdating() { void EmptyNetworkManager::StopUpdating() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
network_manager_->StopUpdating(); network_manager_->StopUpdating();
--start_count_; --start_count_;
DCHECK_GE(start_count_, 0); DCHECK_GE(start_count_, 0);
} }
void EmptyNetworkManager::GetNetworks(NetworkList* networks) const { void EmptyNetworkManager::GetNetworks(NetworkList* networks) const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
networks->clear(); networks->clear();
} }
...@@ -50,7 +50,7 @@ bool EmptyNetworkManager::GetDefaultLocalAddress( ...@@ -50,7 +50,7 @@ bool EmptyNetworkManager::GetDefaultLocalAddress(
} }
void EmptyNetworkManager::OnNetworksChanged() { void EmptyNetworkManager::OnNetworksChanged() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!start_count_) if (!start_count_)
return; return;
...@@ -62,4 +62,4 @@ void EmptyNetworkManager::OnNetworksChanged() { ...@@ -62,4 +62,4 @@ void EmptyNetworkManager::OnNetworksChanged() {
SignalNetworksChanged(); SignalNetworksChanged();
} }
} // namespace content } // namespace blink
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