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_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/memory_coordinator_client.h" |
12 #include "base/memory/memory_pressure_listener.h" | 13 #include "base/memory/memory_pressure_listener.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
14 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
15 #include "content/common/storage_partition_service.mojom.h" | 17 #include "content/common/storage_partition_service.mojom.h" |
16 #include "content/public/browser/dom_storage_context.h" | 18 #include "content/public/browser/dom_storage_context.h" |
17 #include "url/origin.h" | 19 #include "url/origin.h" |
18 | 20 |
19 namespace base { | 21 namespace base { |
20 class FilePath; | 22 class FilePath; |
21 } | 23 } |
22 | 24 |
23 namespace shell { | 25 namespace shell { |
24 class Connector; | 26 class Connector; |
25 } | 27 } |
26 | 28 |
27 namespace storage { | 29 namespace storage { |
28 class SpecialStoragePolicy; | 30 class SpecialStoragePolicy; |
29 } | 31 } |
30 | 32 |
31 namespace content { | 33 namespace content { |
32 | 34 |
33 class DOMStorageContextImpl; | 35 class DOMStorageContextImpl; |
34 class LevelDBWrapperImpl; | 36 class LevelDBWrapperImpl; |
35 | 37 |
36 // This is owned by Storage Partition and encapsulates all its dom storage | 38 // This is owned by Storage Partition and encapsulates all its dom storage |
37 // state. | 39 // state. |
38 class CONTENT_EXPORT DOMStorageContextWrapper : | 40 class CONTENT_EXPORT DOMStorageContextWrapper : |
39 NON_EXPORTED_BASE(public DOMStorageContext), | 41 NON_EXPORTED_BASE(public DOMStorageContext), |
40 public base::RefCountedThreadSafe<DOMStorageContextWrapper> { | 42 public base::RefCountedThreadSafe<DOMStorageContextWrapper>, |
| 43 public base::MemoryCoordinatorClient { |
41 public: | 44 public: |
42 // If |data_path| is empty, nothing will be saved to disk. | 45 // If |data_path| is empty, nothing will be saved to disk. |
43 DOMStorageContextWrapper( | 46 DOMStorageContextWrapper( |
44 shell::Connector* connector, | 47 shell::Connector* connector, |
45 const base::FilePath& data_path, | 48 const base::FilePath& data_path, |
46 const base::FilePath& local_partition_path, | 49 const base::FilePath& local_partition_path, |
47 storage::SpecialStoragePolicy* special_storage_policy); | 50 storage::SpecialStoragePolicy* special_storage_policy); |
48 | 51 |
49 // DOMStorageContext implementation. | 52 // DOMStorageContext implementation. |
50 void GetLocalStorageUsage( | 53 void GetLocalStorageUsage( |
(...skipping 16 matching lines...) Loading... |
67 // Called when the BrowserContext/Profile is going away. | 70 // Called when the BrowserContext/Profile is going away. |
68 void Shutdown(); | 71 void Shutdown(); |
69 | 72 |
70 void Flush(); | 73 void Flush(); |
71 | 74 |
72 // See mojom::StoragePartitionService interface. | 75 // See mojom::StoragePartitionService interface. |
73 void OpenLocalStorage(const url::Origin& origin, | 76 void OpenLocalStorage(const url::Origin& origin, |
74 mojom::LevelDBObserverPtr observer, | 77 mojom::LevelDBObserverPtr observer, |
75 mojom::LevelDBWrapperRequest request); | 78 mojom::LevelDBWrapperRequest request); |
76 | 79 |
77 // Called on UI thread when the system is under memory pressure. | |
78 void OnMemoryPressure( | |
79 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | |
80 | |
81 private: | 80 private: |
82 friend class DOMStorageMessageFilter; // for access to context() | 81 friend class DOMStorageMessageFilter; // for access to context() |
83 friend class SessionStorageNamespaceImpl; // ditto | 82 friend class SessionStorageNamespaceImpl; // ditto |
84 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>; | 83 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>; |
85 | 84 |
86 ~DOMStorageContextWrapper() override; | 85 ~DOMStorageContextWrapper() override; |
87 DOMStorageContextImpl* context() const { return context_.get(); } | 86 DOMStorageContextImpl* context() const { return context_.get(); } |
88 | 87 |
| 88 // Called on UI thread when the system is under memory pressure. |
| 89 void OnMemoryPressure( |
| 90 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 91 |
| 92 // base::MemoryCoordinatorClient implementation: |
| 93 void OnMemoryStateChange(base::MemoryState state) override; |
| 94 |
| 95 void PurgeMemory(DOMStorageContextImpl::PurgeOption purge_option); |
| 96 |
89 // An inner class to keep all mojo-ish details together and not bleed them | 97 // An inner class to keep all mojo-ish details together and not bleed them |
90 // through the public interface. | 98 // through the public interface. |
91 class MojoState; | 99 class MojoState; |
92 std::unique_ptr<MojoState> mojo_state_; | 100 std::unique_ptr<MojoState> mojo_state_; |
93 | 101 |
94 // To receive memory pressure signals. | 102 // To receive memory pressure signals. |
95 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 103 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
96 | 104 |
97 scoped_refptr<DOMStorageContextImpl> context_; | 105 scoped_refptr<DOMStorageContextImpl> context_; |
98 | 106 |
99 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper); | 107 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper); |
100 }; | 108 }; |
101 | 109 |
102 } // namespace content | 110 } // namespace content |
103 | 111 |
104 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ | 112 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ |
OLD | NEW |