Provide a high layer API to check SW's offline capability
This CL is the part in a series of CLs, roughly described as follows:
1. Refactor SeriviceWorkerTimeoutTimer
Unify normal events and pending tasks.
2. Rename SeriviceWorkerTimeoutTimer to ServiceWorkerEventQueue.
3. Further clean up ServiceWorkerEventQueue.
4. Support offline events in ServiceWorkerEventQueue
5. Support offline mode in ServiceWorkerGlobalScope
6. Provide a high layer API to check SW's offline capability (<= this CL.)
This CL implements a high layer API,
|ServiceWorkerContext::CheckOfflineCapability(url, callback)|,
which is intended to be used from clients, such as Add2HomeScreen
feature, who want to know SW's offline capability.
A callback receives enum, |OfflineCapability|, whose meaning is:
- kSupported: SW exists for the url, and its fetch event handler can
return a 200 result even in offline mode. We consider SW has an
offline capability in this case.
- kUnsupported: Any other cases, such as:
- SW does not exist.
- SW's fetch handler can't return a 200 result in offline-mode.
- internal errors such as disk failures, timeout, and etc.
Bug: 965802
Change-Id: If68cfeea2f3337b88a53a3cf0fd6ac87ee3bd66c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900804
Commit-Queue: Hayato Ito <[email protected]>
Reviewed-by: Matt Falkenhagen <[email protected]>
Reviewed-by: Makoto Shimazu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#729678}
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 0b91939b..c4bc9e5d 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -1671,6 +1671,8 @@
"service_worker/service_worker_new_script_loader.h",
"service_worker/service_worker_object_host.cc",
"service_worker/service_worker_object_host.h",
+ "service_worker/service_worker_offline_capability_checker.cc",
+ "service_worker/service_worker_offline_capability_checker.h",
"service_worker/service_worker_ping_controller.cc",
"service_worker/service_worker_ping_controller.h",
"service_worker/service_worker_process_manager.cc",