Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: content/browser/background_fetch/background_fetch_event_dispatcher.cc

Issue 2767093004: Implement the BackgroundFetch{Fail,ed} Service Worker events (Closed)
Patch Set: forward declare the data view Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_event_dispatcher.cc
diff --git a/content/browser/background_fetch/background_fetch_event_dispatcher.cc b/content/browser/background_fetch/background_fetch_event_dispatcher.cc
index 1fd7eb3ecbfd3c9b8f12e6fea3baf4f98b658160..41cb2c12091ff330efb839c2838efb183330bf05 100644
--- a/content/browser/background_fetch/background_fetch_event_dispatcher.cc
+++ b/content/browser/background_fetch/background_fetch_event_dispatcher.cc
@@ -24,6 +24,10 @@ std::string HistogramSuffixForEventType(ServiceWorkerMetrics::EventType event) {
return "AbortEvent";
case ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_CLICK:
return "ClickEvent";
+ case ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_FAIL:
+ return "FailEvent";
+ case ServiceWorkerMetrics::EventType::BACKGROUND_FETCHED:
+ return "FetchedEvent";
default:
NOTREACHED();
return std::string();
@@ -113,6 +117,58 @@ void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchClickEvent(
service_worker_version->CreateSimpleEventCallback(request_id));
}
+void BackgroundFetchEventDispatcher::DispatchBackgroundFetchFailEvent(
+ int64_t service_worker_registration_id,
+ const GURL& origin,
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ base::Closure finished_closure) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LoadServiceWorkerRegistrationForDispatch(
+ ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_FAIL,
+ service_worker_registration_id, origin, std::move(finished_closure),
+ base::Bind(
+ &BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchFailEvent,
+ tag, fetches));
+}
+
+void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchFailEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ scoped_refptr<ServiceWorkerVersion> service_worker_version,
+ int request_id) {
+ DCHECK(service_worker_version);
+ service_worker_version->event_dispatcher()->DispatchBackgroundFetchFailEvent(
+ tag, fetches,
+ service_worker_version->CreateSimpleEventCallback(request_id));
+}
+
+void BackgroundFetchEventDispatcher::DispatchBackgroundFetchedEvent(
+ int64_t service_worker_registration_id,
+ const GURL& origin,
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ base::Closure finished_closure) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LoadServiceWorkerRegistrationForDispatch(
+ ServiceWorkerMetrics::EventType::BACKGROUND_FETCHED,
+ service_worker_registration_id, origin, std::move(finished_closure),
+ base::Bind(
+ &BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchedEvent,
+ tag, fetches));
+}
+
+void BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchedEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ scoped_refptr<ServiceWorkerVersion> service_worker_version,
+ int request_id) {
+ DCHECK(service_worker_version);
+ service_worker_version->event_dispatcher()->DispatchBackgroundFetchedEvent(
+ tag, fetches,
+ service_worker_version->CreateSimpleEventCallback(request_id));
+}
+
void BackgroundFetchEventDispatcher::LoadServiceWorkerRegistrationForDispatch(
ServiceWorkerMetrics::EventType event,
int64_t service_worker_registration_id,

Powered by Google App Engine
This is Rietveld 408576698