#include "content/browser/push_messaging/push_messaging_router.h"
#include <string>
#include "base/check_deref.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "content/browser/devtools/devtools_background_services_context_impl.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_features.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/push_messaging/push_messaging.mojom.h"
#include "third_party/blink/public/mojom/push_messaging/push_messaging_status.mojom.h"
namespace content {
namespace {
ServiceWorkerStartCallback;
DevToolsBackgroundServicesContextImpl* GetDevTools(
const ServiceWorkerContextWrapper& service_worker_context) { … }
void RunPushEventCallback(
PushMessagingRouter::PushEventCallback deliver_message_callback,
blink::mojom::PushEventStatus push_event_status) { … }
void DidFindServiceWorkerRegistration(
ServiceWorkerMetrics::EventType event_type,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
ServiceWorkerStartCallback callback,
blink::ServiceWorkerStatusCode service_worker_status,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration) { … }
void FindServiceWorkerRegistration(
ServiceWorkerMetrics::EventType event_type,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
const url::Origin& origin,
int64_t service_worker_registration_id,
ServiceWorkerStartCallback callback) { … }
void StartServiceWorkerForDispatch(ServiceWorkerMetrics::EventType event_type,
BrowserContext* browser_context,
const GURL& origin,
int64_t service_worker_registration_id,
ServiceWorkerStartCallback callback) { … }
}
void PushMessagingRouter::DeliverMessage(
BrowserContext* browser_context,
const GURL& origin,
int64_t service_worker_registration_id,
const std::string& message_id,
std::optional<std::string> payload,
PushEventCallback deliver_message_callback) { … }
void PushMessagingRouter::DeliverMessageToWorker(
const std::string& message_id,
std::optional<std::string> payload,
PushEventCallback deliver_message_callback,
scoped_refptr<ServiceWorkerVersion> service_worker,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
blink::ServiceWorkerStatusCode status) { … }
void PushMessagingRouter::DeliverMessageEnd(
scoped_refptr<ServiceWorkerVersion> service_worker,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
const std::string& message_id,
PushEventCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status) { … }
void PushMessagingRouter::FireSubscriptionChangeEvent(
BrowserContext* browser_context,
const GURL& origin,
int64_t service_worker_registration_id,
blink::mojom::PushSubscriptionPtr new_subscription,
blink::mojom::PushSubscriptionPtr old_subscription,
PushEventCallback subscription_change_callback) { … }
void PushMessagingRouter::FireSubscriptionChangeEventToWorker(
blink::mojom::PushSubscriptionPtr new_subscription,
blink::mojom::PushSubscriptionPtr old_subscription,
PushEventCallback subscription_change_callback,
scoped_refptr<ServiceWorkerVersion> service_worker,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
blink::ServiceWorkerStatusCode status) { … }
void PushMessagingRouter::FireSubscriptionChangeEventEnd(
scoped_refptr<ServiceWorkerVersion> service_worker,
PushEventCallback subscription_change_callback,
blink::ServiceWorkerStatusCode service_worker_status) { … }
}