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

Side by Side Diff: content/browser/service_worker/service_worker_storage.h

Issue 248803003: ServiceWorker: Store registration data in ServiceWorkerDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_STORAGE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "content/browser/service_worker/service_worker_database.h" 16 #include "content/browser/service_worker/service_worker_database.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/service_worker/service_worker_status_code.h" 18 #include "content/common/service_worker/service_worker_status_code.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace quota { 21 namespace quota {
22 class QuotaManagerProxy; 22 class QuotaManagerProxy;
23 } 23 }
24 24
25 namespace content { 25 namespace content {
26 26
27 class ServiceWorkerContextCore; 27 class ServiceWorkerContextCore;
28 class ServiceWorkerRegistration; 28 class ServiceWorkerRegistration;
29 class ServiceWorkerRegistrationData;
29 class ServiceWorkerRegistrationInfo; 30 class ServiceWorkerRegistrationInfo;
30 class ServiceWorkerVersion; 31 class ServiceWorkerVersion;
31 32
32 // This class provides an interface to store and retrieve ServiceWorker 33 // This class provides an interface to store and retrieve ServiceWorker
33 // registration data. 34 // registration data.
34 class CONTENT_EXPORT ServiceWorkerStorage { 35 class CONTENT_EXPORT ServiceWorkerStorage {
35 public: 36 public:
36 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; 37 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback;
37 typedef base::Callback<void(ServiceWorkerStatusCode status, 38 typedef base::Callback<void(ServiceWorkerStatusCode status,
38 const scoped_refptr<ServiceWorkerRegistration>& 39 const scoped_refptr<ServiceWorkerRegistration>&
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 // Returns new IDs which are guaranteed to be unique in the storage. 92 // Returns new IDs which are guaranteed to be unique in the storage.
92 int64 NewRegistrationId(); 93 int64 NewRegistrationId();
93 int64 NewVersionId(); 94 int64 NewVersionId();
94 int64 NewResourceId(); 95 int64 NewResourceId();
95 96
96 private: 97 private:
97 friend class ServiceWorkerStorageTest; 98 friend class ServiceWorkerStorageTest;
98 99
99 scoped_refptr<ServiceWorkerRegistration> CreateRegistration( 100 scoped_refptr<ServiceWorkerRegistration> CreateRegistration(
100 const ServiceWorkerDatabase::RegistrationData* data); 101 const ServiceWorkerRegistrationData* data);
101 102
102 // TODO(michaeln): Store these structs in a database. 103 // TODO(michaeln): Store these structs in a database.
103 typedef std::map<int64, ServiceWorkerDatabase::RegistrationData> 104 typedef std::map<int64, ServiceWorkerRegistrationData> RegistrationsMap;
104 RegistrationsMap; 105 typedef std::map<GURL, RegistrationsMap> OriginRegistrationsMap;
105 typedef std::map<GURL, RegistrationsMap>
106 OriginRegistrationsMap;
107 OriginRegistrationsMap stored_registrations_; 106 OriginRegistrationsMap stored_registrations_;
108 107
109 // For iterating and lookup based on id only, this map holds 108 // For iterating and lookup based on id only, this map holds
110 // pointers to the values stored in the OriginRegistrationsMap. 109 // pointers to the values stored in the OriginRegistrationsMap.
111 typedef std::map<int64, ServiceWorkerDatabase::RegistrationData*> 110 typedef std::map<int64, ServiceWorkerRegistrationData*> RegistrationPtrMap;
112 RegistrationPtrMap;
113 RegistrationPtrMap registrations_by_id_; 111 RegistrationPtrMap registrations_by_id_;
114 112
115 int64 last_registration_id_; 113 int64 last_registration_id_;
116 int64 last_version_id_; 114 int64 last_version_id_;
117 int64 last_resource_id_; 115 int64 last_resource_id_;
118 bool simulated_lazy_initted_; 116 bool simulated_lazy_initted_;
119 117
120 base::FilePath path_; 118 base::FilePath path_;
121 base::WeakPtr<ServiceWorkerContextCore> context_; 119 base::WeakPtr<ServiceWorkerContextCore> context_;
122 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 120 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
123 121
124 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); 122 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage);
125 }; 123 };
126 124
127 } // namespace content 125 } // namespace content
128 126
129 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ 127 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698