Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: content/browser/dom_storage/dom_storage_context_impl.h

Issue 1906243002: [tracing] Add a memory dump provider for DOM storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dcheck and return value. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/atomic_sequence_num.h" 15 #include "base/atomic_sequence_num.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "base/trace_event/memory_dump_provider.h"
21 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 namespace base { 25 namespace base {
25 class FilePath; 26 class FilePath;
26 class NullableString16; 27 class NullableString16;
27 class Time; 28 class Time;
28 } 29 }
29 30
30 namespace storage { 31 namespace storage {
(...skipping 23 matching lines...) Expand all
54 // Sessions (per-tab) cause the creation and deletion of session Namespaces. 55 // Sessions (per-tab) cause the creation and deletion of session Namespaces.
55 // 56 //
56 // Session Namespaces are cloned by initially making a shallow copy of 57 // Session Namespaces are cloned by initially making a shallow copy of
57 // all contained Areas, the shallow copies refer to the same refcounted Map, 58 // all contained Areas, the shallow copies refer to the same refcounted Map,
58 // and does a deep copy-on-write if needed. 59 // and does a deep copy-on-write if needed.
59 // 60 //
60 // Classes intended to be used by an embedder are DOMStorageContextImpl, 61 // Classes intended to be used by an embedder are DOMStorageContextImpl,
61 // DOMStorageHost, and DOMStorageSession. The other classes are for 62 // DOMStorageHost, and DOMStorageSession. The other classes are for
62 // internal consumption. 63 // internal consumption.
63 class CONTENT_EXPORT DOMStorageContextImpl 64 class CONTENT_EXPORT DOMStorageContextImpl
64 : public base::RefCountedThreadSafe<DOMStorageContextImpl> { 65 : public base::RefCountedThreadSafe<DOMStorageContextImpl>,
66 public base::trace_event::MemoryDumpProvider {
65 public: 67 public:
66 // An interface for observing Local and Session Storage events on the 68 // An interface for observing Local and Session Storage events on the
67 // background thread. 69 // background thread.
68 class EventObserver { 70 class EventObserver {
69 public: 71 public:
70 // |old_value| may be null on initial insert. 72 // |old_value| may be null on initial insert.
71 virtual void OnDOMStorageItemSet( 73 virtual void OnDOMStorageItemSet(
72 const DOMStorageArea* area, 74 const DOMStorageArea* area,
73 const base::string16& key, 75 const base::string16& key,
74 const base::string16& new_value, 76 const base::string16& new_value,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 168
167 // Starts backing sessionStorage on disk. This function must be called right 169 // Starts backing sessionStorage on disk. This function must be called right
168 // after DOMStorageContextImpl is created, before it's used. 170 // after DOMStorageContextImpl is created, before it's used.
169 void SetSaveSessionStorageOnDisk(); 171 void SetSaveSessionStorageOnDisk();
170 172
171 // Deletes all namespaces which don't have an associated DOMStorageNamespace 173 // Deletes all namespaces which don't have an associated DOMStorageNamespace
172 // alive. This function is used for deleting possible leftover data after an 174 // alive. This function is used for deleting possible leftover data after an
173 // unclean exit. 175 // unclean exit.
174 void StartScavengingUnusedSessionStorage(); 176 void StartScavengingUnusedSessionStorage();
175 177
178 // base::trace_event::MemoryDumpProvider implementation.
179 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
180 base::trace_event::ProcessMemoryDump* pmd) override;
181
176 private: 182 private:
177 friend class DOMStorageContextImplTest; 183 friend class DOMStorageContextImplTest;
178 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics); 184 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics);
179 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; 185 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>;
180 typedef std::map<int64_t, scoped_refptr<DOMStorageNamespace>> 186 typedef std::map<int64_t, scoped_refptr<DOMStorageNamespace>>
181 StorageNamespaceMap; 187 StorageNamespaceMap;
182 188
183 ~DOMStorageContextImpl(); 189 ~DOMStorageContextImpl() override;
184 190
185 void ClearSessionOnlyOrigins(); 191 void ClearSessionOnlyOrigins();
186 192
187 // For scavenging unused sessionStorages. 193 // For scavenging unused sessionStorages.
188 void FindUnusedNamespaces(); 194 void FindUnusedNamespaces();
189 void FindUnusedNamespacesInCommitSequence( 195 void FindUnusedNamespacesInCommitSequence(
190 const std::set<std::string>& namespace_ids_in_use, 196 const std::set<std::string>& namespace_ids_in_use,
191 const std::set<std::string>& protected_persistent_session_ids); 197 const std::set<std::string>& protected_persistent_session_ids);
192 void DeleteNextUnusedNamespace(); 198 void DeleteNextUnusedNamespace();
193 void DeleteNextUnusedNamespaceInCommitSequence(); 199 void DeleteNextUnusedNamespaceInCommitSequence();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 std::set<std::string> protected_persistent_session_ids_; 236 std::set<std::string> protected_persistent_session_ids_;
231 237
232 // Mapping between persistent namespace IDs and namespace IDs for 238 // Mapping between persistent namespace IDs and namespace IDs for
233 // sessionStorage. 239 // sessionStorage.
234 std::map<std::string, int64_t> persistent_namespace_id_to_namespace_id_; 240 std::map<std::string, int64_t> persistent_namespace_id_to_namespace_id_;
235 }; 241 };
236 242
237 } // namespace content 243 } // namespace content
238 244
239 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ 245 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_area.cc ('k') | content/browser/dom_storage/dom_storage_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698