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

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

Issue 22297005: Move webkit/{browser,common}/dom_storage into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
6 #define WEBKIT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "content/common/content_export.h"
16 #include "content/common/dom_storage/dom_storage_types.h"
15 #include "third_party/leveldatabase/src/include/leveldb/status.h" 17 #include "third_party/leveldatabase/src/include/leveldb/status.h"
16 #include "webkit/browser/webkit_storage_browser_export.h"
17 #include "webkit/common/dom_storage/dom_storage_types.h"
18 18
19 class GURL; 19 class GURL;
20 20
21 namespace leveldb { 21 namespace leveldb {
22 class DB; 22 class DB;
23 struct ReadOptions; 23 struct ReadOptions;
24 class WriteBatch; 24 class WriteBatch;
25 } // namespace leveldb 25 } // namespace leveldb
26 26
27 namespace dom_storage { 27 namespace content {
28 28
29 // SessionStorageDatabase holds the data from multiple namespaces and multiple 29 // SessionStorageDatabase holds the data from multiple namespaces and multiple
30 // origins. All DomStorageAreas for session storage share the same 30 // origins. All DOMStorageAreas for session storage share the same
31 // SessionStorageDatabase. 31 // SessionStorageDatabase.
32 32
33 // Only one thread is allowed to call the public functions other than 33 // Only one thread is allowed to call the public functions other than
34 // ReadAreaValues and ReadNamespacesAndOrigins. Other threads are allowed to 34 // ReadAreaValues and ReadNamespacesAndOrigins. Other threads are allowed to
35 // call ReadAreaValues and ReadNamespacesAndOrigins. 35 // call ReadAreaValues and ReadNamespacesAndOrigins.
36 class WEBKIT_STORAGE_BROWSER_EXPORT SessionStorageDatabase : 36 class CONTENT_EXPORT SessionStorageDatabase :
37 public base::RefCountedThreadSafe<SessionStorageDatabase> { 37 public base::RefCountedThreadSafe<SessionStorageDatabase> {
38 public: 38 public:
39 explicit SessionStorageDatabase(const base::FilePath& file_path); 39 explicit SessionStorageDatabase(const base::FilePath& file_path);
40 40
41 // Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is 41 // Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is
42 // assumed to be empty and any duplicate keys will be overwritten. If the 42 // assumed to be empty and any duplicate keys will be overwritten. If the
43 // database exists on disk then it will be opened. If it does not exist then 43 // database exists on disk then it will be opened. If it does not exist then
44 // it will not be created and |result| will be unmodified. 44 // it will not be created and |result| will be unmodified.
45 void ReadAreaValues(const std::string& namespace_id, 45 void ReadAreaValues(const std::string& namespace_id,
46 const GURL& origin, 46 const GURL& origin,
47 ValuesMap* result); 47 DOMStorageValuesMap* result);
48 48
49 // Updates the data for |namespace_id| and |origin|. Will remove all keys 49 // Updates the data for |namespace_id| and |origin|. Will remove all keys
50 // before updating the database if |clear_all_first| is set. Then all entries 50 // before updating the database if |clear_all_first| is set. Then all entries
51 // in |changes| will be examined - keys mapped to a null NullableString16 will 51 // in |changes| will be examined - keys mapped to a null NullableString16 will
52 // be removed and all others will be inserted/updated as appropriate. It is 52 // be removed and all others will be inserted/updated as appropriate. It is
53 // allowed to write data into a shallow copy created by CloneNamespace, and in 53 // allowed to write data into a shallow copy created by CloneNamespace, and in
54 // that case the copy will be made deep before writing the values. 54 // that case the copy will be made deep before writing the values.
55 bool CommitAreaChanges(const std::string& namespace_id, 55 bool CommitAreaChanges(const std::string& namespace_id,
56 const GURL& origin, 56 const GURL& origin,
57 bool clear_all_first, 57 bool clear_all_first,
58 const ValuesMap& changes); 58 const DOMStorageValuesMap& changes);
59 59
60 // Creates shallow copies of the areas for |namespace_id| and associates them 60 // Creates shallow copies of the areas for |namespace_id| and associates them
61 // with |new_namespace_id|. 61 // with |new_namespace_id|.
62 bool CloneNamespace(const std::string& namespace_id, 62 bool CloneNamespace(const std::string& namespace_id,
63 const std::string& new_namespace_id); 63 const std::string& new_namespace_id);
64 64
65 // Deletes the data for |namespace_id| and |origin|. 65 // Deletes the data for |namespace_id| and |origin|.
66 bool DeleteArea(const std::string& namespace_id, const GURL& origin); 66 bool DeleteArea(const std::string& namespace_id, const GURL& origin);
67 67
68 // Deletes the data for |namespace_id|. 68 // Deletes the data for |namespace_id|.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // the ref count. 142 // the ref count.
143 bool CreateMapForArea(const std::string& namespace_id, 143 bool CreateMapForArea(const std::string& namespace_id,
144 const GURL& origin, 144 const GURL& origin,
145 std::string* map_id, 145 std::string* map_id,
146 leveldb::WriteBatch* batch); 146 leveldb::WriteBatch* batch);
147 // Reads the contents of the map |map_id| into |result|. If |only_keys| is 147 // Reads the contents of the map |map_id| into |result|. If |only_keys| is
148 // true, only keys are aread from the database and the values in |result| will 148 // true, only keys are aread from the database and the values in |result| will
149 // be empty. 149 // be empty.
150 bool ReadMap(const std::string& map_id, 150 bool ReadMap(const std::string& map_id,
151 const leveldb::ReadOptions& options, 151 const leveldb::ReadOptions& options,
152 ValuesMap* result, 152 DOMStorageValuesMap* result,
153 bool only_keys); 153 bool only_keys);
154 // Writes |values| into the map |map_id|. 154 // Writes |values| into the map |map_id|.
155 void WriteValuesToMap(const std::string& map_id, 155 void WriteValuesToMap(const std::string& map_id,
156 const ValuesMap& values, 156 const DOMStorageValuesMap& values,
157 leveldb::WriteBatch* batch); 157 leveldb::WriteBatch* batch);
158 158
159 bool GetMapRefCount(const std::string& map_id, int64* ref_count); 159 bool GetMapRefCount(const std::string& map_id, int64* ref_count);
160 bool IncreaseMapRefCount(const std::string& map_id, 160 bool IncreaseMapRefCount(const std::string& map_id,
161 leveldb::WriteBatch* batch); 161 leveldb::WriteBatch* batch);
162 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0, 162 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0,
163 // deletes the map. 163 // deletes the map.
164 bool DecreaseMapRefCount(const std::string& map_id, 164 bool DecreaseMapRefCount(const std::string& map_id,
165 int decrease, 165 int decrease,
166 leveldb::WriteBatch* batch); 166 leveldb::WriteBatch* batch);
(...skipping 26 matching lines...) Expand all
193 base::Lock db_lock_; 193 base::Lock db_lock_;
194 194
195 // True if a database error has occurred (e.g., cannot read data). 195 // True if a database error has occurred (e.g., cannot read data).
196 bool db_error_; 196 bool db_error_;
197 // True if the database is in an inconsistent state. 197 // True if the database is in an inconsistent state.
198 bool is_inconsistent_; 198 bool is_inconsistent_;
199 199
200 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); 200 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase);
201 }; 201 };
202 202
203 } // namespace dom_storage 203 } // namespace content
204 204
205 #endif // WEBKIT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 205 #endif // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/local_storage_database_adapter.cc ('k') | content/browser/dom_storage/session_storage_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698