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

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

Issue 10378066: SessionStorageDatabase: Allow writing data into a shallow copy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 7 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 | « no previous file | webkit/dom_storage/session_storage_database.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_SESSION_STORAGE_DATABASE_H_ 5 #ifndef WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
6 #define WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 6 #define WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 // assumed to be empty and any duplicate keys will be overwritten. If the 37 // assumed to be empty and any duplicate keys will be overwritten. If the
38 // database exists on disk then it will be opened. If it does not exist then 38 // database exists on disk then it will be opened. If it does not exist then
39 // it will not be created and |result| will be unmodified. 39 // it will not be created and |result| will be unmodified.
40 void ReadAreaValues(int64 namespace_id, 40 void ReadAreaValues(int64 namespace_id,
41 const GURL& origin, 41 const GURL& origin,
42 ValuesMap* result); 42 ValuesMap* result);
43 43
44 // Updates the data for |namespace_id| and |origin|. Will remove all keys 44 // Updates the data for |namespace_id| and |origin|. Will remove all keys
45 // before updating the database if |clear_all_first| is set. Then all entries 45 // before updating the database if |clear_all_first| is set. Then all entries
46 // in |changes| will be examined - keys mapped to a null NullableString16 will 46 // in |changes| will be examined - keys mapped to a null NullableString16 will
47 // be removed and all others will be inserted/updated as appropriate. 47 // be removed and all others will be inserted/updated as appropriate. It is
48 // allowed to write data into a shallow copy created by CloneNamespace, and in
49 // that case the copy will be made deep before writing the values.
48 bool CommitAreaChanges(int64 namespace_id, 50 bool CommitAreaChanges(int64 namespace_id,
49 const GURL& origin, 51 const GURL& origin,
50 bool clear_all_first, 52 bool clear_all_first,
51 const ValuesMap& changes); 53 const ValuesMap& changes);
52 54
53 // Creates shallow copies of the areas for |namespace_id| and associates them 55 // Creates shallow copies of the areas for |namespace_id| and associates them
54 // with |new_namespace_id|. 56 // with |new_namespace_id|.
55 bool CloneNamespace(int64 namespace_id, int64 new_namespace_id); 57 bool CloneNamespace(int64 namespace_id, int64 new_namespace_id);
56 58
57 // Creates a deep copy of the area for |namespace_id| and |origin|.
58 bool DeepCopyArea(int64 namespace_id, const GURL& origin);
59
60 // Deletes the data for |namespace_id| and |origin|. 59 // Deletes the data for |namespace_id| and |origin|.
61 bool DeleteArea(int64 namespace_id, const GURL& origin); 60 bool DeleteArea(int64 namespace_id, const GURL& origin);
62 61
63 // Deletes the data for |namespace_id|. 62 // Deletes the data for |namespace_id|.
64 bool DeleteNamespace(int64 namespace_id); 63 bool DeleteNamespace(int64 namespace_id);
65 64
66 private: 65 private:
67 friend class base::RefCountedThreadSafe<SessionStorageDatabase>; 66 friend class base::RefCountedThreadSafe<SessionStorageDatabase>;
68 friend class SessionStorageDatabaseTest; 67 friend class SessionStorageDatabaseTest;
69 68
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 leveldb::WriteBatch* batch); 150 leveldb::WriteBatch* batch);
152 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0, 151 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0,
153 // deletes the map. 152 // deletes the map.
154 bool DecreaseMapRefCount(const std::string& map_id, 153 bool DecreaseMapRefCount(const std::string& map_id,
155 int decrease, 154 int decrease,
156 leveldb::WriteBatch* batch); 155 leveldb::WriteBatch* batch);
157 156
158 // Deletes all values in |map_id|. 157 // Deletes all values in |map_id|.
159 bool ClearMap(const std::string& map_id, leveldb::WriteBatch* batch); 158 bool ClearMap(const std::string& map_id, leveldb::WriteBatch* batch);
160 159
160 // Breaks the association between (|namespace_id|, |origin|) and |map_id| and
161 // creates a new map for (|namespace_id|, |origin|). Copies the data from the
162 // old map if |copy_data| is true.
163 bool DeepCopyArea(int64 namespace_id,
164 const GURL& origin,
165 bool copy_data,
166 std::string* map_id,
167 leveldb::WriteBatch* batch);
168
161 // Helper functions for creating the keys needed for the schema. 169 // Helper functions for creating the keys needed for the schema.
162 static std::string NamespaceStartKey(const std::string& namespace_id_str); 170 static std::string NamespaceStartKey(const std::string& namespace_id_str);
163 static std::string NamespaceStartKey(int64 namespace_id, 171 static std::string NamespaceStartKey(int64 namespace_id,
164 int64 namespace_offset); 172 int64 namespace_offset);
165 static std::string NamespaceKey(const std::string& namespace_id_str, 173 static std::string NamespaceKey(const std::string& namespace_id_str,
166 const std::string& origin); 174 const std::string& origin);
167 static std::string NamespaceKey(int64 namespace_id, 175 static std::string NamespaceKey(int64 namespace_id,
168 int64 namespace_offset, 176 int64 namespace_offset,
169 const GURL& origin); 177 const GURL& origin);
170 static std::string NamespaceIdStr(int64 namespace_id, int64 namespace_offset); 178 static std::string NamespaceIdStr(int64 namespace_id, int64 namespace_offset);
(...skipping 22 matching lines...) Expand all
193 // the offset yet. The namespaces ids which are handled as strings (named 201 // the offset yet. The namespaces ids which are handled as strings (named
194 // namesapce_id_str) contain the offset. 202 // namesapce_id_str) contain the offset.
195 int64 namespace_offset_; 203 int64 namespace_offset_;
196 204
197 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); 205 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase);
198 }; 206 };
199 207
200 } // namespace dom_storage 208 } // namespace dom_storage
201 209
202 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 210 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/dom_storage/session_storage_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698