#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include <limits>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
namespace webrtc_event_logging {
namespace {
BrowserContext;
BrowserThread;
RenderFrameHost;
RenderProcessHost;
BrowserContextId;
class PeerConnectionTrackerProxyImpl
: public WebRtcEventLogManager::PeerConnectionTrackerProxy { … };
bool IsRemoteLoggingFeatureEnabled() { … }
BrowserContext* GetBrowserContext(int render_process_id) { … }
template <typename... Args>
inline void MaybeReply(const base::Location& location,
base::OnceCallback<void(Args...)> reply,
Args... args) { … }
}
WebRtcEventLogManager* WebRtcEventLogManager::g_webrtc_event_log_manager = …;
std::unique_ptr<WebRtcEventLogManager>
WebRtcEventLogManager::CreateSingletonInstance() { … }
WebRtcEventLogManager* WebRtcEventLogManager::GetInstance() { … }
base::FilePath WebRtcEventLogManager::GetRemoteBoundWebRtcEventLogsDir(
content::BrowserContext* browser_context) { … }
WebRtcEventLogManager::WebRtcEventLogManager()
: … { … }
WebRtcEventLogManager::~WebRtcEventLogManager() { … }
void WebRtcEventLogManager::EnableForBrowserContext(
BrowserContext* browser_context,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::DisableForBrowserContext(
content::BrowserContext* browser_context,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::OnPeerConnectionAdded(
content::GlobalRenderFrameHostId frame_id,
int lid,
base::ProcessId pid,
const std::string& url,
const std::string& rtc_configuration) { … }
void WebRtcEventLogManager::OnPeerConnectionRemoved(
content::GlobalRenderFrameHostId frame_id,
int lid) { … }
void WebRtcEventLogManager::OnPeerConnectionUpdated(
content::GlobalRenderFrameHostId frame_id,
int lid,
const std::string& type,
const std::string& value) { … }
void WebRtcEventLogManager::OnPeerConnectionSessionIdSet(
content::GlobalRenderFrameHostId frame_id,
int lid,
const std::string& session_id) { … }
void WebRtcEventLogManager::OnWebRtcEventLogWrite(
content::GlobalRenderFrameHostId frame_id,
int lid,
const std::string& message) { … }
void WebRtcEventLogManager::EnableLocalLogging(
const base::FilePath& base_path) { … }
void WebRtcEventLogManager::DisableLocalLogging() { … }
void WebRtcEventLogManager::StartRemoteLogging(
int render_process_id,
const std::string& session_id,
size_t max_file_size_bytes,
int output_period_ms,
size_t web_app_id,
base::OnceCallback<void(bool, const std::string&, const std::string&)>
reply) { … }
void WebRtcEventLogManager::ClearCacheForBrowserContext(
const BrowserContext* browser_context,
const base::Time& delete_begin,
const base::Time& delete_end,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::GetHistory(
BrowserContextId browser_context_id,
base::OnceCallback<void(const std::vector<UploadList::UploadInfo>&)>
reply) { … }
void WebRtcEventLogManager::SetLocalLogsObserver(
WebRtcLocalEventLogsObserver* observer,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetRemoteLogsObserver(
WebRtcRemoteEventLogsObserver* observer,
base::OnceClosure reply) { … }
bool WebRtcEventLogManager::IsRemoteLoggingAllowedForBrowserContext(
BrowserContext* browser_context) const { … }
std::unique_ptr<LogFileWriter::Factory>
WebRtcEventLogManager::CreateRemoteLogFileWriterFactory() { … }
void WebRtcEventLogManager::RenderProcessExited(
RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { … }
void WebRtcEventLogManager::RenderProcessHostDestroyed(
RenderProcessHost* host) { … }
void WebRtcEventLogManager::RenderProcessHostExitedDestroyed(
RenderProcessHost* host) { … }
void WebRtcEventLogManager::OnPeerConnectionAdded(
content::GlobalRenderFrameHostId frame_id,
int lid,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnPeerConnectionRemoved(
content::GlobalRenderFrameHostId frame_id,
int lid,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnPeerConnectionStopped(
content::GlobalRenderFrameHostId frame_id,
int lid,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnPeerConnectionSessionIdSet(
content::GlobalRenderFrameHostId frame_id,
int lid,
const std::string& session_id,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnWebRtcEventLogWrite(
content::GlobalRenderFrameHostId frame_id,
int lid,
const std::string& message,
base::OnceCallback<void(std::pair<bool, bool>)> reply) { … }
void WebRtcEventLogManager::EnableLocalLogging(
const base::FilePath& base_path,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::EnableLocalLogging(
const base::FilePath& base_path,
size_t max_file_size_bytes,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::DisableLocalLogging(
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnLocalLogStarted(PeerConnectionKey peer_connection,
const base::FilePath& file_path) { … }
void WebRtcEventLogManager::OnLocalLogStopped(
PeerConnectionKey peer_connection) { … }
void WebRtcEventLogManager::OnRemoteLogStarted(PeerConnectionKey key,
const base::FilePath& file_path,
int output_period_ms) { … }
void WebRtcEventLogManager::OnRemoteLogStopped(
WebRtcEventLogPeerConnectionKey key) { … }
void WebRtcEventLogManager::OnLoggingTargetStarted(LoggingTarget target,
PeerConnectionKey key,
int output_period_ms) { … }
void WebRtcEventLogManager::OnLoggingTargetStopped(LoggingTarget target,
PeerConnectionKey key) { … }
void WebRtcEventLogManager::StartListeningForPrefChangeForBrowserContext(
BrowserContext* browser_context) { … }
void WebRtcEventLogManager::StopListeningForPrefChangeForBrowserContext(
BrowserContext* browser_context) { … }
void WebRtcEventLogManager::OnPrefChange(BrowserContext* browser_context) { … }
void WebRtcEventLogManager::OnFirstBrowserContextLoaded() { … }
void WebRtcEventLogManager::OnFirstBrowserContextLoadedInternal(
network::NetworkConnectionTracker* network_connection_tracker,
std::unique_ptr<LogFileWriter::Factory> log_file_writer_factory) { … }
void WebRtcEventLogManager::EnableRemoteBoundLoggingForBrowserContext(
BrowserContextId browser_context_id,
const base::FilePath& browser_context_dir,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::DisableRemoteBoundLoggingForBrowserContext(
BrowserContextId browser_context_id,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::
RemovePendingRemoteBoundLogsForNotEnabledBrowserContext(
BrowserContextId browser_context_id,
const base::FilePath& browser_context_dir,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::OnPeerConnectionAddedInternal(
PeerConnectionKey key,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnPeerConnectionRemovedInternal(
PeerConnectionKey key,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnPeerConnectionSessionIdSetInternal(
PeerConnectionKey key,
const std::string& session_id,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::OnWebRtcEventLogWriteInternal(
PeerConnectionKey key,
const std::string& message,
base::OnceCallback<void(std::pair<bool, bool>)> reply) { … }
void WebRtcEventLogManager::EnableLocalLoggingInternal(
const base::FilePath& base_path,
size_t max_file_size_bytes,
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::DisableLocalLoggingInternal(
base::OnceCallback<void(bool)> reply) { … }
void WebRtcEventLogManager::StartRemoteLoggingInternal(
int render_process_id,
BrowserContextId browser_context_id,
const std::string& session_id,
const base::FilePath& browser_context_dir,
size_t max_file_size_bytes,
int output_period_ms,
size_t web_app_id,
base::OnceCallback<void(bool, const std::string&, const std::string&)>
reply) { … }
void WebRtcEventLogManager::ClearCacheForBrowserContextInternal(
BrowserContextId browser_context_id,
const base::Time& delete_begin,
const base::Time& delete_end) { … }
void WebRtcEventLogManager::OnClearCacheForBrowserContextDoneInternal(
base::OnceClosure reply) { … }
void WebRtcEventLogManager::GetHistoryInternal(
BrowserContextId browser_context_id,
base::OnceCallback<void(const std::vector<UploadList::UploadInfo>&)>
reply) { … }
void WebRtcEventLogManager::RenderProcessExitedInternal(int render_process_id) { … }
void WebRtcEventLogManager::SetLocalLogsObserverInternal(
WebRtcLocalEventLogsObserver* observer,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetRemoteLogsObserverInternal(
WebRtcRemoteEventLogsObserver* observer,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetClockForTesting(base::Clock* clock,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetPeerConnectionTrackerProxyForTesting(
std::unique_ptr<PeerConnectionTrackerProxy> pc_tracker_proxy,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetWebRtcEventLogUploaderFactoryForTesting(
std::unique_ptr<WebRtcEventLogUploader::Factory> uploader_factory,
base::OnceClosure reply) { … }
void WebRtcEventLogManager::SetRemoteLogFileWriterFactoryForTesting(
std::unique_ptr<LogFileWriter::Factory> factory) { … }
void WebRtcEventLogManager::UploadConditionsHoldForTesting(
base::OnceCallback<void(bool)> callback) { … }
scoped_refptr<base::SequencedTaskRunner>
WebRtcEventLogManager::GetTaskRunnerForTesting() { … }
void WebRtcEventLogManager::PostNullTaskForTesting(base::OnceClosure reply) { … }
void WebRtcEventLogManager::ShutDownForTesting(base::OnceClosure reply) { … }
}