#include "chrome/browser/media/webrtc/webrtc_logging_controller.h"
#include <memory>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/supports_user_data.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include "chrome/browser/media/webrtc/webrtc_log_uploader.h"
#include "chrome/browser/media/webrtc/webrtc_rtp_dump_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/webrtc_logging/browser/text_log_list.h"
#include "content/public/browser/render_process_host.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "content/public/browser/child_process_security_policy.h"
#include "storage/browser/file_system/isolated_context.h"
#endif
WebRtcEventLogManager;
namespace {
constexpr char kRenderProcessHostKey[] = …;
}
void WebRtcLoggingController::AttachToRenderProcessHost(
content::RenderProcessHost* host) { … }
WebRtcLoggingController* WebRtcLoggingController::FromRenderProcessHost(
content::RenderProcessHost* host) { … }
void WebRtcLoggingController::SetMetaData(
std::unique_ptr<WebRtcLogMetaDataMap> meta_data,
GenericDoneCallback callback) { … }
void WebRtcLoggingController::StartLogging(GenericDoneCallback callback) { … }
void WebRtcLoggingController::StopLogging(GenericDoneCallback callback) { … }
void WebRtcLoggingController::UploadLog(UploadDoneCallback callback) { … }
void WebRtcLoggingController::UploadStoredLog(const std::string& log_id,
UploadDoneCallback callback) { … }
void WebRtcLoggingController::DiscardLog(GenericDoneCallback callback) { … }
void WebRtcLoggingController::StoreLog(const std::string& log_id,
GenericDoneCallback callback) { … }
void WebRtcLoggingController::StoreLogContinue(const std::string& log_id,
GenericDoneCallback callback) { … }
void WebRtcLoggingController::StartRtpDump(RtpDumpType type,
GenericDoneCallback callback) { … }
void WebRtcLoggingController::StopRtpDump(RtpDumpType type,
GenericDoneCallback callback) { … }
void WebRtcLoggingController::StartEventLogging(
const std::string& session_id,
size_t max_log_size_bytes,
int output_period_ms,
size_t web_app_id,
const StartEventLoggingCallback& callback) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
void WebRtcLoggingController::GetLogsDirectory(
LogsDirectoryCallback callback,
LogsDirectoryErrorCallback error_callback) { … }
void WebRtcLoggingController::GrantLogsDirectoryAccess(
LogsDirectoryCallback callback,
LogsDirectoryErrorCallback error_callback,
const base::FilePath& logs_path) { … }
#endif
void WebRtcLoggingController::OnRtpPacket(
base::HeapArray<uint8_t> packet_header,
size_t packet_length,
bool incoming) { … }
void WebRtcLoggingController::OnAddMessages(
std::vector<chrome::mojom::WebRtcLoggingMessagePtr> messages) { … }
void WebRtcLoggingController::OnStopped() { … }
WebRtcLoggingController::WebRtcLoggingController(
int render_process_id,
content::BrowserContext* browser_context)
: … { … }
WebRtcLoggingController::~WebRtcLoggingController() { … }
void WebRtcLoggingController::OnAgentDisconnected() { … }
void WebRtcLoggingController::TriggerUpload(
UploadDoneCallback callback,
const base::FilePath& log_directory) { … }
void WebRtcLoggingController::StoreLogInDirectory(
const std::string& log_id,
std::unique_ptr<WebRtcLogPaths> log_paths,
GenericDoneCallback done_callback,
const base::FilePath& directory) { … }
void WebRtcLoggingController::DoUploadLogAndRtpDumps(
const base::FilePath& log_directory,
UploadDoneCallback callback) { … }
void WebRtcLoggingController::CreateRtpDumpHandlerAndStart(
RtpDumpType type,
GenericDoneCallback callback,
const base::FilePath& dump_dir) { … }
void WebRtcLoggingController::DoStartRtpDump(RtpDumpType type,
GenericDoneCallback callback) { … }
bool WebRtcLoggingController::ReleaseRtpDumps(WebRtcLogPaths* log_paths) { … }
void WebRtcLoggingController::FireGenericDoneCallback(
GenericDoneCallback callback,
bool success,
const std::string& error_message) { … }
content::BrowserContext* WebRtcLoggingController::GetBrowserContext() const { … }
bool WebRtcLoggingController::IsWebRtcTextLogAllowed(
content::BrowserContext* browser_context) { … }
base::FilePath WebRtcLoggingController::GetLogDirectoryAndEnsureExists(
const base::FilePath& browser_context_directory_path) { … }