#include "components/background_sync/background_sync_controller_impl.h"
#include "base/containers/contains.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/keep_alive_registry/keep_alive_registry.h"
#include "content/public/browser/background_sync_context.h"
#include "content/public/browser/background_sync_controller.h"
#include "content/public/browser/background_sync_parameters.h"
#include "content/public/browser/background_sync_registration.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/storage_partition.h"
#include "url/gurl.h"
#include "url/origin.h"
const char BackgroundSyncControllerImpl::kFieldTrialName[] = …;
const char BackgroundSyncControllerImpl::kDisabledParameterName[] = …;
#if BUILDFLAG(IS_ANDROID)
const char BackgroundSyncControllerImpl::kRelyOnAndroidNetworkDetection[] =
"rely_on_android_network_detection";
#endif
const char BackgroundSyncControllerImpl::kKeepBrowserAwakeParameterName[] = …;
const char BackgroundSyncControllerImpl::kSkipPermissionsCheckParameterName[] = …;
const char BackgroundSyncControllerImpl::kMaxAttemptsParameterName[] = …;
const char BackgroundSyncControllerImpl::
kMaxAttemptsWithNotificationPermissionParameterName[] = …;
const char BackgroundSyncControllerImpl::kInitialRetryParameterName[] = …;
const char BackgroundSyncControllerImpl::kRetryDelayFactorParameterName[] = …;
const char BackgroundSyncControllerImpl::kMinSyncRecoveryTimeName[] = …;
const char BackgroundSyncControllerImpl::kMaxSyncEventDurationName[] = …;
const char BackgroundSyncControllerImpl::kMinPeriodicSyncEventsInterval[] = …;
BackgroundSyncControllerImpl::BackgroundSyncControllerImpl(
content::BrowserContext* browser_context,
std::unique_ptr<background_sync::BackgroundSyncDelegate> delegate)
: … { … }
BackgroundSyncControllerImpl::~BackgroundSyncControllerImpl() = default;
void BackgroundSyncControllerImpl::OnContentSettingChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) { … }
void BackgroundSyncControllerImpl::GetParameterOverrides(
content::BackgroundSyncParameters* parameters) { … }
void BackgroundSyncControllerImpl::NotifyOneShotBackgroundSyncRegistered(
const url::Origin& origin,
bool can_fire,
bool is_reregistered) { … }
void BackgroundSyncControllerImpl::NotifyPeriodicBackgroundSyncRegistered(
const url::Origin& origin,
int min_interval,
bool is_reregistered) { … }
void BackgroundSyncControllerImpl::NotifyOneShotBackgroundSyncCompleted(
const url::Origin& origin,
blink::ServiceWorkerStatusCode status_code,
int num_attempts,
int max_attempts) { … }
void BackgroundSyncControllerImpl::NotifyPeriodicBackgroundSyncCompleted(
const url::Origin& origin,
blink::ServiceWorkerStatusCode status_code,
int num_attempts,
int max_attempts) { … }
void BackgroundSyncControllerImpl::ScheduleBrowserWakeUpWithDelay(
blink::mojom::BackgroundSyncType sync_type,
base::TimeDelta delay) { … }
void BackgroundSyncControllerImpl::CancelBrowserWakeup(
blink::mojom::BackgroundSyncType sync_type) { … }
base::TimeDelta BackgroundSyncControllerImpl::SnapToMaxOriginFrequency(
int64_t min_interval,
int64_t min_gap_for_origin) { … }
base::TimeDelta BackgroundSyncControllerImpl::ApplyMinGapForOrigin(
base::TimeDelta delay,
base::TimeDelta time_till_next_scheduled_event_for_origin,
base::TimeDelta min_gap_for_origin) { … }
bool BackgroundSyncControllerImpl::IsContentSettingBlocked(
const url::Origin& origin) { … }
void BackgroundSyncControllerImpl::Shutdown() { … }
base::TimeDelta BackgroundSyncControllerImpl::GetNextEventDelay(
const content::BackgroundSyncRegistration& registration,
content::BackgroundSyncParameters* parameters,
base::TimeDelta time_till_soonest_scheduled_event_for_origin) { … }
std::unique_ptr<content::BackgroundSyncController::BackgroundSyncEventKeepAlive>
BackgroundSyncControllerImpl::CreateBackgroundSyncEventKeepAlive() { … }
void BackgroundSyncControllerImpl::NoteSuspendedPeriodicSyncOrigins(
std::set<url::Origin> suspended_origins) { … }
void BackgroundSyncControllerImpl::NoteRegisteredPeriodicSyncOrigins(
std::set<url::Origin> registered_origins) { … }
void BackgroundSyncControllerImpl::AddToTrackedOrigins(
const url::Origin& origin) { … }
void BackgroundSyncControllerImpl::RemoveFromTrackedOrigins(
const url::Origin& origin) { … }