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_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/public/browser/dom_storage_context.h" | 9 #include "content/public/browser/dom_storage_context.h" |
10 | 10 |
11 class FilePath; | 11 class FilePath; |
12 | 12 |
13 namespace quota { | 13 namespace quota { |
14 class SpecialStoragePolicy; | 14 class SpecialStoragePolicy; |
15 } | 15 } |
16 | 16 |
| 17 namespace content { |
| 18 |
17 // This is owned by BrowserContext (aka Profile) and encapsulates all | 19 // This is owned by BrowserContext (aka Profile) and encapsulates all |
18 // per-profile dom storage state. | 20 // per-profile dom storage state. |
19 class CONTENT_EXPORT DOMStorageContextImpl : | 21 class CONTENT_EXPORT DOMStorageContextImpl : |
20 NON_EXPORTED_BASE(public content::DOMStorageContext), | 22 NON_EXPORTED_BASE(public DOMStorageContext), |
21 public base::RefCountedThreadSafe<DOMStorageContextImpl> { | 23 public base::RefCountedThreadSafe<DOMStorageContextImpl> { |
22 public: | 24 public: |
23 // If |data_path| is empty, nothing will be saved to disk. | 25 // If |data_path| is empty, nothing will be saved to disk. |
24 DOMStorageContextImpl(const FilePath& data_path, | 26 DOMStorageContextImpl(const FilePath& data_path, |
25 quota::SpecialStoragePolicy* special_storage_policy); | 27 quota::SpecialStoragePolicy* special_storage_policy); |
26 | 28 |
27 // DOMStorageContext implementation. | 29 // DOMStorageContext implementation. |
28 virtual void GetLocalStorageUsage( | 30 virtual void GetLocalStorageUsage( |
29 const GetLocalStorageUsageCallback& callback) OVERRIDE; | 31 const GetLocalStorageUsageCallback& callback) OVERRIDE; |
30 virtual void GetSessionStorageUsage( | 32 virtual void GetSessionStorageUsage( |
31 const GetSessionStorageUsageCallback& callback) OVERRIDE; | 33 const GetSessionStorageUsageCallback& callback) OVERRIDE; |
32 virtual void DeleteLocalStorage(const GURL& origin) OVERRIDE; | 34 virtual void DeleteLocalStorage(const GURL& origin) OVERRIDE; |
33 virtual void DeleteSessionStorage( | 35 virtual void DeleteSessionStorage( |
34 const dom_storage::DomStorageContext::SessionStorageUsageInfo& usage_info) | 36 const dom_storage::DomStorageContext::SessionStorageUsageInfo& usage_info) |
35 OVERRIDE; | 37 OVERRIDE; |
36 virtual void SetSaveSessionStorageOnDisk() OVERRIDE; | 38 virtual void SetSaveSessionStorageOnDisk() OVERRIDE; |
37 virtual scoped_refptr<content::SessionStorageNamespace> | 39 virtual scoped_refptr<SessionStorageNamespace> |
38 RecreateSessionStorage(const std::string& persistent_id) OVERRIDE; | 40 RecreateSessionStorage(const std::string& persistent_id) OVERRIDE; |
39 virtual void StartScavengingUnusedSessionStorage() OVERRIDE; | 41 virtual void StartScavengingUnusedSessionStorage() OVERRIDE; |
40 | 42 |
41 // Called to free up memory that's not strictly needed. | 43 // Called to free up memory that's not strictly needed. |
42 void PurgeMemory(); | 44 void PurgeMemory(); |
43 | 45 |
44 // Used by content settings to alter the behavior around | 46 // Used by content settings to alter the behavior around |
45 // what data to keep and what data to discard at shutdown. | 47 // what data to keep and what data to discard at shutdown. |
46 // The policy is not so straight forward to describe, see | 48 // The policy is not so straight forward to describe, see |
47 // the implementation for details. | 49 // the implementation for details. |
48 void SetForceKeepSessionState(); | 50 void SetForceKeepSessionState(); |
49 | 51 |
50 // Called when the BrowserContext/Profile is going away. | 52 // Called when the BrowserContext/Profile is going away. |
51 void Shutdown(); | 53 void Shutdown(); |
52 | 54 |
53 private: | 55 private: |
54 friend class DOMStorageMessageFilter; // for access to context() | 56 friend class DOMStorageMessageFilter; // for access to context() |
55 friend class SessionStorageNamespaceImpl; // ditto | 57 friend class SessionStorageNamespaceImpl; // ditto |
56 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; | 58 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; |
57 | 59 |
58 virtual ~DOMStorageContextImpl(); | 60 virtual ~DOMStorageContextImpl(); |
59 dom_storage::DomStorageContext* context() const { return context_.get(); } | 61 dom_storage::DomStorageContext* context() const { return context_.get(); } |
60 | 62 |
61 scoped_refptr<dom_storage::DomStorageContext> context_; | 63 scoped_refptr<dom_storage::DomStorageContext> context_; |
62 | 64 |
63 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl); | 65 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl); |
64 }; | 66 }; |
65 | 67 |
| 68 } // namespace content |
| 69 |
66 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 70 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
OLD | NEW |