#include "chrome/browser/media/webrtc/webrtc_event_log_uploader.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/webrtc/webrtc_log_uploader.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "ui/base/text/bytes_formatting.h"
namespace webrtc_event_logging {
namespace {
const char kUploadContentType[] = …;
const char kBoundary[] = …;
constexpr size_t kExpectedMimeOverheadBytes = …;
constexpr net::NetworkTrafficAnnotationTag
kWebrtcEventLogUploaderTrafficAnnotation = …;
void AddFileContents(const char* filename,
const std::string& file_contents,
const std::string& content_type,
std::string* post_data) { … }
std::string MimeContentType() { … }
void BindURLLoaderFactoryReceiver(
mojo::PendingReceiver<network::mojom::URLLoaderFactory>
url_loader_factory_receiver) { … }
void OnURLLoadUploadProgress(uint64_t current, uint64_t total) { … }
}
const char WebRtcEventLogUploaderImpl::kUploadURL[] = …;
WebRtcEventLogUploaderImpl::Factory::Factory(
scoped_refptr<base::SequencedTaskRunner> task_runner)
: … { … }
WebRtcEventLogUploaderImpl::Factory::~Factory() = default;
std::unique_ptr<WebRtcEventLogUploader>
WebRtcEventLogUploaderImpl::Factory::Create(const WebRtcLogFileInfo& log_file,
UploadResultCallback callback) { … }
std::unique_ptr<WebRtcEventLogUploader>
WebRtcEventLogUploaderImpl::Factory::CreateWithCustomMaxSizeForTesting(
const WebRtcLogFileInfo& log_file,
UploadResultCallback callback,
size_t max_log_file_size_bytes) { … }
WebRtcEventLogUploaderImpl::WebRtcEventLogUploaderImpl(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const WebRtcLogFileInfo& log_file,
UploadResultCallback callback,
size_t max_log_file_size_bytes)
: … { … }
WebRtcEventLogUploaderImpl::~WebRtcEventLogUploaderImpl() { … }
const WebRtcLogFileInfo& WebRtcEventLogUploaderImpl::GetWebRtcLogFileInfo()
const { … }
void WebRtcEventLogUploaderImpl::Cancel() { … }
bool WebRtcEventLogUploaderImpl::PrepareUploadData(std::string* upload_data) { … }
void WebRtcEventLogUploaderImpl::StartUpload(const std::string& upload_data) { … }
void WebRtcEventLogUploaderImpl::OnURLLoadComplete(
std::unique_ptr<std::string> response_body) { … }
void WebRtcEventLogUploaderImpl::ReportResult(bool upload_successful,
bool delete_history_file) { … }
void WebRtcEventLogUploaderImpl::DeleteLogFile() { … }
void WebRtcEventLogUploaderImpl::DeleteHistoryFile() { … }
}