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/GetUserDataByKeyPrefix responds OK only if all keys are found; | 184 // GetUserData responds OK only if all keys are found; otherwise NOT_FOUND, |
185 // otherwise NOT_FOUND, and the callback's data will be empty. | 185 // 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 | |
193 // Stored data is deleted when the associated registraton is deleted. | 189 // Stored data is deleted when the associated registraton is deleted. |
194 void StoreUserData( | 190 void StoreUserData( |
195 int64_t registration_id, | 191 int64_t registration_id, |
196 const GURL& origin, | 192 const GURL& origin, |
197 const std::vector<std::pair<std::string, std::string>>& key_value_pairs, | 193 const std::vector<std::pair<std::string, std::string>>& key_value_pairs, |
198 const StatusCallback& callback); | 194 const StatusCallback& callback); |
199 // Responds OK if all are successfully deleted or not found in the database. | 195 // Responds OK if all are successfully deleted or not found in the database. |
200 void ClearUserData(int64_t registration_id, | 196 void ClearUserData(int64_t registration_id, |
201 const std::vector<std::string>& keys, | 197 const std::vector<std::string>& keys, |
202 const StatusCallback& callback); | 198 const StatusCallback& callback); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 ServiceWorkerDatabase* database, | 492 ServiceWorkerDatabase* database, |
497 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 493 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
498 int64_t registration_id, | 494 int64_t registration_id, |
499 const FindInDBCallback& callback); | 495 const FindInDBCallback& callback); |
500 static void GetUserDataInDB( | 496 static void GetUserDataInDB( |
501 ServiceWorkerDatabase* database, | 497 ServiceWorkerDatabase* database, |
502 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 498 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
503 int64_t registration_id, | 499 int64_t registration_id, |
504 const std::vector<std::string>& keys, | 500 const std::vector<std::string>& keys, |
505 const GetUserDataInDBCallback& callback); | 501 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); | |
512 static void GetUserDataForAllRegistrationsInDB( | 502 static void GetUserDataForAllRegistrationsInDB( |
513 ServiceWorkerDatabase* database, | 503 ServiceWorkerDatabase* database, |
514 scoped_refptr<base::SequencedTaskRunner> original_task_runner, | 504 scoped_refptr<base::SequencedTaskRunner> original_task_runner, |
515 const std::string& key, | 505 const std::string& key, |
516 const GetUserDataForAllRegistrationsInDBCallback& callback); | 506 const GetUserDataForAllRegistrationsInDBCallback& callback); |
517 static void DeleteAllDataForOriginsFromDB( | 507 static void DeleteAllDataForOriginsFromDB( |
518 ServiceWorkerDatabase* database, | 508 ServiceWorkerDatabase* database, |
519 const std::set<GURL>& origins); | 509 const std::set<GURL>& origins); |
520 | 510 |
521 bool IsDisabled() const; | 511 bool IsDisabled() const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 std::set<int64_t> pending_deletions_; | 561 std::set<int64_t> pending_deletions_; |
572 | 562 |
573 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; | 563 base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; |
574 | 564 |
575 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); | 565 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStorage); |
576 }; | 566 }; |
577 | 567 |
578 } // namespace content | 568 } // namespace content |
579 | 569 |
580 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ | 570 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ |
OLD | NEW |