| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/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 "third_party/leveldatabase/src/include/leveldb/status.h" | 15 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 16 #include "webkit/dom_storage/dom_storage_export.h" |
| 16 #include "webkit/dom_storage/dom_storage_types.h" | 17 #include "webkit/dom_storage/dom_storage_types.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace leveldb { | 21 namespace leveldb { |
| 21 class DB; | 22 class DB; |
| 22 struct ReadOptions; | 23 struct ReadOptions; |
| 23 class WriteBatch; | 24 class WriteBatch; |
| 24 } // namespace leveldb | 25 } // namespace leveldb |
| 25 | 26 |
| 26 namespace dom_storage { | 27 namespace dom_storage { |
| 27 | 28 |
| 28 // SessionStorageDatabase holds the data from multiple namespaces and multiple | 29 // SessionStorageDatabase holds the data from multiple namespaces and multiple |
| 29 // origins. All DomStorageAreas for session storage share the same | 30 // origins. All DomStorageAreas for session storage share the same |
| 30 // SessionStorageDatabase. | 31 // SessionStorageDatabase. |
| 31 | 32 |
| 32 // 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 |
| 33 // ReadAreaValues. Other threads area allowed to call ReadAreaValues. | 34 // ReadAreaValues. Other threads area allowed to call ReadAreaValues. |
| 34 class SessionStorageDatabase : | 35 class DOM_STORAGE_EXPORT SessionStorageDatabase : |
| 35 public base::RefCountedThreadSafe<SessionStorageDatabase> { | 36 public base::RefCountedThreadSafe<SessionStorageDatabase> { |
| 36 public: | 37 public: |
| 37 explicit SessionStorageDatabase(const FilePath& file_path); | 38 explicit SessionStorageDatabase(const FilePath& file_path); |
| 38 | 39 |
| 39 // Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is | 40 // Reads the (key, value) pairs for |namespace_id| and |origin|. |result| is |
| 40 // assumed to be empty and any duplicate keys will be overwritten. If the | 41 // assumed to be empty and any duplicate keys will be overwritten. If the |
| 41 // database exists on disk then it will be opened. If it does not exist then | 42 // database exists on disk then it will be opened. If it does not exist then |
| 42 // it will not be created and |result| will be unmodified. | 43 // it will not be created and |result| will be unmodified. |
| 43 void ReadAreaValues(const std::string& namespace_id, | 44 void ReadAreaValues(const std::string& namespace_id, |
| 44 const GURL& origin, | 45 const GURL& origin, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool db_error_; | 198 bool db_error_; |
| 198 // True if the database is in an inconsistent state. | 199 // True if the database is in an inconsistent state. |
| 199 bool is_inconsistent_; | 200 bool is_inconsistent_; |
| 200 | 201 |
| 201 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); | 202 DISALLOW_COPY_AND_ASSIGN(SessionStorageDatabase); |
| 202 }; | 203 }; |
| 203 | 204 |
| 204 } // namespace dom_storage | 205 } // namespace dom_storage |
| 205 | 206 |
| 206 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ | 207 #endif // WEBKIT_DOM_STORAGE_SESSION_STORAGE_DATABASE_H_ |
| OLD | NEW |