Adopt absl::string_view in rtc_base/ (straightforward cases)

Bug: webrtc:13579
Change-Id: I240db6285abb22652242bc0b2ebe9844ec4a45f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258723
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36561}
This commit is contained in:
Ali Tofigh
2022-04-13 12:55:15 +02:00
committed by WebRTC LUCI CQ
parent a62136ac74
commit 2ab914c6ab
40 changed files with 165 additions and 167 deletions

View File

@ -14,6 +14,7 @@
#include <string>
#include <utility>
#include "absl/strings/string_view.h"
#include "api/ref_counted_base.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
@ -66,7 +67,7 @@ void PostTaskToGlobalQueue(std::unique_ptr<webrtc::QueuedTask> task) {
} // namespace
#endif
int ResolveHostname(const std::string& hostname,
int ResolveHostname(absl::string_view hostname,
int family,
std::vector<IPAddress>* addresses) {
#ifdef __native_client__
@ -99,7 +100,8 @@ int ResolveHostname(const std::string& hostname,
// https://android.googlesource.com/platform/bionic/+/
// 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657
hints.ai_flags = AI_ADDRCONFIG;
int ret = getaddrinfo(hostname.c_str(), nullptr, &hints, &result);
int ret =
getaddrinfo(std::string(hostname).c_str(), nullptr, &hints, &result);
if (ret != 0) {
return ret;
}
@ -151,8 +153,7 @@ void AsyncResolver::Start(const SocketAddress& addr) {
[this, addr, caller_task_queue = webrtc::TaskQueueBase::Current(),
state = state_] {
std::vector<IPAddress> addresses;
int error =
ResolveHostname(addr.hostname().c_str(), addr.family(), &addresses);
int error = ResolveHostname(addr.hostname(), addr.family(), &addresses);
webrtc::MutexLock lock(&state->mutex);
if (state->status == State::Status::kLive) {
caller_task_queue->PostTask(webrtc::ToQueuedTask(