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

Side by Side Diff: content/browser/dom_storage/dom_storage_namespace.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: nits. Created 4 years, 8 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 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_NAMESPACE_H_ 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/trace_event/memory_dump_provider.h"
15 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 class DOMStorageArea; 21 class DOMStorageArea;
21 class DOMStorageTaskRunner; 22 class DOMStorageTaskRunner;
22 class SessionStorageDatabase; 23 class SessionStorageDatabase;
23 24
24 // Container for the set of per-origin Areas. 25 // Container for the set of per-origin Areas.
25 // See class comments for DOMStorageContextImpl for a larger overview. 26 // See class comments for DOMStorageContextImpl for a larger overview.
26 class CONTENT_EXPORT DOMStorageNamespace 27 class CONTENT_EXPORT DOMStorageNamespace
27 : public base::RefCountedThreadSafe<DOMStorageNamespace> { 28 : public base::RefCountedThreadSafe<DOMStorageNamespace>,
29 public base::trace_event::MemoryDumpProvider {
28 public: 30 public:
29 // Option for PurgeMemory. 31 // Option for PurgeMemory.
30 enum PurgeOption { 32 enum PurgeOption {
31 // Purge unopened areas only. 33 // Purge unopened areas only.
32 PURGE_UNOPENED, 34 PURGE_UNOPENED,
33 35
34 // Purge aggressively, i.e. discard cache even for areas that have 36 // Purge aggressively, i.e. discard cache even for areas that have
35 // non-zero open count. 37 // non-zero open count.
36 PURGE_AGGRESSIVE, 38 PURGE_AGGRESSIVE,
37 }; 39 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& clone_persistent_namespace_id); 71 const std::string& clone_persistent_namespace_id);
70 72
71 void DeleteLocalStorageOrigin(const GURL& origin); 73 void DeleteLocalStorageOrigin(const GURL& origin);
72 void DeleteSessionStorageOrigin(const GURL& origin); 74 void DeleteSessionStorageOrigin(const GURL& origin);
73 void PurgeMemory(PurgeOption purge); 75 void PurgeMemory(PurgeOption purge);
74 void Shutdown(); 76 void Shutdown();
75 void Flush(); 77 void Flush();
76 78
77 unsigned int CountInMemoryAreas() const; 79 unsigned int CountInMemoryAreas() const;
78 80
81 // base::trace_event::MemoryDumpProvider implementation.
82 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
83 base::trace_event::ProcessMemoryDump* pmd) override;
84
79 private: 85 private:
80 friend class base::RefCountedThreadSafe<DOMStorageNamespace>; 86 friend class base::RefCountedThreadSafe<DOMStorageNamespace>;
81 87
82 // Struct to hold references to our contained areas and 88 // Struct to hold references to our contained areas and
83 // to keep track of how many tabs have a given area open. 89 // to keep track of how many tabs have a given area open.
84 struct AreaHolder { 90 struct AreaHolder {
85 scoped_refptr<DOMStorageArea> area_; 91 scoped_refptr<DOMStorageArea> area_;
86 int open_count_; 92 int open_count_;
87 AreaHolder(); 93 AreaHolder();
88 AreaHolder(DOMStorageArea* area, int count); 94 AreaHolder(DOMStorageArea* area, int count);
89 AreaHolder(const AreaHolder& other); 95 AreaHolder(const AreaHolder& other);
90 ~AreaHolder(); 96 ~AreaHolder();
91 }; 97 };
92 typedef std::map<GURL, AreaHolder> AreaMap; 98 typedef std::map<GURL, AreaHolder> AreaMap;
93 99
94 ~DOMStorageNamespace(); 100 ~DOMStorageNamespace() override;
95 101
96 // Returns a pointer to the area holder in our map or NULL. 102 // Returns a pointer to the area holder in our map or NULL.
97 AreaHolder* GetAreaHolder(const GURL& origin); 103 AreaHolder* GetAreaHolder(const GURL& origin);
98 104
99 int64_t namespace_id_; 105 int64_t namespace_id_;
100 std::string persistent_namespace_id_; 106 std::string persistent_namespace_id_;
101 base::FilePath directory_; 107 base::FilePath directory_;
102 AreaMap areas_; 108 AreaMap areas_;
103 scoped_refptr<DOMStorageTaskRunner> task_runner_; 109 scoped_refptr<DOMStorageTaskRunner> task_runner_;
104 scoped_refptr<SessionStorageDatabase> session_storage_database_; 110 scoped_refptr<SessionStorageDatabase> session_storage_database_;
105 }; 111 };
106 112
107 } // namespace content 113 } // namespace content
108 114
109 115
110 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ 116 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698