| Index: content/browser/service_worker/service_worker_database.h
|
| diff --git a/content/browser/service_worker/service_worker_database.h b/content/browser/service_worker/service_worker_database.h
|
| index 889f983667230a56d028a58ec2e28ca848338d9e..938071c4eb9b15d4011b942561c14b4aae6c5aef 100644
|
| --- a/content/browser/service_worker/service_worker_database.h
|
| +++ b/content/browser/service_worker/service_worker_database.h
|
| @@ -5,6 +5,9 @@
|
| #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
|
| #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_
|
|
|
| +#include <set>
|
| +#include <vector>
|
| +
|
| #include "base/files/file_path.h"
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| @@ -23,6 +26,9 @@ class WriteBatch;
|
|
|
| namespace content {
|
|
|
| +class ServiceWorkerRegistrationData;
|
| +class ServiceWorkerResourceRecord;
|
| +
|
| // Class to persist serviceworker registration data in a database.
|
| // Should NOT be used on the IO thread since this does blocking
|
| // file io. The ServiceWorkerStorage class owns this class and
|
| @@ -34,34 +40,38 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
|
| explicit ServiceWorkerDatabase(const base::FilePath& path);
|
| ~ServiceWorkerDatabase();
|
|
|
| - struct RegistrationData {
|
| - // These values are immutable for the life of a registration.
|
| - int64 registration_id;
|
| - GURL scope;
|
| - GURL script;
|
| -
|
| - // Versions are first stored once they successfully install and become
|
| - // the waiting version. Then transition to the active version. The stored
|
| - // version may be in the ACTIVE state or in the INSTALLED state.
|
| - int64 version_id;
|
| - bool is_active;
|
| - bool has_fetch_handler;
|
| - base::Time last_update_check;
|
| -
|
| - ServiceWorkerVersion::Status GetVersionStatus() const {
|
| - if (is_active)
|
| - return ServiceWorkerVersion::ACTIVE;
|
| - return ServiceWorkerVersion::INSTALLED;
|
| - }
|
| -
|
| - RegistrationData();
|
| - ~RegistrationData();
|
| - };
|
| -
|
| // For use during initialization.
|
| bool GetNextAvailableIds(int64* next_avail_registration_id,
|
| int64* next_avail_version_id,
|
| int64* next_avail_resource_id);
|
| + bool GetOriginsWithRegistrations(std::set<GURL>* origins);
|
| +
|
| + // For use when first handling a request in an origin with registrations.
|
| + bool GetRegistrationsForOrigin(
|
| + const GURL& origin,
|
| + std::vector<ServiceWorkerRegistrationData>* registrations);
|
| +
|
| + // Saving, retrieving, and updating registration data.
|
| + // (will bump next_avail_xxxx_ids as needed)
|
| + // (resource ids will be added/removed from the uncommitted/purgeable
|
| + // lists as needed)
|
| +
|
| + bool ReadRegistration(
|
| + int64 registration_id,
|
| + const GURL& origin,
|
| + ServiceWorkerRegistrationData* registration,
|
| + std::vector<ServiceWorkerResourceRecord>* resources);
|
| + bool WriteRegistration(
|
| + const ServiceWorkerRegistrationData& registration,
|
| + const std::vector<ServiceWorkerResourceRecord>& resources);
|
| +
|
| + bool UpdateVersionToActive(int64 registration_id,
|
| + const GURL& origin);
|
| + bool UpdateLastCheckTime(int64 registration_id,
|
| + const GURL& origin,
|
| + const base::Time& time);
|
| + bool DeleteRegistration(int64 registration_id,
|
| + const GURL& origin);
|
|
|
| bool is_disabled() const { return is_disabled_; }
|
| bool was_corruption_detected() const { return was_corruption_detected_; }
|
| @@ -79,8 +89,17 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
|
|
|
| bool ReadNextAvailableId(const char* id_key,
|
| int64* next_avail_id);
|
| + bool ReadRegistrationData(int64 registration_id,
|
| + const GURL& origin,
|
| + ServiceWorkerRegistrationData* registration);
|
| bool WriteBatch(leveldb::WriteBatch* batch);
|
|
|
| + // Bumps the next available id specified by |id_key| if |used_id| is greater
|
| + // than or equal to the stored one.
|
| + bool BumpNextAvailableIdIfNeeded(const char* id_key,
|
| + int64 used_id,
|
| + leveldb::WriteBatch* batch);
|
| +
|
| bool IsOpen();
|
| bool IsEmpty();
|
|
|
|
|