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 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/nullable_string16.h" | 12 #include "base/nullable_string16.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "webkit/dom_storage/dom_storage_export.h" |
15 #include "webkit/dom_storage/dom_storage_types.h" | 16 #include "webkit/dom_storage/dom_storage_types.h" |
16 | 17 |
17 namespace dom_storage { | 18 namespace dom_storage { |
18 | 19 |
19 class DomStorageDatabaseAdapter; | 20 class DomStorageDatabaseAdapter; |
20 class DomStorageMap; | 21 class DomStorageMap; |
21 class DomStorageTaskRunner; | 22 class DomStorageTaskRunner; |
22 class SessionStorageDatabase; | 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 DOM_STORAGE_EXPORT 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, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Frees up memory when possible. Typically, this method returns | 72 // Frees up memory when possible. Typically, this method returns |
72 // the object to its just constructed state, however if uncommitted | 73 // the object to its just constructed state, however if uncommitted |
73 // changes are pending, it does nothing. | 74 // changes are pending, it does nothing. |
74 void PurgeMemory(); | 75 void PurgeMemory(); |
75 | 76 |
76 // Schedules the commit of any unsaved changes and enters a | 77 // Schedules the commit of any unsaved changes and enters a |
77 // shutdown state such that the value getters and setters will | 78 // shutdown state such that the value getters and setters will |
78 // no longer do anything. | 79 // no longer do anything. |
79 void Shutdown(); | 80 void Shutdown(); |
80 | 81 |
| 82 static void DisableCommitDelayForTesting(); |
| 83 |
81 private: | 84 private: |
82 friend class DomStorageAreaTest; | 85 friend class DomStorageAreaTest; |
83 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics); | 86 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics); |
84 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened); | 87 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened); |
85 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath); | 88 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath); |
86 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks); | 89 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks); |
87 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown); | 90 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown); |
88 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DeleteOrigin); | 91 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DeleteOrigin); |
89 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, PurgeMemory); | 92 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, PurgeMemory); |
90 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, PersistentIds); | 93 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, PersistentIds); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 scoped_refptr<SessionStorageDatabase> session_storage_backing_; | 127 scoped_refptr<SessionStorageDatabase> session_storage_backing_; |
125 bool is_initial_import_done_; | 128 bool is_initial_import_done_; |
126 bool is_shutdown_; | 129 bool is_shutdown_; |
127 scoped_ptr<CommitBatch> commit_batch_; | 130 scoped_ptr<CommitBatch> commit_batch_; |
128 int commit_batches_in_flight_; | 131 int commit_batches_in_flight_; |
129 }; | 132 }; |
130 | 133 |
131 } // namespace dom_storage | 134 } // namespace dom_storage |
132 | 135 |
133 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 136 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
OLD | NEW |