#include "third_party/blink/renderer/modules/service_worker/service_worker_event_queue.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom-blink.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
BASE_FEATURE(…);
constexpr base::TimeDelta ServiceWorkerEventQueue::kEventTimeout;
constexpr base::TimeDelta ServiceWorkerEventQueue::kUpdateInterval;
ServiceWorkerEventQueue::StayAwakeToken::StayAwakeToken(
base::WeakPtr<ServiceWorkerEventQueue> event_queue)
: … { … }
ServiceWorkerEventQueue::StayAwakeToken::~StayAwakeToken() { … }
ServiceWorkerEventQueue::ServiceWorkerEventQueue(
BeforeStartEventCallback before_start_event_callback,
base::RepeatingClosure idle_callback,
scoped_refptr<base::SequencedTaskRunner> task_runner)
: … { … }
ServiceWorkerEventQueue::ServiceWorkerEventQueue(
BeforeStartEventCallback before_start_event_callback,
base::RepeatingClosure idle_callback,
scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::TickClock* tick_clock)
: … { … }
ServiceWorkerEventQueue::~ServiceWorkerEventQueue() { … }
void ServiceWorkerEventQueue::Start() { … }
void ServiceWorkerEventQueue::EnqueueNormal(
int event_id,
StartCallback start_callback,
AbortCallback abort_callback,
std::optional<base::TimeDelta> custom_timeout) { … }
void ServiceWorkerEventQueue::EnqueuePending(
int event_id,
StartCallback start_callback,
AbortCallback abort_callback,
std::optional<base::TimeDelta> custom_timeout) { … }
void ServiceWorkerEventQueue::EnqueueOffline(
int event_id,
StartCallback start_callback,
AbortCallback abort_callback,
std::optional<base::TimeDelta> custom_timeout) { … }
bool ServiceWorkerEventQueue::CanStartEvent(const Event& event) const { … }
std::map<int, std::unique_ptr<ServiceWorkerEventQueue::Event>>&
ServiceWorkerEventQueue::GetActiveEventQueue() { … }
void ServiceWorkerEventQueue::EnqueueEvent(std::unique_ptr<Event> event) { … }
void ServiceWorkerEventQueue::ProcessEvents() { … }
void ServiceWorkerEventQueue::StartEvent(int event_id,
std::unique_ptr<Event> event) { … }
void ServiceWorkerEventQueue::EndEvent(int event_id) { … }
bool ServiceWorkerEventQueue::HasEvent(int event_id) const { … }
bool ServiceWorkerEventQueue::HasEventInQueue(int event_id) const { … }
std::unique_ptr<ServiceWorkerEventQueue::StayAwakeToken>
ServiceWorkerEventQueue::CreateStayAwakeToken() { … }
void ServiceWorkerEventQueue::SetIdleDelay(base::TimeDelta idle_delay) { … }
void ServiceWorkerEventQueue::CheckEventQueue() { … }
void ServiceWorkerEventQueue::UpdateStatus() { … }
void ServiceWorkerEventQueue::ScheduleIdleCallback(base::TimeDelta delay) { … }
void ServiceWorkerEventQueue::TriggerIdleCallback() { … }
void ServiceWorkerEventQueue::OnNoInflightEvent() { … }
bool ServiceWorkerEventQueue::HasInflightEvent() const { … }
void ServiceWorkerEventQueue::ResetIdleTimeout() { … }
bool ServiceWorkerEventQueue::HasScheduledIdleCallback() const { … }
int ServiceWorkerEventQueue::NextEventId() { … }
ServiceWorkerEventQueue::Event::Event(
int event_id,
ServiceWorkerEventQueue::Event::Type type,
StartCallback start_callback,
AbortCallback abort_callback,
std::optional<base::TimeDelta> custom_timeout)
: … { … }
ServiceWorkerEventQueue::Event::~Event() = default;
ServiceWorkerEventQueue::EventInfo::EventInfo(
base::TimeTicks expiration_time,
base::OnceCallback<void(blink::mojom::ServiceWorkerEventStatus)>
abort_callback)
: … { … }
ServiceWorkerEventQueue::EventInfo::~EventInfo() = default;
}