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_types.h" | 15 #include "webkit/dom_storage/dom_storage_types.h" |
16 | 16 |
17 namespace dom_storage { | 17 namespace dom_storage { |
18 | 18 |
19 class DomStorageDatabaseAdapter; | 19 class DomStorageDatabaseAdapter; |
20 class DomStorageMap; | 20 class DomStorageMap; |
21 class DomStorageTaskRunner; | 21 class DomStorageTaskRunner; |
22 class SessionStorageDatabase; | 22 class SessionStorageDatabase; |
23 | 23 |
24 // Container for a per-origin Map of key/value pairs potentially | 24 // Container for a per-origin Map of key/value pairs potentially |
25 // backed by storage on disk and lazily commits changes to disk. | 25 // backed by storage on disk and lazily commits changes to disk. |
26 // See class comments for DomStorageContext for a larger overview. | 26 // See class comments for DomStorageContext for a larger overview. |
27 class DomStorageArea | 27 class __attribute__((visibility("default"))) DomStorageArea |
28 : public base::RefCountedThreadSafe<DomStorageArea> { | 28 : public base::RefCountedThreadSafe<DomStorageArea> { |
29 | 29 |
30 public: | 30 public: |
31 static const FilePath::CharType kDatabaseFileExtension[]; | 31 static const FilePath::CharType kDatabaseFileExtension[]; |
32 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); | 32 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); |
33 static GURL OriginFromDatabaseFileName(const FilePath& file_name); | 33 static GURL OriginFromDatabaseFileName(const FilePath& file_name); |
34 | 34 |
35 // Local storage. Backed on disk if directory is nonempty. | 35 // Local storage. Backed on disk if directory is nonempty. |
36 DomStorageArea(const GURL& origin, | 36 DomStorageArea(const GURL& origin, |
37 const FilePath& directory, | 37 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 | 71 // Frees up memory when possible. Typically, this method returns |
72 // the object to its just constructed state, however if uncommitted | 72 // the object to its just constructed state, however if uncommitted |
73 // changes are pending, it does nothing. | 73 // changes are pending, it does nothing. |
74 void PurgeMemory(); | 74 void PurgeMemory(); |
75 | 75 |
76 // Schedules the commit of any unsaved changes and enters a | 76 // Schedules the commit of any unsaved changes and enters a |
77 // shutdown state such that the value getters and setters will | 77 // shutdown state such that the value getters and setters will |
78 // no longer do anything. | 78 // no longer do anything. |
79 void Shutdown(); | 79 void Shutdown(); |
80 | 80 |
| 81 static int set_me; |
| 82 |
81 private: | 83 private: |
82 friend class DomStorageAreaTest; | 84 friend class DomStorageAreaTest; |
83 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics); | 85 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics); |
84 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened); | 86 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened); |
85 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath); | 87 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath); |
86 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks); | 88 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks); |
87 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown); | 89 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown); |
88 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DeleteOrigin); | 90 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DeleteOrigin); |
89 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, PurgeMemory); | 91 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, PurgeMemory); |
90 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, PersistentIds); | 92 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_; | 126 scoped_refptr<SessionStorageDatabase> session_storage_backing_; |
125 bool is_initial_import_done_; | 127 bool is_initial_import_done_; |
126 bool is_shutdown_; | 128 bool is_shutdown_; |
127 scoped_ptr<CommitBatch> commit_batch_; | 129 scoped_ptr<CommitBatch> commit_batch_; |
128 int commit_batches_in_flight_; | 130 int commit_batches_in_flight_; |
129 }; | 131 }; |
130 | 132 |
131 } // namespace dom_storage | 133 } // namespace dom_storage |
132 | 134 |
133 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 135 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
OLD | NEW |