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

Side by Side Diff: webkit/dom_storage/dom_storage_cached_area.h

Issue 10799008: Web Inspector: count DOM storage cache memory for native snapshot (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/nullable_string16.h" 12 #include "base/nullable_string16.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 14
15 namespace dom_storage { 15 namespace dom_storage {
16 16
17 class DomStorageMap; 17 class DomStorageMap;
18 class DomStorageProxy; 18 class DomStorageProxy;
19 19
20 // Unlike the other classes in the dom_storage library, this one is intended 20 // Unlike the other classes in the dom_storage library, this one is intended
21 // for use in renderer processes. It maintains a complete cach of the an 21 // for use in renderer processes. It maintains a complete cache of the
22 // origin's Map of key/value pairs for fast access. The cache is primed on 22 // origin's Map of key/value pairs for fast access. The cache is primed on
23 // first access and changes are written to the backend thru the |proxy|. 23 // first access and changes are written to the backend thru the |proxy|.
24 // Mutations originating in other processes are applied to the cache via 24 // Mutations originating in other processes are applied to the cache via
25 // the ApplyMutation method. 25 // the ApplyMutation method.
26 class DomStorageCachedArea : public base::RefCounted<DomStorageCachedArea> { 26 class DomStorageCachedArea : public base::RefCounted<DomStorageCachedArea> {
27 public: 27 public:
28 DomStorageCachedArea(int64 namespace_id, const GURL& origin, 28 DomStorageCachedArea(int64 namespace_id, const GURL& origin,
29 DomStorageProxy* proxy); 29 DomStorageProxy* proxy);
30 30
31 int64 namespace_id() const { return namespace_id_; } 31 int64 namespace_id() const { return namespace_id_; }
32 const GURL& origin() const { return origin_; } 32 const GURL& origin() const { return origin_; }
33 33
34 unsigned GetLength(int connection_id); 34 unsigned GetLength(int connection_id);
35 NullableString16 GetKey(int connection_id, unsigned index); 35 NullableString16 GetKey(int connection_id, unsigned index);
36 NullableString16 GetItem(int connection_id, const string16& key); 36 NullableString16 GetItem(int connection_id, const string16& key);
37 bool SetItem(int connection_id, const string16& key, const string16& value, 37 bool SetItem(int connection_id, const string16& key, const string16& value,
38 const GURL& page_url); 38 const GURL& page_url);
39 void RemoveItem(int connection_id, const string16& key, 39 void RemoveItem(int connection_id, const string16& key,
40 const GURL& page_url); 40 const GURL& page_url);
41 void Clear(int connection_id, const GURL& page_url); 41 void Clear(int connection_id, const GURL& page_url);
42 42
43 void ApplyMutation(const NullableString16& key, 43 void ApplyMutation(const NullableString16& key,
44 const NullableString16& new_value); 44 const NullableString16& new_value);
45 45
46 size_t MemoryBytesUsedByCache() const;
47
46 private: 48 private:
47 friend class DomStorageCachedAreaTest; 49 friend class DomStorageCachedAreaTest;
48 friend class base::RefCounted<DomStorageCachedArea>; 50 friend class base::RefCounted<DomStorageCachedArea>;
49 ~DomStorageCachedArea(); 51 ~DomStorageCachedArea();
50 52
51 // Primes the cache, loading all values for the area. 53 // Primes the cache, loading all values for the area.
52 void Prime(int connection_id); 54 void Prime(int connection_id);
53 void PrimeIfNeeded(int connection_id) { 55 void PrimeIfNeeded(int connection_id) {
54 if (!map_) 56 if (!map_)
55 Prime(connection_id); 57 Prime(connection_id);
(...skipping 21 matching lines...) Expand all
77 int64 namespace_id_; 79 int64 namespace_id_;
78 GURL origin_; 80 GURL origin_;
79 scoped_refptr<DomStorageMap> map_; 81 scoped_refptr<DomStorageMap> map_;
80 scoped_refptr<DomStorageProxy> proxy_; 82 scoped_refptr<DomStorageProxy> proxy_;
81 base::WeakPtrFactory<DomStorageCachedArea> weak_factory_; 83 base::WeakPtrFactory<DomStorageCachedArea> weak_factory_;
82 }; 84 };
83 85
84 } // namespace dom_storage 86 } // namespace dom_storage
85 87
86 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ 88 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
OLDNEW
« no previous file with comments | « content/renderer/dom_storage/webstoragearea_impl.cc ('k') | webkit/dom_storage/dom_storage_cached_area.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698