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

Unified Diff: content/browser/service_worker/embedded_worker_test_helper.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/service_worker/embedded_worker_test_helper.cc
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc
index e138fd26d0238b5ae8f6ca31a3e894a7a907520b..9d92c5b3186cb06be380f0f47588c017b7d64bd2 100644
--- a/content/browser/service_worker/embedded_worker_test_helper.cc
+++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -21,6 +21,7 @@
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_dispatcher_host.h"
+#include "content/common/background_fetch/background_fetch_types.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/common/service_worker/embedded_worker_start_params.h"
#include "content/common/service_worker/service_worker_messages.h"
@@ -174,6 +175,24 @@ class EmbeddedWorkerTestHelper::MockServiceWorkerEventDispatcher
helper_->OnBackgroundFetchClickEventStub(tag, state, callback);
}
+ void DispatchBackgroundFetchFailEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const DispatchBackgroundFetchFailEventCallback& callback) override {
+ if (!helper_)
+ return;
+ helper_->OnBackgroundFetchFailEventStub(tag, fetches, callback);
+ }
+
+ void DispatchBackgroundFetchedEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const DispatchBackgroundFetchedEventCallback& callback) override {
+ if (!helper_)
+ return;
+ helper_->OnBackgroundFetchedEventStub(tag, fetches, callback);
+ }
+
void DispatchFetchEvent(int fetch_event_id,
const ServiceWorkerFetchRequest& request,
mojom::FetchEventPreloadHandlePtr preload_handle,
@@ -412,6 +431,22 @@ void EmbeddedWorkerTestHelper::OnBackgroundFetchClickEvent(
callback.Run(SERVICE_WORKER_OK, base::Time::Now());
}
+void EmbeddedWorkerTestHelper::OnBackgroundFetchFailEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const mojom::ServiceWorkerEventDispatcher::
+ DispatchBackgroundFetchFailEventCallback& callback) {
+ callback.Run(SERVICE_WORKER_OK, base::Time::Now());
+}
+
+void EmbeddedWorkerTestHelper::OnBackgroundFetchedEvent(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const mojom::ServiceWorkerEventDispatcher::
+ DispatchBackgroundFetchedEventCallback& callback) {
+ callback.Run(SERVICE_WORKER_OK, base::Time::Now());
+}
+
void EmbeddedWorkerTestHelper::OnExtendableMessageEvent(
mojom::ExtendableMessageEventPtr event,
const mojom::ServiceWorkerEventDispatcher::
@@ -628,6 +663,27 @@ void EmbeddedWorkerTestHelper::OnBackgroundFetchClickEventStub(
AsWeakPtr(), tag, state, callback));
}
+void EmbeddedWorkerTestHelper::OnBackgroundFetchFailEventStub(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const mojom::ServiceWorkerEventDispatcher::
+ DispatchBackgroundFetchFailEventCallback& callback) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&EmbeddedWorkerTestHelper::OnBackgroundFetchFailEvent,
+ AsWeakPtr(), tag, fetches, callback));
+}
+
+void EmbeddedWorkerTestHelper::OnBackgroundFetchedEventStub(
+ const std::string& tag,
+ const std::vector<BackgroundFetchSettledFetch>& fetches,
+ const mojom::ServiceWorkerEventDispatcher::
+ DispatchBackgroundFetchedEventCallback& callback) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnBackgroundFetchedEvent,
+ AsWeakPtr(), tag, fetches, callback));
+}
+
void EmbeddedWorkerTestHelper::OnExtendableMessageEventStub(
mojom::ExtendableMessageEventPtr event,
const mojom::ServiceWorkerEventDispatcher::
« no previous file with comments | « content/browser/service_worker/embedded_worker_test_helper.h ('k') | content/browser/service_worker/service_worker_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698