OLD | NEW |
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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // but not yet stored with a registration. | 174 // but not yet stored with a registration. |
175 void StoreUncommittedResourceId(int64_t resource_id); | 175 void StoreUncommittedResourceId(int64_t resource_id); |
176 | 176 |
177 // Removes resource ids from uncommitted list, adds them to the purgeable list | 177 // Removes resource ids from uncommitted list, adds them to the purgeable list |
178 // and purges them. | 178 // and purges them. |
179 void DoomUncommittedResource(int64_t resource_id); | 179 void DoomUncommittedResource(int64_t resource_id); |
180 void DoomUncommittedResources(const std::set<int64_t>& resource_ids); | 180 void DoomUncommittedResources(const std::set<int64_t>& resource_ids); |
181 | 181 |
182 // Provide a storage mechanism to read/write arbitrary data associated with | 182 // Provide a storage mechanism to read/write arbitrary data associated with |
183 // a registration. Each registration has its own key namespace. | 183 // a registration. Each registration has its own key namespace. |
184 // GetUserData responds OK only if all keys are found; otherwise NOT_FOUND, | 184 // GetUserData/GetUserDataByKeyPrefix responds OK only if all keys are found; |
185 // and the callback's data will be empty. | 185 // otherwise NOT_FOUND, and the callback's data will be empty. |
186 void GetUserData(int64_t registration_id, | 186 void GetUserData(int64_t registration_id, |
187 const std::vector<std::string>& keys, | 187 const std::vector<std::string>& keys, |
188 const GetUserDataCallback& callback); | 188 const GetUserDataCallback& callback); |
| 189 void GetUserDataByKeyPrefix(int64_t registration_id, |
| 190 const std::string& key_prefix, |
| 191 const GetUserDataCallback& callback); |
| 192 |
189 // Stored data is deleted when the associated registraton is deleted. | 193 // Stored data is deleted when the associated registraton is deleted. |
190 void StoreUserData( | 194 void StoreUserData( |
191 int64_t registration_id, | 195 int64_t registration_id, |
192 const GURL& origin, | 196 const GURL& origin, |
193 const std::vector<std::pair<std::string, std::string>>& key_value_pairs, | 197 const std::vector<std::pair<std::string, std::string>>& key_value_pairs, |
194 const StatusCallback& callback); | 198 const StatusCallback& callback); |
195 // Responds OK if all are successfully deleted or not found in the database. | 199 // Responds OK if all are successfully deleted or not found in the database. |
196 void ClearUserData(int64_t registration_id, | 200 void ClearUserData(int64_t registration_id, |
197 const std::vector<std::string>& keys, | 201 const std::vector<std::string>& keys, |
198 const StatusCallback& callback); | 202 const StatusCallback& callback); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 ServiceWorkerDatabase* database, | 496 ServiceWorkerDatabase* database, |
493 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 497 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
494 int64_t registration_id, | 498 int64_t registration_id, |
495 const FindInDBCallback& callback); | 499 const FindInDBCallback& callback); |
496 static void GetUserDataInDB( | 500 static void GetUserDataInDB( |
497 ServiceWorkerDatabase* database, | 501 ServiceWorkerDatabase* database, |
498 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 502 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
499 int64_t registration_id, | 503 int64_t registration_id, |
500 const std::vector<std::string>& keys, | 504 const std::vector<std::string>& keys, |
501 const GetUserDataInDBCallback& callback); | 505 const GetUserDataInDBCallback& callback); |
| 506 static void GetUserDataByKeyPrefixInDB( |
| 507 ServiceWorkerDatabase* database, |
| 508 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
| 509 int64_t registration_id, |
| 510 const std::string& key_prefix, |
| 511 const GetUserDataInDBCallback& callback); |
502 static void GetUserDataForAllRegistrationsInDB( | 512 static void GetUserDataForAllRegistrationsInDB( |
503 ServiceWorkerDatabase* database, | 513 ServiceWorkerDatabase* database, |
504 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 514 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
505 const std::string& key, | 515 const std::string& key, |
506 const GetUserDataForAllRegistrationsInDBCallback& callback); | 516 const GetUserDataForAllRegistrationsInDBCallback& callback); |
507 static void DeleteAllDataForOriginsFromDB( | 517 static void DeleteAllDataForOriginsFromDB( |
508 ServiceWorkerDatabase* database, | 518 ServiceWorkerDatabase* database, |
509 const std::set<GURL>& origins); | 519 const std::set<GURL>& origins); |
510 | 520 |
511 bool IsDisabled() const; | 521 bool IsDisabled() const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 std::set<int64_t> pending_deletions_; | 571 std::set<int64_t> pending_deletions_; |
562 | 572 |
563 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 573 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
564 | 574 |
565 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 575 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
566 }; | 576 }; |
567 | 577 |
568 } // namespace content | 578 } // namespace content |
569 | 579 |
570 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 580 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |