Move socket_address_pair.h to webrtc namespace
Bug: webrtc:42232595
Change-Id: Ic46e80ab4d56f7f4acc800d289a356a5c4ad4460
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/380501
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44077}
diff --git a/rtc_base/socket_address_pair.cc b/rtc_base/socket_address_pair.cc
index 54f70ff..351dbd3 100644
--- a/rtc_base/socket_address_pair.cc
+++ b/rtc_base/socket_address_pair.cc
@@ -10,10 +10,10 @@
#include "rtc_base/socket_address_pair.h"
-namespace rtc {
+namespace webrtc {
-SocketAddressPair::SocketAddressPair(const SocketAddress& src,
- const SocketAddress& dest)
+SocketAddressPair::SocketAddressPair(const rtc::SocketAddress& src,
+ const rtc::SocketAddress& dest)
: src_(src), dest_(dest) {}
bool SocketAddressPair::operator==(const SocketAddressPair& p) const {
@@ -36,4 +36,4 @@
return src_.Hash() ^ dest_.Hash();
}
-} // namespace rtc
+} // namespace webrtc
diff --git a/rtc_base/socket_address_pair.h b/rtc_base/socket_address_pair.h
index f315e64..aa1b01c 100644
--- a/rtc_base/socket_address_pair.h
+++ b/rtc_base/socket_address_pair.h
@@ -15,7 +15,7 @@
#include "rtc_base/socket_address.h"
-namespace rtc {
+namespace webrtc {
// Records a pair (source,destination) of socket addresses. The two addresses
// identify a connection between two machines. (For UDP, this "connection" is
@@ -23,10 +23,11 @@
class SocketAddressPair {
public:
SocketAddressPair() {}
- SocketAddressPair(const SocketAddress& srs, const SocketAddress& dest);
+ SocketAddressPair(const rtc::SocketAddress& srs,
+ const rtc::SocketAddress& dest);
- const SocketAddress& source() const { return src_; }
- const SocketAddress& destination() const { return dest_; }
+ const rtc::SocketAddress& source() const { return src_; }
+ const rtc::SocketAddress& destination() const { return dest_; }
bool operator==(const SocketAddressPair& r) const;
bool operator<(const SocketAddressPair& r) const;
@@ -34,10 +35,16 @@
size_t Hash() const;
private:
- SocketAddress src_;
- SocketAddress dest_;
+ rtc::SocketAddress src_;
+ rtc::SocketAddress dest_;
};
+} // namespace webrtc
+
+// Re-export symbols from the webrtc namespace for backwards compatibility.
+// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
+namespace rtc {
+using ::webrtc::SocketAddressPair;
} // namespace rtc
#endif // RTC_BASE_SOCKET_ADDRESS_PAIR_H_
diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc
index 51a9901..de4e181 100644
--- a/rtc_base/virtual_socket_server.cc
+++ b/rtc_base/virtual_socket_server.cc
@@ -869,8 +869,8 @@
// multiple clients to connect to the same server address.
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
- SocketAddressPair address_pair(local_normalized, remote_normalized);
- connections_->insert(std::pair<SocketAddressPair, VirtualSocket*>(
+ webrtc::SocketAddressPair address_pair(local_normalized, remote_normalized);
+ connections_->insert(std::pair<webrtc::SocketAddressPair, VirtualSocket*>(
address_pair, remote_socket));
}
@@ -879,7 +879,7 @@
const SocketAddress& remote) {
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
- SocketAddressPair address_pair(local_normalized, remote_normalized);
+ webrtc::SocketAddressPair address_pair(local_normalized, remote_normalized);
ConnectionMap::iterator it = connections_->find(address_pair);
return (connections_->end() != it) ? it->second : nullptr;
}
@@ -888,7 +888,7 @@
const SocketAddress& remote) {
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
- SocketAddressPair address_pair(local_normalized, remote_normalized);
+ webrtc::SocketAddressPair address_pair(local_normalized, remote_normalized);
connections_->erase(address_pair);
}
diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h
index d462288..6de8dc0 100644
--- a/rtc_base/virtual_socket_server.h
+++ b/rtc_base/virtual_socket_server.h
@@ -23,6 +23,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
+#include "rtc_base/socket_address_pair.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/synchronization/mutex.h"
@@ -30,7 +31,6 @@
class VirtualSocketPacket;
class VirtualSocketServer;
-class SocketAddressPair;
// Implements the socket interface using the virtual network. Packets are
// passed in tasks using the thread of the socket server.
@@ -434,7 +434,7 @@
static bool CanInteractWith(VirtualSocket* local, VirtualSocket* remote);
typedef std::map<SocketAddress, VirtualSocket*> AddressMap;
- typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap;
+ typedef std::map<webrtc::SocketAddressPair, VirtualSocket*> ConnectionMap;
// May be null if the test doesn't use a fake clock, or it does but doesn't
// use ProcessMessagesUntilIdle.