OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // backed by storage on disk and lazily commits changes to disk. | 28 // backed by storage on disk and lazily commits changes to disk. |
29 // See class comments for DOMStorageContextImpl for a larger overview. | 29 // See class comments for DOMStorageContextImpl for a larger overview. |
30 class CONTENT_EXPORT DOMStorageArea | 30 class CONTENT_EXPORT DOMStorageArea |
31 : public base::RefCountedThreadSafe<DOMStorageArea> { | 31 : public base::RefCountedThreadSafe<DOMStorageArea> { |
32 | 32 |
33 public: | 33 public: |
34 static const base::FilePath::CharType kDatabaseFileExtension[]; | 34 static const base::FilePath::CharType kDatabaseFileExtension[]; |
35 static base::FilePath DatabaseFileNameFromOrigin(const GURL& origin); | 35 static base::FilePath DatabaseFileNameFromOrigin(const GURL& origin); |
36 static GURL OriginFromDatabaseFileName(const base::FilePath& file_name); | 36 static GURL OriginFromDatabaseFileName(const base::FilePath& file_name); |
37 | 37 |
| 38 // Commence aggressive flushing. This should be called early in the startup - |
| 39 // before any localStorage writing. Currently scheduled writes will not be |
| 40 // rescheduled and will be flushed at the scheduled time after which |
| 41 // aggressive flushing will commence. |
| 42 static void EnableAggressiveCommitDelay(); |
| 43 |
38 // Local storage. Backed on disk if directory is nonempty. | 44 // Local storage. Backed on disk if directory is nonempty. |
39 DOMStorageArea(const GURL& origin, | 45 DOMStorageArea(const GURL& origin, |
40 const base::FilePath& directory, | 46 const base::FilePath& directory, |
41 DOMStorageTaskRunner* task_runner); | 47 DOMStorageTaskRunner* task_runner); |
42 | 48 |
43 // Session storage. Backed on disk if |session_storage_backing| is not NULL. | 49 // Session storage. Backed on disk if |session_storage_backing| is not NULL. |
44 DOMStorageArea(int64 namespace_id, | 50 DOMStorageArea(int64 namespace_id, |
45 const std::string& persistent_namespace_id, | 51 const std::string& persistent_namespace_id, |
46 const GURL& origin, | 52 const GURL& origin, |
47 SessionStorageDatabase* session_storage_backing, | 53 SessionStorageDatabase* session_storage_backing, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 CommitBatch* CreateCommitBatchIfNeeded(); | 152 CommitBatch* CreateCommitBatchIfNeeded(); |
147 void StartCommitTimer(); | 153 void StartCommitTimer(); |
148 void OnCommitTimer(); | 154 void OnCommitTimer(); |
149 void PostCommitTask(); | 155 void PostCommitTask(); |
150 void CommitChanges(const CommitBatch* commit_batch); | 156 void CommitChanges(const CommitBatch* commit_batch); |
151 void OnCommitComplete(); | 157 void OnCommitComplete(); |
152 base::TimeDelta ComputeCommitDelay() const; | 158 base::TimeDelta ComputeCommitDelay() const; |
153 | 159 |
154 void ShutdownInCommitSequence(); | 160 void ShutdownInCommitSequence(); |
155 | 161 |
| 162 static bool s_aggressive_flushing_enabled_; |
| 163 |
156 int64 namespace_id_; | 164 int64 namespace_id_; |
157 std::string persistent_namespace_id_; | 165 std::string persistent_namespace_id_; |
158 GURL origin_; | 166 GURL origin_; |
159 base::FilePath directory_; | 167 base::FilePath directory_; |
160 scoped_refptr<DOMStorageTaskRunner> task_runner_; | 168 scoped_refptr<DOMStorageTaskRunner> task_runner_; |
161 scoped_refptr<DOMStorageMap> map_; | 169 scoped_refptr<DOMStorageMap> map_; |
162 scoped_ptr<DOMStorageDatabaseAdapter> backing_; | 170 scoped_ptr<DOMStorageDatabaseAdapter> backing_; |
163 scoped_refptr<SessionStorageDatabase> session_storage_backing_; | 171 scoped_refptr<SessionStorageDatabase> session_storage_backing_; |
164 bool is_initial_import_done_; | 172 bool is_initial_import_done_; |
165 bool is_shutdown_; | 173 bool is_shutdown_; |
166 scoped_ptr<CommitBatch> commit_batch_; | 174 scoped_ptr<CommitBatch> commit_batch_; |
167 int commit_batches_in_flight_; | 175 int commit_batches_in_flight_; |
168 base::TimeTicks start_time_; | 176 base::TimeTicks start_time_; |
169 RateLimiter data_rate_limiter_; | 177 RateLimiter data_rate_limiter_; |
170 RateLimiter commit_rate_limiter_; | 178 RateLimiter commit_rate_limiter_; |
171 | 179 |
172 DISALLOW_COPY_AND_ASSIGN(DOMStorageArea); | 180 DISALLOW_COPY_AND_ASSIGN(DOMStorageArea); |
173 }; | 181 }; |
174 | 182 |
175 } // namespace content | 183 } // namespace content |
176 | 184 |
177 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 185 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
OLD | NEW |