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

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

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