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