#include "content/browser/background_fetch/background_fetch_event_dispatcher.h"
#include <map>
#include <sstream>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "content/browser/background_fetch/background_fetch_registration_id.h"
#include "content/browser/background_fetch/background_fetch_registration_service_impl.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/service_worker/service_worker_version.h"
#include "content/common/background_fetch/background_fetch_types.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
namespace content {
namespace {
std::string EventTypeToString(ServiceWorkerMetrics::EventType event) { … }
}
BackgroundFetchEventDispatcher::BackgroundFetchEventDispatcher(
BackgroundFetchContext* background_fetch_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
DevToolsBackgroundServicesContextImpl& devtools_context)
: … { … }
BackgroundFetchEventDispatcher::~BackgroundFetchEventDispatcher() { … }
void BackgroundFetchEventDispatcher::DispatchBackgroundFetchCompletionEvent(
const BackgroundFetchRegistrationId& registration_id,
blink::mojom::BackgroundFetchRegistrationDataPtr registration_data,
base::OnceClosure finished_closure) { … }
void BackgroundFetchEventDispatcher::DispatchBackgroundFetchAbortEvent(
const BackgroundFetchRegistrationId& registration_id,
blink::mojom::BackgroundFetchRegistrationPtr registration,
base::OnceClosure finished_closure) { … }
void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchAbortEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
scoped_refptr<ServiceWorkerVersion> service_worker_version,
int request_id) { … }
void BackgroundFetchEventDispatcher::DispatchBackgroundFetchClickEvent(
const BackgroundFetchRegistrationId& registration_id,
blink::mojom::BackgroundFetchRegistrationDataPtr registration_data,
base::OnceClosure finished_closure) { … }
void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchClickEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
scoped_refptr<ServiceWorkerVersion> service_worker_version,
int request_id) { … }
void BackgroundFetchEventDispatcher::DispatchBackgroundFetchFailEvent(
const BackgroundFetchRegistrationId& registration_id,
blink::mojom::BackgroundFetchRegistrationPtr registration,
base::OnceClosure finished_closure) { … }
void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchFailEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
scoped_refptr<ServiceWorkerVersion> service_worker_version,
int request_id) { … }
void BackgroundFetchEventDispatcher::DispatchBackgroundFetchSuccessEvent(
const BackgroundFetchRegistrationId& registration_id,
blink::mojom::BackgroundFetchRegistrationPtr registration,
base::OnceClosure finished_closure) { … }
void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchSuccessEvent(
blink::mojom::BackgroundFetchRegistrationPtr registration,
scoped_refptr<ServiceWorkerVersion> service_worker_version,
int request_id) { … }
void BackgroundFetchEventDispatcher::LoadServiceWorkerRegistrationForDispatch(
const BackgroundFetchRegistrationId& registration_id,
ServiceWorkerMetrics::EventType event,
base::OnceClosure finished_closure,
ServiceWorkerLoadedCallback loaded_callback) { … }
void BackgroundFetchEventDispatcher::StartActiveWorkerForDispatch(
ServiceWorkerMetrics::EventType event,
base::OnceClosure finished_closure,
ServiceWorkerLoadedCallback loaded_callback,
blink::ServiceWorkerStatusCode service_worker_status,
scoped_refptr<ServiceWorkerRegistration> registration) { … }
void BackgroundFetchEventDispatcher::DispatchEvent(
ServiceWorkerMetrics::EventType event,
base::OnceClosure finished_closure,
ServiceWorkerLoadedCallback loaded_callback,
scoped_refptr<ServiceWorkerVersion> service_worker_version,
blink::ServiceWorkerStatusCode start_worker_status) { … }
void BackgroundFetchEventDispatcher::DidDispatchEvent(
ServiceWorkerMetrics::EventType event,
base::OnceClosure finished_closure,
DispatchPhase dispatch_phase,
blink::ServiceWorkerStatusCode service_worker_status) { … }
void BackgroundFetchEventDispatcher::LogBackgroundFetchCompletionForDevTools(
const BackgroundFetchRegistrationId& registration_id,
ServiceWorkerMetrics::EventType event_type,
blink::mojom::BackgroundFetchFailureReason failure_reason) { … }
void BackgroundFetchEventDispatcher::Shutdown() { … }
}