#include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h"
#include <utility>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/supports_user_data.h"
#include "base/task/task_runner.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/safe_browsing/download_protection/download_feedback.h"
#include "components/download/public/common/download_item.h"
#include "content/public/browser/browser_thread.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace safe_browsing {
namespace {
const void* const kPingKey = …;
class DownloadFeedbackPings : public base::SupportsUserData::Data { … };
DownloadFeedbackPings::DownloadFeedbackPings(const std::string& ping_request,
const std::string& ping_response)
: … { … }
void DownloadFeedbackPings::CreateForDownload(
download::DownloadItem* download,
const std::string& ping_request,
const std::string& ping_response) { … }
DownloadFeedbackPings* DownloadFeedbackPings::FromDownload(
const download::DownloadItem& download) { … }
}
DownloadFeedbackService::DownloadFeedbackService(
DownloadProtectionService* download_protection_service,
base::TaskRunner* file_task_runner)
: … { … }
DownloadFeedbackService::~DownloadFeedbackService() { … }
void DownloadFeedbackService::MaybeStorePingsForDownload(
DownloadCheckResult result,
bool upload_requested,
download::DownloadItem* download,
const std::string& ping,
const std::string& response) { … }
bool DownloadFeedbackService::IsEnabledForDownload(
const download::DownloadItem& download) { … }
bool DownloadFeedbackService::GetPingsForDownloadForTesting(
const download::DownloadItem& download,
std::string* ping,
std::string* response) { … }
void DownloadFeedbackService::BeginFeedbackForDownload(
Profile* profile,
download::DownloadItem* download,
DownloadCommands::Command download_command) { … }
void DownloadFeedbackService::BeginFeedbackOrDeleteFile(
const scoped_refptr<base::TaskRunner>& file_task_runner,
const base::WeakPtr<DownloadFeedbackService>& service,
Profile* profile,
const std::string& ping_request,
const std::string& ping_response,
uint64_t file_size,
const base::FilePath& path) { … }
void DownloadFeedbackService::StartPendingFeedback() { … }
void DownloadFeedbackService::BeginFeedback(Profile* profile,
const std::string& ping_request,
const std::string& ping_response,
const base::FilePath& path,
uint64_t file_size) { … }
void DownloadFeedbackService::FeedbackComplete() { … }
}