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

Unified Diff: content/browser/service_worker/service_worker_version.h

Issue 2251633002: Use tri-state enum for the existence of Fetch Handler in ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/status/existence/ Created 4 years, 4 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/service_worker_version.h
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h
index 0e368ab3c619bd97a8834f44dbbe84ff16382f78..530900c0a184d5d8452ca29f1e3d82bf8980ae2e 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -90,6 +90,13 @@ class CONTENT_EXPORT ServiceWorkerVersion
// timed out.
};
+ // Whether the version has fetch handlers or not.
+ enum class FetchHandlerExistence {
+ UNKNOWN, // This version is a new version and not installed yet.
+ EXISTS,
+ DOES_NOT_EXIST,
+ };
+
class Listener {
public:
virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {}
@@ -134,9 +141,17 @@ class CONTENT_EXPORT ServiceWorkerVersion
}
ServiceWorkerVersionInfo GetInfo();
Status status() const { return status_; }
- bool has_fetch_handler() const { return has_fetch_handler_; }
- void set_has_fetch_handler(bool has_fetch_handler) {
- has_fetch_handler_ = has_fetch_handler;
+
+ // This status is set to EXISTS or DOES_NOT_EXIST when the install event has
+ // been executed in a new version or when an installed version is loaded from
+ // the storage. When a new version is not installed yet, it is UNKNOW.
+ FetchHandlerExistence fetch_handler_existence() const {
+ return fetch_handler_existence_;
+ }
+ void set_fetch_handler_existence(FetchHandlerExistence existence) {
+ DCHECK_EQ(fetch_handler_existence_, FetchHandlerExistence::UNKNOWN);
+ DCHECK_NE(existence, FetchHandlerExistence::UNKNOWN);
+ fetch_handler_existence_ = existence;
}
const std::vector<GURL>& foreign_fetch_scopes() const {
@@ -663,7 +678,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
const GURL scope_;
std::vector<GURL> foreign_fetch_scopes_;
std::vector<url::Origin> foreign_fetch_origins_;
- bool has_fetch_handler_ = true;
+ FetchHandlerExistence fetch_handler_existence_;
Status status_ = NEW;
std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_;

Powered by Google App Engine
This is Rietveld 408576698