OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // be removed and all others will be inserted/updated as appropriate. It is | 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 | 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. | 49 // that case the copy will be made deep before writing the values. |
50 bool CommitAreaChanges(int64 namespace_id, | 50 bool CommitAreaChanges(int64 namespace_id, |
51 const GURL& origin, | 51 const GURL& origin, |
52 bool clear_all_first, | 52 bool clear_all_first, |
53 const ValuesMap& changes); | 53 const ValuesMap& changes); |
54 | 54 |
55 // 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 |
56 // with |new_namespace_id|. | 56 // with |new_namespace_id|. |
57 bool CloneNamespace(int64 namespace_id, int64 new_namespace_id); | 57 void CloneNamespace(int64 namespace_id, int64 new_namespace_id); |
58 | 58 |
59 // Deletes the data for |namespace_id| and |origin|. | 59 // Deletes the data for |namespace_id| and |origin|. |
60 bool DeleteArea(int64 namespace_id, const GURL& origin); | 60 void DeleteArea(int64 namespace_id, const GURL& origin); |
61 | 61 |
62 // Deletes the data for |namespace_id|. | 62 // Deletes the data for |namespace_id|. |
63 bool DeleteNamespace(int64 namespace_id); | 63 bool DeleteNamespace(int64 namespace_id); |
64 | 64 |
| 65 // Reads all namespace ids from the database. |
| 66 bool ReadNamespaceIds(std::vector<int64>* namespace_ids); |
| 67 |
65 private: | 68 private: |
66 friend class base::RefCountedThreadSafe<SessionStorageDatabase>; | 69 friend class base::RefCountedThreadSafe<SessionStorageDatabase>; |
67 friend class SessionStorageDatabaseTest; | 70 friend class SessionStorageDatabaseTest; |
68 | 71 |
69 ~SessionStorageDatabase(); | 72 ~SessionStorageDatabase(); |
70 | 73 |
71 bool LazyOpen(bool create_if_needed); | 74 bool LazyOpen(bool create_if_needed); |
72 leveldb::Status TryToOpen(const FilePath& file_path, leveldb::DB** db); | 75 leveldb::Status TryToOpen(const FilePath& file_path, leveldb::DB** db); |
73 bool IsOpen() const; | 76 bool IsOpen() const; |
74 | 77 |
(...skipping 26 matching lines...) Expand all Loading... |
101 std::map<std::string, std::string>* areas); | 104 std::map<std::string, std::string>* areas); |
102 | 105 |
103 // Adds an association between |origin| and |map_id| into the namespace | 106 // Adds an association between |origin| and |map_id| into the namespace |
104 // |namespace_id|. | 107 // |namespace_id|. |
105 void AddAreaToNamespace(int64 namespace_id, | 108 void AddAreaToNamespace(int64 namespace_id, |
106 const std::string& origin, | 109 const std::string& origin, |
107 const std::string& map_id, | 110 const std::string& map_id, |
108 leveldb::WriteBatch* batch); | 111 leveldb::WriteBatch* batch); |
109 | 112 |
110 // Helpers for deleting data for |namespace_id| and |origin|. | 113 // Helpers for deleting data for |namespace_id| and |origin|. |
111 bool DeleteArea(int64 namespace_id, | 114 bool DeleteAreaHelper(int64 namespace_id, |
112 const std::string& origin, | 115 const std::string& origin, |
113 leveldb::WriteBatch* batch); | 116 leveldb::WriteBatch* batch); |
114 bool DeleteArea(const std::string& namespace_id_str, | 117 bool DeleteAreaHelper(const std::string& namespace_id_str, |
115 const std::string& origin, | 118 const std::string& origin, |
116 leveldb::WriteBatch* batch); | 119 leveldb::WriteBatch* batch); |
117 | 120 |
118 // Retrieves the map id for |namespace_id| and |origin|. It's not an error if | 121 // Retrieves the map id for |namespace_id| and |origin|. It's not an error if |
119 // the map doesn't exist. | 122 // the map doesn't exist. |
120 bool GetMapForArea(int64 namespace_id, | 123 bool GetMapForArea(int64 namespace_id, |
121 const GURL& origin, | 124 const GURL& origin, |
122 bool* exists, | 125 bool* exists, |
123 std::string* map_id); | 126 std::string* map_id); |
124 bool GetMapForArea(const std::string& namespace_id_str, | 127 bool GetMapForArea(const std::string& namespace_id_str, |
125 const std::string& origin, | 128 const std::string& origin, |
126 bool* exists, | 129 bool* exists, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // 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 |
202 // namesapce_id_str) contain the offset. | 205 // namesapce_id_str) contain the offset. |
203 int64 namespace_offset_; | 206 int64 namespace_offset_; |
204 | 207 |
205 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); | 208 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); |
206 }; | 209 }; |
207 | 210 |
208 } // namespace dom_storage | 211 } // namespace dom_storage |
209 | 212 |
210 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ | 213 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ |
OLD | NEW |