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

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: 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|. 59 // Creates a deep copy of the area for |namespace_id| and |origin|.
58 bool DeepCopyArea(int64 namespace_id, const GURL& origin); 60 bool DeepCopyArea(int64 namespace_id, const GURL& origin);
michaeln 2012/05/09 21:46:48 looks like this method decl is obsolete now and sh
marja 2012/05/10 06:30:04 Done.
59 61
60 // Deletes the data for |namespace_id| and |origin|. 62 // Deletes the data for |namespace_id| and |origin|.
61 bool DeleteArea(int64 namespace_id, const GURL& origin); 63 bool DeleteArea(int64 namespace_id, const GURL& origin);
62 64
63 // Deletes the data for |namespace_id|. 65 // Deletes the data for |namespace_id|.
64 bool DeleteNamespace(int64 namespace_id); 66 bool DeleteNamespace(int64 namespace_id);
65 67
66 private: 68 private:
67 friend class base::RefCountedThreadSafe<SessionStorageDatabase>; 69 friend class base::RefCountedThreadSafe<SessionStorageDatabase>;
68 friend class SessionStorageDatabaseTest; 70 friend class SessionStorageDatabaseTest;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 leveldb::WriteBatch* batch); 153 leveldb::WriteBatch* batch);
152 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0, 154 // Decreases the ref count of a map by |decrease|. If the ref count goes to 0,
153 // deletes the map. 155 // deletes the map.
154 bool DecreaseMapRefCount(const std::string& map_id, 156 bool DecreaseMapRefCount(const std::string& map_id,
155 int decrease, 157 int decrease,
156 leveldb::WriteBatch* batch); 158 leveldb::WriteBatch* batch);
157 159
158 // Deletes all values in |map_id|. 160 // Deletes all values in |map_id|.
159 bool ClearMap(const std::string& map_id, leveldb::WriteBatch* batch); 161 bool ClearMap(const std::string& map_id, leveldb::WriteBatch* batch);
160 162
163 // Breaks the association between (|namespace_id|, |origin|) and |map_id| and
164 // creates a new map for (|namespace_id|, |origin|). Copies the data from the
165 // old map if |copy_data| is true.
166 bool DeepCopyArea(int64 namespace_id,
167 const GURL& origin,
168 bool copy_data,
169 std::string* map_id,
170 leveldb::WriteBatch* batch);
171
161 // Helper functions for creating the keys needed for the schema. 172 // Helper functions for creating the keys needed for the schema.
162 static std::string NamespaceStartKey(const std::string& namespace_id_str); 173 static std::string NamespaceStartKey(const std::string& namespace_id_str);
163 static std::string NamespaceStartKey(int64 namespace_id, 174 static std::string NamespaceStartKey(int64 namespace_id,
164 int64 namespace_offset); 175 int64 namespace_offset);
165 static std::string NamespaceKey(const std::string& namespace_id_str, 176 static std::string NamespaceKey(const std::string& namespace_id_str,
166 const std::string& origin); 177 const std::string& origin);
167 static std::string NamespaceKey(int64 namespace_id, 178 static std::string NamespaceKey(int64 namespace_id,
168 int64 namespace_offset, 179 int64 namespace_offset,
169 const GURL& origin); 180 const GURL& origin);
170 static std::string NamespaceIdStr(int64 namespace_id, int64 namespace_offset); 181 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 204 // the offset yet. The namespaces ids which are handled as strings (named
194 // namesapce_id_str) contain the offset. 205 // namesapce_id_str) contain the offset.
195 int64 namespace_offset_; 206 int64 namespace_offset_;
196 207
197 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); 208 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase);
198 }; 209 };
199 210
200 } // namespace dom_storage 211 } // namespace dom_storage
201 212
202 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ 213 #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