| 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_DOM_STORAGE_AREA_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/nullable_string16.h" | 13 #include "base/nullable_string16.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "webkit/dom_storage/dom_storage_types.h" | 16 #include "webkit/dom_storage/dom_storage_types.h" |
| 17 | 17 |
| 18 namespace dom_storage { | 18 namespace dom_storage { |
| 19 | 19 |
| 20 class DomStorageDatabaseAdapter; | 20 class DomStorageDatabaseAdapter; |
| 21 class DomStorageMap; | 21 class DomStorageMap; |
| 22 class DomStorageTaskRunner; | 22 class DomStorageTaskRunner; |
| 23 class SessionStorageDatabase; |
| 23 | 24 |
| 24 // Container for a per-origin Map of key/value pairs potentially | 25 // Container for a per-origin Map of key/value pairs potentially |
| 25 // backed by storage on disk and lazily commits changes to disk. | 26 // backed by storage on disk and lazily commits changes to disk. |
| 26 // See class comments for DomStorageContext for a larger overview. | 27 // See class comments for DomStorageContext for a larger overview. |
| 27 class DomStorageArea | 28 class DomStorageArea |
| 28 : public base::RefCountedThreadSafe<DomStorageArea> { | 29 : public base::RefCountedThreadSafe<DomStorageArea> { |
| 29 | 30 |
| 30 public: | 31 public: |
| 31 static const FilePath::CharType kDatabaseFileExtension[]; | 32 static const FilePath::CharType kDatabaseFileExtension[]; |
| 32 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); | 33 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); |
| 33 static GURL OriginFromDatabaseFileName(const FilePath& file_name); | 34 static GURL OriginFromDatabaseFileName(const FilePath& file_name); |
| 34 | 35 |
| 35 // Local storage. Backed on disk if directory is nonempty. | 36 // Local storage. Backed on disk if directory is nonempty. |
| 36 DomStorageArea(const GURL& origin, | 37 DomStorageArea(const GURL& origin, |
| 37 const FilePath& directory, | 38 const FilePath& directory, |
| 38 DomStorageTaskRunner* task_runner); | 39 DomStorageTaskRunner* task_runner); |
| 39 | 40 |
| 40 // Session storage. | 41 // Session storage. Backed on disk if |session_storage_backing| is not NULL. |
| 41 DomStorageArea(int64 namespace_id, | 42 DomStorageArea(int64 namespace_id, |
| 42 const std::string& persistent_namespace_id, | 43 const std::string& persistent_namespace_id, |
| 43 const GURL& origin, | 44 const GURL& origin, |
| 45 SessionStorageDatabase* session_storage_backing, |
| 44 DomStorageTaskRunner* task_runner); | 46 DomStorageTaskRunner* task_runner); |
| 45 | 47 |
| 46 const GURL& origin() const { return origin_; } | 48 const GURL& origin() const { return origin_; } |
| 47 int64 namespace_id() const { return namespace_id_; } | 49 int64 namespace_id() const { return namespace_id_; } |
| 48 | 50 |
| 49 // Writes a copy of the current set of values in the area to the |map|. | 51 // Writes a copy of the current set of values in the area to the |map|. |
| 50 void ExtractValues(ValuesMap* map); | 52 void ExtractValues(ValuesMap* map); |
| 51 | 53 |
| 52 unsigned Length(); | 54 unsigned Length(); |
| 53 NullableString16 Key(unsigned index); | 55 NullableString16 Key(unsigned index); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 115 |
| 114 void ShutdownInCommitSequence(); | 116 void ShutdownInCommitSequence(); |
| 115 | 117 |
| 116 int64 namespace_id_; | 118 int64 namespace_id_; |
| 117 std::string persistent_namespace_id_; | 119 std::string persistent_namespace_id_; |
| 118 GURL origin_; | 120 GURL origin_; |
| 119 FilePath directory_; | 121 FilePath directory_; |
| 120 scoped_refptr<DomStorageTaskRunner> task_runner_; | 122 scoped_refptr<DomStorageTaskRunner> task_runner_; |
| 121 scoped_refptr<DomStorageMap> map_; | 123 scoped_refptr<DomStorageMap> map_; |
| 122 scoped_ptr<DomStorageDatabaseAdapter> backing_; | 124 scoped_ptr<DomStorageDatabaseAdapter> backing_; |
| 125 scoped_refptr<SessionStorageDatabase> session_storage_backing_; |
| 123 bool is_initial_import_done_; | 126 bool is_initial_import_done_; |
| 124 bool is_shutdown_; | 127 bool is_shutdown_; |
| 125 scoped_ptr<CommitBatch> commit_batch_; | 128 scoped_ptr<CommitBatch> commit_batch_; |
| 126 int commit_batches_in_flight_; | 129 int commit_batches_in_flight_; |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 } // namespace dom_storage | 132 } // namespace dom_storage |
| 130 | 133 |
| 131 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 134 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| OLD | NEW |