#include "components/safe_browsing/core/browser/db/v4_update_protocol_manager.h"
#include <utility>
#include "base/base64url.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/browser/db/safebrowsing.pb.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/utils.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.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 "services/network/public/mojom/url_response_head.mojom.h"
Time;
using enum safe_browsing::ExtendedReportingLevel;
namespace {
enum ParseResultType { … };
void RecordParseUpdateResult(ParseResultType result_type) { … }
void RecordUpdateResult(safe_browsing::V4OperationResult result) { … }
}
namespace safe_browsing {
static const int kV4TimerStartIntervalSecMin = …;
static const int kV4TimerStartIntervalSecMax = …;
static const int kV4TimerUpdateWaitSecMax = …;
ChromeClientInfo::SafeBrowsingReportingPopulation GetReportingLevelProtoValue(
ExtendedReportingLevel reporting_level) { … }
class V4UpdateProtocolManagerFactoryImpl
: public V4UpdateProtocolManagerFactory { … };
V4UpdateProtocolManagerFactory* V4UpdateProtocolManager::factory_ = …;
std::unique_ptr<V4UpdateProtocolManager> V4UpdateProtocolManager::Create(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const V4ProtocolConfig& config,
V4UpdateCallback update_callback,
ExtendedReportingLevelCallback extended_reporting_level_callback) { … }
void V4UpdateProtocolManager::ResetUpdateErrors() { … }
V4UpdateProtocolManager::V4UpdateProtocolManager(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const V4ProtocolConfig& config,
V4UpdateCallback update_callback,
ExtendedReportingLevelCallback extended_reporting_level_callback)
: … { … }
V4UpdateProtocolManager::~V4UpdateProtocolManager() { … }
bool V4UpdateProtocolManager::IsUpdateScheduled() const { … }
void V4UpdateProtocolManager::ScheduleNextUpdate(
std::unique_ptr<StoreStateMap> store_state_map) { … }
void V4UpdateProtocolManager::ScheduleNextUpdateWithBackoff(bool back_off) { … }
base::TimeDelta V4UpdateProtocolManager::GetNextUpdateInterval(bool back_off) { … }
void V4UpdateProtocolManager::ScheduleNextUpdateAfterInterval(
base::TimeDelta interval) { … }
std::string V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto() { … }
bool V4UpdateProtocolManager::ParseUpdateResponse(
const std::string& data,
ParsedServerResponse* parsed_server_response) { … }
void V4UpdateProtocolManager::IssueUpdateRequest() { … }
void V4UpdateProtocolManager::HandleTimeout() { … }
void V4UpdateProtocolManager::OnURLLoaderComplete(
std::unique_ptr<std::string> response_body) { … }
void V4UpdateProtocolManager::OnURLLoaderCompleteInternal(
int net_error,
int response_code,
const std::string& data) { … }
void V4UpdateProtocolManager::GetUpdateUrlAndHeaders(
const std::string& req_base64,
GURL* gurl,
net::HttpRequestHeaders* headers) const { … }
void V4UpdateProtocolManager::CollectUpdateInfo(
DatabaseManagerInfo::UpdateInfo* update_info) { … }
const base::Time& V4UpdateProtocolManager::last_response_time() const { … }
}