chromium/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc

// Copyright 2014 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/safe_browsing/incident_reporting/incident_reporting_service.h"

#include <math.h>
#include <stddef.h>

#include <array>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/process/process.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/safe_browsing/incident_reporting/environment_data_collection.h"
#include "chrome/browser/safe_browsing/incident_reporting/extension_data_collection.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_report_uploader_impl.h"
#include "chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h"
#include "chrome/browser/safe_browsing/incident_reporting/state_store.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/preferences/public/mojom/tracked_preference_validation_delegate.mojom.h"

namespace safe_browsing {

BASE_FEATURE();

namespace {

// The action taken for an incident; used for user metrics (see
// LogIncidentDataType).
enum IncidentDisposition {};

// The state persisted for a specific instance of an incident to enable pruning
// of previously-reported incidents.
struct PersistentIncidentState {};

// The amount of time the service will wait to collate incidents.
const int64_t kDefaultUploadDelayMs =;  // one minute

// The amount of time between running delayed analysis callbacks.
const int64_t kDefaultCallbackIntervalMs =;

// Logs the type of incident in |incident_data| to a user metrics histogram.
void LogIncidentDataType(IncidentDisposition disposition,
                         const Incident& incident) {}

// Computes the persistent state for an incident.
PersistentIncidentState ComputeIncidentState(const Incident& incident) {}

// Returns a task runner for blocking tasks in the background.
scoped_refptr<base::TaskRunner> GetBackgroundTaskRunner() {}

}  // namespace

struct IncidentReportingService::ProfileContext {};

class IncidentReportingService::UploadContext {};

// An IncidentReceiver that is weakly-bound to the service and transparently
// bounces process-wide incidents back to the main thread for handling.
class IncidentReportingService::Receiver : public IncidentReceiver {};

IncidentReportingService::Receiver::Receiver(
    const base::WeakPtr<IncidentReportingService>& service)
    :{}

IncidentReportingService::Receiver::~Receiver() {}

void IncidentReportingService::Receiver::AddIncidentForProfile(
    Profile* profile,
    std::unique_ptr<Incident> incident) {}

void IncidentReportingService::Receiver::AddIncidentForProcess(
    std::unique_ptr<Incident> incident) {}

void IncidentReportingService::Receiver::ClearIncidentForProcess(
    std::unique_ptr<Incident> incident) {}

bool IncidentReportingService::HasIncidentsToUpload() const {}

// static
void IncidentReportingService::Receiver::AddIncidentOnMainThread(
    const base::WeakPtr<IncidentReportingService>& service,
    Profile* profile,
    std::unique_ptr<Incident> incident) {}

// static
void IncidentReportingService::Receiver::ClearIncidentOnMainThread(
    const base::WeakPtr<IncidentReportingService>& service,
    Profile* profile,
    std::unique_ptr<Incident> incident) {}

IncidentReportingService::ProfileContext::ProfileContext() :{}

IncidentReportingService::ProfileContext::~ProfileContext() {}

bool IncidentReportingService::ProfileContext::HasIncidents() const {}

IncidentReportingService::UploadContext::UploadContext(
    std::unique_ptr<ClientIncidentReport> report)
    :{}

IncidentReportingService::UploadContext::~UploadContext() {}

// static
bool IncidentReportingService::IsEnabledForProfile(Profile* profile) {}

IncidentReportingService::IncidentReportingService(
    SafeBrowsingService* safe_browsing_service)
    :{}

IncidentReportingService::~IncidentReportingService() {}

std::unique_ptr<IncidentReceiver>
IncidentReportingService::GetIncidentReceiver() {}

std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
IncidentReportingService::CreatePreferenceValidationDelegate(Profile* profile) {}

void IncidentReportingService::RegisterDelayedAnalysisCallback(
    DelayedAnalysisCallback callback) {}

void IncidentReportingService::AddDownloadManager(
    content::DownloadManager* download_manager) {}

IncidentReportingService::IncidentReportingService(
    SafeBrowsingService* safe_browsing_service,
    base::TimeDelta delayed_task_interval,
    const scoped_refptr<base::TaskRunner>& delayed_task_runner)
    :{}

void IncidentReportingService::SetCollectEnvironmentHook(
    CollectEnvironmentDataFn collect_environment_data_hook,
    const scoped_refptr<base::TaskRunner>& task_runner) {}

void IncidentReportingService::DoExtensionCollection(
    ClientIncidentReport_ExtensionData* extension_data) {}

void IncidentReportingService::OnProfileAdded(Profile* profile) {}

void IncidentReportingService::OnProfileWillBeDestroyed(Profile* profile) {}

std::unique_ptr<LastDownloadFinder>
IncidentReportingService::CreateDownloadFinder(
    LastDownloadFinder::LastDownloadCallback callback) {}

std::unique_ptr<IncidentReportUploader>
IncidentReportingService::StartReportUpload(
    IncidentReportUploader::OnResultCallback callback,
    const ClientIncidentReport& report) {}

bool IncidentReportingService::IsProcessingReport() const {}

IncidentReportingService::ProfileContext*
IncidentReportingService::GetOrCreateProfileContext(Profile* profile) {}

IncidentReportingService::ProfileContext*
IncidentReportingService::GetProfileContext(Profile* profile) {}

Profile* IncidentReportingService::FindEligibleProfile() const {}

void IncidentReportingService::AddIncident(Profile* profile,
                                           std::unique_ptr<Incident> incident) {}

void IncidentReportingService::ClearIncident(
    Profile* profile,
    std::unique_ptr<Incident> incident) {}

void IncidentReportingService::BeginReportProcessing() {}

void IncidentReportingService::BeginIncidentCollation() {}

bool IncidentReportingService::WaitingToCollateIncidents() {}

void IncidentReportingService::CancelIncidentCollection() {}

void IncidentReportingService::OnCollationTimeout() {}

void IncidentReportingService::BeginEnvironmentCollection() {}

bool IncidentReportingService::WaitingForEnvironmentCollection() {}

void IncidentReportingService::CancelEnvironmentCollection() {}

void IncidentReportingService::OnEnvironmentDataCollected(
    std::unique_ptr<ClientIncidentReport_EnvironmentData> environment_data) {}

void IncidentReportingService::BeginDownloadCollection() {}

bool IncidentReportingService::WaitingForMostRecentDownload() {}

void IncidentReportingService::CancelDownloadCollection() {}

void IncidentReportingService::OnLastDownloadFound(
    std::unique_ptr<ClientIncidentReport_DownloadDetails> last_binary_download,
    std::unique_ptr<ClientIncidentReport_NonBinaryDownloadDetails>
        last_non_binary_download) {}

void IncidentReportingService::ProcessIncidentsIfCollectionComplete() {}

void IncidentReportingService::CancelAllReportUploads() {}

void IncidentReportingService::UploadReportIfUploadingEnabled(
    UploadContext* context) {}

void IncidentReportingService::HandleResponse(const UploadContext& context) {}

void IncidentReportingService::OnReportUploadResult(
    UploadContext* context,
    IncidentReportUploader::Result result,
    std::unique_ptr<ClientIncidentResponse> response) {}

void IncidentReportingService::OnClientDownloadRequest(
    download::DownloadItem* download,
    const ClientDownloadRequest* request) {}

}  // namespace safe_browsing