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

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

Issue 9726022: Revert 127573 - DOMStorageContextImpl that's implemented in terms of the new dom_storage classes. A… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CONTEXT_H_ 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <vector>
11 10
12 #include "base/atomic_sequence_num.h" 11 #include "base/atomic_sequence_num.h"
13 #include "base/basictypes.h" 12 #include "base/basictypes.h"
14 #include "base/file_path.h" 13 #include "base/file_path.h"
15 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
16 #include "base/observer_list.h" 15 #include "base/observer_list.h"
17 #include "googleurl/src/gurl.h"
18 16
19 class FilePath; 17 class FilePath;
18 class GURL;
20 class NullableString16; 19 class NullableString16;
21 20
22 namespace base { 21 namespace base {
23 class Time; 22 class Time;
24 } 23 }
25 24
26 namespace quota { 25 namespace quota {
27 class SpecialStoragePolicy; 26 class SpecialStoragePolicy;
28 } 27 }
29 28
(...skipping 19 matching lines...) Expand all
49 // Session Namespaces are cloned by initially making a shallow copy of 48 // Session Namespaces are cloned by initially making a shallow copy of
50 // all contained Areas, the shallow copies refer to the same refcounted Map, 49 // all contained Areas, the shallow copies refer to the same refcounted Map,
51 // and does a deep copy-on-write if needed. 50 // and does a deep copy-on-write if needed.
52 // 51 //
53 // Classes intended to be used by an embedder are DomStorageContext, 52 // Classes intended to be used by an embedder are DomStorageContext,
54 // DomStorageHost, and DomStorageSession. The other classes are for 53 // DomStorageHost, and DomStorageSession. The other classes are for
55 // internal consumption. 54 // internal consumption.
56 class DomStorageContext 55 class DomStorageContext
57 : public base::RefCountedThreadSafe<DomStorageContext> { 56 : public base::RefCountedThreadSafe<DomStorageContext> {
58 public: 57 public:
59 struct UsageInfo {
60 GURL origin;
61 size_t data_size;
62 base::Time last_modified;
63
64 UsageInfo();
65 ~UsageInfo();
66 };
67
68 // An interface for observing LocalStorage events on the 58 // An interface for observing LocalStorage events on the
69 // background thread. 59 // background thread.
70 class EventObserver { 60 class EventObserver {
71 public: 61 public:
72 virtual void OnDomStorageItemSet( 62 virtual void OnDomStorageItemSet(
73 const DomStorageArea* area, 63 const DomStorageArea* area,
74 const string16& key, 64 const string16& key,
75 const string16& new_value, 65 const string16& new_value,
76 const NullableString16& old_value, // may be null on initial insert 66 const NullableString16& old_value, // may be null on initial insert
77 const GURL& page_url) = 0; 67 const GURL& page_url) = 0;
78 virtual void OnDomStorageItemRemoved( 68 virtual void OnDomStorageItemRemoved(
79 const DomStorageArea* area, 69 const DomStorageArea* area,
80 const string16& key, 70 const string16& key,
81 const string16& old_value, 71 const string16& old_value,
82 const GURL& page_url) = 0; 72 const GURL& page_url) = 0;
83 virtual void OnDomStorageAreaCleared( 73 virtual void OnDomStorageAreaCleared(
84 const DomStorageArea* area, 74 const DomStorageArea* area,
85 const GURL& page_url) = 0; 75 const GURL& page_url) = 0;
86 virtual ~EventObserver() {} 76 virtual ~EventObserver() {}
87 }; 77 };
88 78
89 DomStorageContext(const FilePath& directory, // empty for incognito profiles 79 DomStorageContext(const FilePath& directory, // empty for incognito profiles
90 quota::SpecialStoragePolicy* special_storage_policy, 80 quota::SpecialStoragePolicy* special_storage_policy,
91 DomStorageTaskRunner* task_runner); 81 DomStorageTaskRunner* task_runner);
92 const FilePath& directory() const { return directory_; }
93 DomStorageTaskRunner* task_runner() const { return task_runner_; } 82 DomStorageTaskRunner* task_runner() const { return task_runner_; }
94 DomStorageNamespace* GetStorageNamespace(int64 namespace_id); 83 DomStorageNamespace* GetStorageNamespace(int64 namespace_id);
95 84
96 void GetUsageInfo(std::vector<UsageInfo>* info);
97 void DeleteOrigin(const GURL& origin);
98 void DeleteDataModifiedSince(const base::Time& cutoff);
99 void PurgeMemory();
100
101 // Used by content settings to alter the behavior around
102 // what data to keep and what data to discard at shutdown.
103 // The policy is not so straight forward to describe, see
104 // the implementation for details.
105 void SetClearLocalState(bool clear_local_state) {
106 clear_local_state_ = clear_local_state;
107 }
108 void SaveSessionState() {
109 save_session_state_ = true;
110 }
111
112 // Called when the BrowserContext/Profile is going away.
113 void Shutdown();
114
115 // Methods to add, remove, and notify EventObservers. 85 // Methods to add, remove, and notify EventObservers.
116 void AddEventObserver(EventObserver* observer); 86 void AddEventObserver(EventObserver* observer);
117 void RemoveEventObserver(EventObserver* observer); 87 void RemoveEventObserver(EventObserver* observer);
118 void NotifyItemSet( 88 void NotifyItemSet(
119 const DomStorageArea* area, 89 const DomStorageArea* area,
120 const string16& key, 90 const string16& key,
121 const string16& new_value, 91 const string16& new_value,
122 const NullableString16& old_value, 92 const NullableString16& old_value,
123 const GURL& page_url); 93 const GURL& page_url);
124 void NotifyItemRemoved( 94 void NotifyItemRemoved(
(...skipping 19 matching lines...) Expand all
144 friend class base::RefCountedThreadSafe<DomStorageContext>; 114 friend class base::RefCountedThreadSafe<DomStorageContext>;
145 typedef std::map<int64, scoped_refptr<DomStorageNamespace> > 115 typedef std::map<int64, scoped_refptr<DomStorageNamespace> >
146 StorageNamespaceMap; 116 StorageNamespaceMap;
147 117
148 ~DomStorageContext(); 118 ~DomStorageContext();
149 119
150 // Collection of namespaces keyed by id. 120 // Collection of namespaces keyed by id.
151 StorageNamespaceMap namespaces_; 121 StorageNamespaceMap namespaces_;
152 122
153 // Where localstorage data is stored, maybe empty for the incognito use case. 123 // Where localstorage data is stored, maybe empty for the incognito use case.
154 const FilePath directory_; 124 FilePath directory_;
155 125
156 // Used to schedule sequenced background tasks. 126 // Used to schedule sequenced background tasks.
157 scoped_refptr<DomStorageTaskRunner> task_runner_; 127 scoped_refptr<DomStorageTaskRunner> task_runner_;
158 128
159 // List of objects observing local storage events. 129 // List of objects observing local storage events.
160 ObserverList<EventObserver> event_observers_; 130 ObserverList<EventObserver> event_observers_;
161 131
162 // We use a 32 bit identifier for per tab storage sessions. 132 // We use a 32 bit identifier for per tab storage sessions.
163 // At a tab per second, this range is large enough for 68 years. 133 // At a tab per second, this range is large enough for 68 years.
164 base::AtomicSequenceNumber session_id_sequence_; 134 base::AtomicSequenceNumber session_id_sequence_;
165
166 bool clear_local_state_;
167 bool save_session_state_;
168 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
169 }; 135 };
170 136
171 } // namespace dom_storage 137 } // namespace dom_storage
172 138
173 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ 139 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698