#include "chrome/browser/media/webrtc/webrtc_text_log_handler.h"
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/cpu.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/i18n/time_formatting.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/media/audio_service_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/media/webrtc_logging.mojom.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/webrtc_log.h"
#include "content/public/common/content_features.h"
#include "gpu/config/gpu_info.h"
#include "media/audio/audio_manager.h"
#include "media/base/media_switches.h"
#include "media/webrtc/webrtc_features.h"
#include "net/base/ip_address.h"
#include "net/base/network_change_notifier.h"
#include "net/base/network_interfaces.h"
#include "services/network/public/mojom/network_service.mojom.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/linux_util.h"
#include "base/task/thread_pool.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/system/statistics_provider.h"
#endif
NumberToString;
namespace {
void ForwardMessageViaTaskRunner(
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::RepeatingCallback<void(const std::string&)> callback,
const std::string& message) { … }
std::string Format(const std::string& message,
base::Time timestamp,
base::Time start_time) { … }
std::string FormatMetaDataAsLogMessage(const WebRtcLogMetaDataMap& meta_data) { … }
std::string IPAddressToSensitiveString(const net::IPAddress& address) { … }
enum class StartError { … };
void RecordStartError(StartError error) { … }
}
WebRtcTextLogHandler::WebRtcTextLogHandler(int render_process_id)
: … { … }
WebRtcTextLogHandler::~WebRtcTextLogHandler() { … }
WebRtcTextLogHandler::LoggingState WebRtcTextLogHandler::GetState() const { … }
bool WebRtcTextLogHandler::GetChannelIsClosing() const { … }
void WebRtcTextLogHandler::SetMetaData(
std::unique_ptr<WebRtcLogMetaDataMap> meta_data,
GenericDoneCallback callback) { … }
bool WebRtcTextLogHandler::StartLogging(GenericDoneCallback callback) { … }
void WebRtcTextLogHandler::StartDone(GenericDoneCallback callback) { … }
bool WebRtcTextLogHandler::StopLogging(GenericDoneCallback callback) { … }
void WebRtcTextLogHandler::StopDone() { … }
void WebRtcTextLogHandler::ChannelClosing() { … }
void WebRtcTextLogHandler::DiscardLog() { … }
void WebRtcTextLogHandler::ReleaseLog(
std::unique_ptr<WebRtcLogBuffer>* log_buffer,
std::unique_ptr<WebRtcLogMetaDataMap>* meta_data) { … }
void WebRtcTextLogHandler::LogToCircularBuffer(const std::string& message) { … }
void WebRtcTextLogHandler::LogMessage(const std::string& message) { … }
void WebRtcTextLogHandler::LogWebRtcLoggingMessage(
const chrome::mojom::WebRtcLoggingMessage* message) { … }
bool WebRtcTextLogHandler::ExpectLoggingStateStopped(
GenericDoneCallback* callback) { … }
void WebRtcTextLogHandler::FireGenericDoneCallback(
GenericDoneCallback callback,
bool success,
const std::string& error_message) { … }
void WebRtcTextLogHandler::SetWebAppId(int web_app_id) { … }
void WebRtcTextLogHandler::OnGetNetworkInterfaceList(
GenericDoneCallback callback,
const std::optional<net::NetworkInterfaceList>& networks) { … }
void WebRtcTextLogHandler::OnGetNetworkInterfaceListFinish(
GenericDoneCallback callback,
const std::optional<net::NetworkInterfaceList>& networks,
const std::string& linux_distro) { … }