chromium/chrome/browser/media/webrtc/webrtc_event_log_manager_remote.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/media/webrtc/webrtc_event_log_manager_remote.h"

#include <iterator>
#include <utility>

#include "base/command_line.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"

namespace webrtc_event_logging {

// TODO(crbug.com/40545136): Change max back to (1u << 29) after resolving the
// issue where we read the entire file into memory.
const size_t kMaxRemoteLogFileSizeBytes =;

const int kDefaultOutputPeriodMs =;
const int kMaxOutputPeriodMs =;

namespace {
const base::TimeDelta kDefaultProactivePruningDelta =;

const base::TimeDelta kDefaultWebRtcRemoteEventLogUploadDelay =;

// Because history files are rarely used, their existence is not kept in memory.
// That means that pruning them involves inspecting data on disk. This is not
// terribly cheap (up to kMaxWebRtcEventLogHistoryFiles files per profile), and
// should therefore be done somewhat infrequently.
const base::TimeDelta kProactiveHistoryFilesPruneDelta =;

base::TimeDelta GetProactivePendingLogsPruneDelta() {}

base::TimeDelta GetUploadDelay() {}

bool TimePointInRange(const base::Time& time_point,
                      const base::Time& range_begin,
                      const base::Time& range_end) {}

// Do not attempt to upload when there is no active connection.
// Do not attempt to upload if the connection is known to be a mobile one.
// Note #1: A device may have multiple connections, so this is not bullet-proof.
// Note #2: Does not attempt to recognize mobile hotspots.
bool UploadSupportedUsingConnectionType(
    network::mojom::ConnectionType connection) {}

// Produce a history file for a given file.
void CreateHistoryFile(const base::FilePath& log_file_path,
                       const base::Time& capture_time) {}

// The following is a list of entry types used to transmit information
// from GetHistory() to the caller (normally - the UI).
// Each entry is of type UploadList::UploadInfo. Depending on the entry
// type, the fields in the UploadInfo have different values:
// 1+2. Currently-being-captured or pending -> State::Pending && !upload_time.
//   3. Currently-being-uploaded -> State::Pending && upload_time.
//   4. Pruned before being uploaded -> State::NotUploaded && !upload_time.
//   5. Unsuccessful upload attempt -> State::NotUploaded && upload_time.
//   6. Successfully uploaded -> State::Uploaded.
//
// As for the meaning of the local_id field, its semantics change according to
// the above entry type.
// * For cases 1-3 above, it is the filename, since the log is still on disk.
// * For cases 5-6 above, it is the local log ID that the now-deleted file used
// * to have.
namespace history {
UploadList::UploadInfo CreateActivelyCapturedLogEntry(
    const base::FilePath& path,
    const base::Time& capture_time) {}

UploadList::UploadInfo CreatePendingLogEntry(
    const WebRtcLogFileInfo& log_info) {}

UploadList::UploadInfo CreateActivelyUploadedLogEntry(
    const WebRtcLogFileInfo& log_info,
    const base::Time& upload_time) {}

UploadList::UploadInfo CreateEntryFromHistoryFileReader(
    const WebRtcEventLogHistoryFileReader& reader) {}
}  // namespace history
}  // namespace

const size_t kMaxActiveRemoteBoundWebRtcEventLogs =;
const size_t kMaxPendingRemoteBoundWebRtcEventLogs =;
static_assert;
const size_t kMaxWebRtcEventLogHistoryFiles =;

// Maximum time to keep remote-bound logs on disk.
const base::TimeDelta kRemoteBoundWebRtcEventLogsMaxRetention =;

// Maximum time to keep history files on disk. These serve to display an upload
// on chrome://webrtc-logs/. It is persisted for longer than the log itself.
const base::TimeDelta kHistoryFileRetention =;

WebRtcRemoteEventLogManager::WebRtcRemoteEventLogManager(
    WebRtcRemoteEventLogsObserver* observer,
    scoped_refptr<base::SequencedTaskRunner> task_runner)
    :{}

WebRtcRemoteEventLogManager::~WebRtcRemoteEventLogManager() {}

void WebRtcRemoteEventLogManager::SetNetworkConnectionTracker(
    network::NetworkConnectionTracker* network_connection_tracker) {}

void WebRtcRemoteEventLogManager::SetLogFileWriterFactory(
    std::unique_ptr<LogFileWriter::Factory> log_file_writer_factory) {}

void WebRtcRemoteEventLogManager::EnableForBrowserContext(
    BrowserContextId browser_context_id,
    const base::FilePath& browser_context_dir) {}

void WebRtcRemoteEventLogManager::DisableForBrowserContext(
    BrowserContextId browser_context_id) {}

bool WebRtcRemoteEventLogManager::OnPeerConnectionAdded(
    const PeerConnectionKey& key) {}

bool WebRtcRemoteEventLogManager::OnPeerConnectionRemoved(
    const PeerConnectionKey& key) {}

bool WebRtcRemoteEventLogManager::OnPeerConnectionSessionIdSet(
    const PeerConnectionKey& key,
    const std::string& session_id) {}

bool WebRtcRemoteEventLogManager::StartRemoteLogging(
    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,
    std::string* log_id,
    std::string* error_message) {}

bool WebRtcRemoteEventLogManager::EventLogWrite(const PeerConnectionKey& key,
                                                const std::string& message) {}

void WebRtcRemoteEventLogManager::ClearCacheForBrowserContext(
    BrowserContextId browser_context_id,
    const base::Time& delete_begin,
    const base::Time& delete_end) {}

void WebRtcRemoteEventLogManager::GetHistory(
    BrowserContextId browser_context_id,
    base::OnceCallback<void(const std::vector<UploadList::UploadInfo>&)>
        reply) {}

void WebRtcRemoteEventLogManager::RemovePendingLogsForNotEnabledBrowserContext(
    BrowserContextId browser_context_id,
    const base::FilePath& browser_context_dir) {}

void WebRtcRemoteEventLogManager::RenderProcessHostExitedDestroyed(
    int render_process_id) {}

void WebRtcRemoteEventLogManager::OnConnectionChanged(
    network::mojom::ConnectionType type) {}

void WebRtcRemoteEventLogManager::SetWebRtcEventLogUploaderFactoryForTesting(
    std::unique_ptr<WebRtcEventLogUploader::Factory> uploader_factory) {}

void WebRtcRemoteEventLogManager::UploadConditionsHoldForTesting(
    base::OnceCallback<void(bool)> callback) {}

void WebRtcRemoteEventLogManager::ShutDownForTesting(base::OnceClosure reply) {}

bool WebRtcRemoteEventLogManager::AreLogParametersValid(
    size_t max_file_size_bytes,
    int output_period_ms,
    size_t web_app_id,
    std::string* error_message) const {}

bool WebRtcRemoteEventLogManager::BrowserContextEnabled(
    BrowserContextId browser_context_id) const {}

WebRtcRemoteEventLogManager::LogFilesMap::iterator
WebRtcRemoteEventLogManager::CloseLogFile(LogFilesMap::iterator it,
                                          bool make_pending) {}

bool WebRtcRemoteEventLogManager::MaybeCreateLogsDirectory(
    const base::FilePath& remote_bound_logs_dir) {}

void WebRtcRemoteEventLogManager::LoadLogsDirectory(
    BrowserContextId browser_context_id,
    const base::FilePath& remote_bound_logs_dir) {}

bool WebRtcRemoteEventLogManager::LoadPendingLogInfo(
    BrowserContextId browser_context_id,
    const base::FilePath& path,
    base::Time last_modified) {}

std::unique_ptr<WebRtcEventLogHistoryFileReader>
WebRtcRemoteEventLogManager::LoadHistoryFile(
    BrowserContextId browser_context_id,
    const base::FilePath& path,
    const base::Time& prune_begin,
    const base::Time& prune_end) {}

std::set<WebRtcEventLogHistoryFileReader>
WebRtcRemoteEventLogManager::PruneAndLoadHistoryFilesForBrowserContext(
    const base::Time& prune_begin,
    const base::Time& prune_end,
    BrowserContextId browser_context_id) {}

bool WebRtcRemoteEventLogManager::StartWritingLog(
    const PeerConnectionKey& key,
    const base::FilePath& browser_context_dir,
    size_t max_file_size_bytes,
    int output_period_ms,
    size_t web_app_id,
    std::string* log_id_out,
    std::string* error_message_out) {}

void WebRtcRemoteEventLogManager::MaybeStopRemoteLogging(
    const PeerConnectionKey& key) {}

void WebRtcRemoteEventLogManager::PrunePendingLogs(
    std::optional<BrowserContextId> browser_context_id) {}

void WebRtcRemoteEventLogManager::RecurringlyPrunePendingLogs() {}

void WebRtcRemoteEventLogManager::PruneHistoryFiles() {}

void WebRtcRemoteEventLogManager::RecurringlyPruneHistoryFiles() {}

void WebRtcRemoteEventLogManager::MaybeCancelActiveLogs(
    const base::Time& delete_begin,
    const base::Time& delete_end,
    BrowserContextId browser_context_id) {}

void WebRtcRemoteEventLogManager::MaybeRemovePendingLogs(
    const base::Time& delete_begin,
    const base::Time& delete_end,
    std::optional<BrowserContextId> browser_context_id,
    bool is_cache_clear) {}

void WebRtcRemoteEventLogManager::MaybeRemoveHistoryFiles(
    const base::Time& delete_begin,
    const base::Time& delete_end,
    BrowserContextId browser_context_id) {}

void WebRtcRemoteEventLogManager::MaybeCancelUpload(
    const base::Time& delete_begin,
    const base::Time& delete_end,
    BrowserContextId browser_context_id) {}

bool WebRtcRemoteEventLogManager::MatchesFilter(
    BrowserContextId log_browser_context_id,
    const base::Time& log_last_modification,
    std::optional<BrowserContextId> filter_browser_context_id,
    const base::Time& filter_range_begin,
    const base::Time& filter_range_end) const {}

bool WebRtcRemoteEventLogManager::AdditionalActiveLogAllowed(
    BrowserContextId browser_context_id) const {}

bool WebRtcRemoteEventLogManager::UploadSuppressed() const {}

bool WebRtcRemoteEventLogManager::UploadConditionsHold() const {}

void WebRtcRemoteEventLogManager::ManageUploadSchedule() {}

void WebRtcRemoteEventLogManager::MaybeStartUploading() {}

void WebRtcRemoteEventLogManager::OnWebRtcEventLogUploadComplete(
    const base::FilePath& log_file,
    bool upload_successful) {}

bool WebRtcRemoteEventLogManager::FindPeerConnection(
    int render_process_id,
    const std::string& session_id,
    PeerConnectionKey* key) const {}

WebRtcRemoteEventLogManager::PeerConnectionMap::const_iterator
WebRtcRemoteEventLogManager::FindNextPeerConnection(
    PeerConnectionMap::const_iterator begin,
    int render_process_id,
    const std::string& session_id) const {}

}  // namespace webrtc_event_logging