| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/optional.h" | 19 #include "base/optional.h" |
| 20 #include "base/sequence_checker.h" | 20 #include "base/sequence_checker.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/common/origin_trials/trial_token_validator.h" | 23 #include "content/common/origin_trials/trial_token_validator.h" |
| 24 #include "content/common/service_worker/service_worker_status_code.h" | 24 #include "content/common/service_worker/service_worker_status_code.h" |
| 25 #include "content/common/service_worker/service_worker_types.h" | 25 #include "content/common/service_worker/service_worker_types.h" |
| 26 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerUpdateViaCache.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 #include "url/origin.h" | 28 #include "url/origin.h" |
| 28 | 29 |
| 29 namespace tracked_objects { | 30 namespace tracked_objects { |
| 30 class Location; | 31 class Location; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace leveldb { | 34 namespace leveldb { |
| 34 class DB; | 35 class DB; |
| 35 class Env; | 36 class Env; |
| 36 class Status; | 37 class Status; |
| 37 class WriteBatch; | 38 class WriteBatch; |
| 38 } | 39 } // namespace leveldb |
| 39 | 40 |
| 40 namespace content { | 41 namespace content { |
| 41 | 42 |
| 42 // Class to persist serviceworker registration data in a database. | 43 // Class to persist serviceworker registration data in a database. |
| 43 // Should NOT be used on the IO thread since this does blocking | 44 // Should NOT be used on the IO thread since this does blocking |
| 44 // file io. The ServiceWorkerStorage class owns this class and | 45 // file io. The ServiceWorkerStorage class owns this class and |
| 45 // is responsible for only calling it serially on background | 46 // is responsible for only calling it serially on background |
| 46 // non-IO threads (ala SequencedWorkerPool). | 47 // non-IO threads (ala SequencedWorkerPool). |
| 47 class CONTENT_EXPORT ServiceWorkerDatabase { | 48 class CONTENT_EXPORT ServiceWorkerDatabase { |
| 48 public: | 49 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 STATUS_ERROR_FAILED, | 60 STATUS_ERROR_FAILED, |
| 60 STATUS_ERROR_NOT_SUPPORTED, | 61 STATUS_ERROR_NOT_SUPPORTED, |
| 61 STATUS_ERROR_MAX, | 62 STATUS_ERROR_MAX, |
| 62 }; | 63 }; |
| 63 static const char* StatusToString(Status status); | 64 static const char* StatusToString(Status status); |
| 64 | 65 |
| 65 struct CONTENT_EXPORT RegistrationData { | 66 struct CONTENT_EXPORT RegistrationData { |
| 66 // These values are immutable for the life of a registration. | 67 // These values are immutable for the life of a registration. |
| 67 int64_t registration_id; | 68 int64_t registration_id; |
| 68 GURL scope; | 69 GURL scope; |
| 70 blink::WebServiceWorkerUpdateViaCache update_via_cache; |
| 69 | 71 |
| 70 // Versions are first stored once they successfully install and become | 72 // Versions are first stored once they successfully install and become |
| 71 // the waiting version. Then transition to the active version. The stored | 73 // the waiting version. Then transition to the active version. The stored |
| 72 // version may be in the ACTIVATED state or in the INSTALLED state. | 74 // version may be in the ACTIVATED state or in the INSTALLED state. |
| 73 GURL script; | 75 GURL script; |
| 74 int64_t version_id; | 76 int64_t version_id; |
| 75 bool is_active; | 77 bool is_active; |
| 76 bool has_fetch_handler; | 78 bool has_fetch_handler; |
| 77 base::Time last_update_check; | 79 base::Time last_update_check; |
| 78 std::vector<GURL> foreign_fetch_scopes; | 80 std::vector<GURL> foreign_fetch_scopes; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, | 416 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, |
| 415 UserData_UninitializedDatabase); | 417 UserData_UninitializedDatabase); |
| 416 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); | 418 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDatabaseTest, DestroyDatabase); |
| 417 | 419 |
| 418 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); | 420 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDatabase); |
| 419 }; | 421 }; |
| 420 | 422 |
| 421 } // namespace content | 423 } // namespace content |
| 422 | 424 |
| 423 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ | 425 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ |
| OLD | NEW |