| 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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <string> | 11 #include <string> |
| 9 | 12 |
| 10 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 11 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/nullable_string16.h" | 18 #include "base/strings/nullable_string16.h" |
| 15 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 16 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 17 #include "content/common/dom_storage/dom_storage_types.h" | 21 #include "content/common/dom_storage/dom_storage_types.h" |
| 18 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 19 | 23 |
| 20 namespace content { | 24 namespace content { |
| 21 | 25 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 // rescheduled and will be flushed at the scheduled time after which | 44 // rescheduled and will be flushed at the scheduled time after which |
| 41 // aggressive flushing will commence. | 45 // aggressive flushing will commence. |
| 42 static void EnableAggressiveCommitDelay(); | 46 static void EnableAggressiveCommitDelay(); |
| 43 | 47 |
| 44 // Local storage. Backed on disk if directory is nonempty. | 48 // Local storage. Backed on disk if directory is nonempty. |
| 45 DOMStorageArea(const GURL& origin, | 49 DOMStorageArea(const GURL& origin, |
| 46 const base::FilePath& directory, | 50 const base::FilePath& directory, |
| 47 DOMStorageTaskRunner* task_runner); | 51 DOMStorageTaskRunner* task_runner); |
| 48 | 52 |
| 49 // Session storage. Backed on disk if |session_storage_backing| is not NULL. | 53 // Session storage. Backed on disk if |session_storage_backing| is not NULL. |
| 50 DOMStorageArea(int64 namespace_id, | 54 DOMStorageArea(int64_t namespace_id, |
| 51 const std::string& persistent_namespace_id, | 55 const std::string& persistent_namespace_id, |
| 52 const GURL& origin, | 56 const GURL& origin, |
| 53 SessionStorageDatabase* session_storage_backing, | 57 SessionStorageDatabase* session_storage_backing, |
| 54 DOMStorageTaskRunner* task_runner); | 58 DOMStorageTaskRunner* task_runner); |
| 55 | 59 |
| 56 const GURL& origin() const { return origin_; } | 60 const GURL& origin() const { return origin_; } |
| 57 int64 namespace_id() const { return namespace_id_; } | 61 int64_t namespace_id() const { return namespace_id_; } |
| 58 | 62 |
| 59 // Writes a copy of the current set of values in the area to the |map|. | 63 // Writes a copy of the current set of values in the area to the |map|. |
| 60 void ExtractValues(DOMStorageValuesMap* map); | 64 void ExtractValues(DOMStorageValuesMap* map); |
| 61 | 65 |
| 62 unsigned Length(); | 66 unsigned Length(); |
| 63 base::NullableString16 Key(unsigned index); | 67 base::NullableString16 Key(unsigned index); |
| 64 base::NullableString16 GetItem(const base::string16& key); | 68 base::NullableString16 GetItem(const base::string16& key); |
| 65 bool SetItem(const base::string16& key, const base::string16& value, | 69 bool SetItem(const base::string16& key, const base::string16& value, |
| 66 base::NullableString16* old_value); | 70 base::NullableString16* old_value); |
| 67 bool RemoveItem(const base::string16& key, base::string16* old_value); | 71 bool RemoveItem(const base::string16& key, base::string16* old_value); |
| 68 bool Clear(); | 72 bool Clear(); |
| 69 void FastClear(); | 73 void FastClear(); |
| 70 | 74 |
| 71 DOMStorageArea* ShallowCopy( | 75 DOMStorageArea* ShallowCopy( |
| 72 int64 destination_namespace_id, | 76 int64_t destination_namespace_id, |
| 73 const std::string& destination_persistent_namespace_id); | 77 const std::string& destination_persistent_namespace_id); |
| 74 | 78 |
| 75 bool HasUncommittedChanges() const; | 79 bool HasUncommittedChanges() const; |
| 76 void ScheduleImmediateCommit(); | 80 void ScheduleImmediateCommit(); |
| 77 | 81 |
| 78 // Similar to Clear() but more optimized for just deleting | 82 // Similar to Clear() but more optimized for just deleting |
| 79 // without raising events. | 83 // without raising events. |
| 80 void DeleteOrigin(); | 84 void DeleteOrigin(); |
| 81 | 85 |
| 82 // Frees up memory when possible. Typically, this method returns | 86 // Frees up memory when possible. Typically, this method returns |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void OnCommitTimer(); | 158 void OnCommitTimer(); |
| 155 void PostCommitTask(); | 159 void PostCommitTask(); |
| 156 void CommitChanges(const CommitBatch* commit_batch); | 160 void CommitChanges(const CommitBatch* commit_batch); |
| 157 void OnCommitComplete(); | 161 void OnCommitComplete(); |
| 158 base::TimeDelta ComputeCommitDelay() const; | 162 base::TimeDelta ComputeCommitDelay() const; |
| 159 | 163 |
| 160 void ShutdownInCommitSequence(); | 164 void ShutdownInCommitSequence(); |
| 161 | 165 |
| 162 static bool s_aggressive_flushing_enabled_; | 166 static bool s_aggressive_flushing_enabled_; |
| 163 | 167 |
| 164 int64 namespace_id_; | 168 int64_t namespace_id_; |
| 165 std::string persistent_namespace_id_; | 169 std::string persistent_namespace_id_; |
| 166 GURL origin_; | 170 GURL origin_; |
| 167 base::FilePath directory_; | 171 base::FilePath directory_; |
| 168 scoped_refptr<DOMStorageTaskRunner> task_runner_; | 172 scoped_refptr<DOMStorageTaskRunner> task_runner_; |
| 169 scoped_refptr<DOMStorageMap> map_; | 173 scoped_refptr<DOMStorageMap> map_; |
| 170 scoped_ptr<DOMStorageDatabaseAdapter> backing_; | 174 scoped_ptr<DOMStorageDatabaseAdapter> backing_; |
| 171 scoped_refptr<SessionStorageDatabase> session_storage_backing_; | 175 scoped_refptr<SessionStorageDatabase> session_storage_backing_; |
| 172 bool is_initial_import_done_; | 176 bool is_initial_import_done_; |
| 173 bool is_shutdown_; | 177 bool is_shutdown_; |
| 174 scoped_ptr<CommitBatch> commit_batch_; | 178 scoped_ptr<CommitBatch> commit_batch_; |
| 175 int commit_batches_in_flight_; | 179 int commit_batches_in_flight_; |
| 176 base::TimeTicks start_time_; | 180 base::TimeTicks start_time_; |
| 177 RateLimiter data_rate_limiter_; | 181 RateLimiter data_rate_limiter_; |
| 178 RateLimiter commit_rate_limiter_; | 182 RateLimiter commit_rate_limiter_; |
| 179 | 183 |
| 180 DISALLOW_COPY_AND_ASSIGN(DOMStorageArea); | 184 DISALLOW_COPY_AND_ASSIGN(DOMStorageArea); |
| 181 }; | 185 }; |
| 182 | 186 |
| 183 } // namespace content | 187 } // namespace content |
| 184 | 188 |
| 185 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 189 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
| OLD | NEW |