Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_ |
| 6 | #define CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/callback.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | |
| 13 | class GURL; |
| 14 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 15 | namespace content { |
| 16 | |
| 17 | class BrowserContext; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 18 | struct LocalStorageUsageInfo; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 19 | class SessionStorageNamespace; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 20 | struct SessionStorageUsageInfo; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 21 | |
| 22 | // Represents the per-BrowserContext Local Storage data. |
| 23 | class DOMStorageContext { |
| 24 | public: |
| 25 | typedef base::Callback< |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 26 | void(const std::vector<LocalStorageUsageInfo>&)> |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 27 | GetLocalStorageUsageCallback; |
| 28 | |
| 29 | typedef base::Callback< |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 30 | void(const std::vector<SessionStorageUsageInfo>&)> |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 31 | GetSessionStorageUsageCallback; |
| 32 | |
| 33 | // Returns a collection of origins using local storage to the given callback. |
| 34 | virtual void GetLocalStorageUsage( |
| 35 | const GetLocalStorageUsageCallback& callback) = 0; |
| 36 | |
| 37 | // Returns a collection of origins using session storage to the given |
| 38 | // callback. |
| 39 | virtual void GetSessionStorageUsage( |
| 40 | const GetSessionStorageUsageCallback& callback) = 0; |
| 41 | |
| 42 | // Deletes the local storage data for the given origin. |
| 43 | virtual void DeleteLocalStorage(const GURL& origin) = 0; |
| 44 | |
| 45 | // Deletes the session storage data identified by |usage_info|. |
| 46 | virtual void DeleteSessionStorage( |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 47 | const SessionStorageUsageInfo& usage_info) = 0; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 48 | |
| 49 | // If this is called, sessionStorage data will be stored on disk, and can be |
| 50 | // restored after a browser restart (with RecreateSessionStorage). This |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 51 | // function must be called right after DOMStorageContextWrapper is created, |
| 52 | // and before it's used. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 53 | virtual void SetSaveSessionStorageOnDisk() = 0; |
| 54 | |
| 55 | // Creates a SessionStorageNamespace with the given |persistent_id|. Used |
| 56 | // after tabs are restored by session restore. When created, the |
| 57 | // SessionStorageNamespace with the correct |persistent_id| will be |
| 58 | // associated with the persisted sessionStorage data. |
| 59 | virtual scoped_refptr<SessionStorageNamespace> RecreateSessionStorage( |
| 60 | const std::string& persistent_id) = 0; |
| 61 | |
| 62 | // Starts deleting sessionStorages which don't have an associated |
| 63 | // SessionStorageNamespace alive. Called when SessionStorageNamespaces have |
| 64 | // been created after a session restore, or a session restore won't happen. |
| 65 | virtual void StartScavengingUnusedSessionStorage() = 0; |
| 66 | |
| 67 | protected: |
| 68 | virtual ~DOMStorageContext() {} |
| 69 | }; |
| 70 | |
| 71 | } // namespace content |
| 72 | |
| 73 | #endif // CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_ |