Index: content/browser/dom_storage/dom_storage_area.h |
diff --git a/content/browser/dom_storage/dom_storage_area.h b/content/browser/dom_storage/dom_storage_area.h |
index ca28be1aa144da7a55a984a3fdf2f1cdc96d50ed..09da0547a132a3894918fb9cf81e3bf1e41a3810 100644 |
--- a/content/browser/dom_storage/dom_storage_area.h |
+++ b/content/browser/dom_storage/dom_storage_area.h |
@@ -5,6 +5,8 @@ |
#ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
#define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
+#include <string> |
+ |
#include "base/files/file_path.h" |
#include "base/gtest_prod_util.h" |
#include "base/memory/ref_counted.h" |
@@ -65,6 +67,7 @@ class CONTENT_EXPORT DOMStorageArea |
const std::string& destination_persistent_namespace_id); |
bool HasUncommittedChanges() const; |
+ void ScheduleImmediateCommit(); |
// Similar to Clear() but more optimized for just deleting |
// without raising events. |
@@ -92,14 +95,32 @@ class CONTENT_EXPORT DOMStorageArea |
FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, CommitChangesAtShutdown); |
FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, DeleteOrigin); |
FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, PurgeMemory); |
+ FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, RateLimiter); |
FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, PersistentIds); |
friend class base::RefCountedThreadSafe<DOMStorageArea>; |
+ class CONTENT_EXPORT RateLimiter { |
+ public: |
+ RateLimiter(size_t desired_rate, base::TimeDelta time_quantum); |
+ |
+ void add_samples(size_t samples); |
+ base::TimeDelta ComputeTimeNeeded() const; |
+ base::TimeDelta ComputeDelayNeeded( |
+ const base::TimeDelta elapsed_time) const; |
+ |
+ private: |
+ float rate_; |
+ float samples_; |
+ base::TimeDelta time_quantum_; |
+ }; |
+ |
struct CommitBatch { |
bool clear_all_first; |
DOMStorageValuesMap changed_values; |
+ |
CommitBatch(); |
~CommitBatch(); |
+ size_t GetDataSize() const; |
}; |
~DOMStorageArea(); |
@@ -116,6 +137,7 @@ class CONTENT_EXPORT DOMStorageArea |
void OnCommitTimer(); |
void CommitChanges(const CommitBatch* commit_batch); |
void OnCommitComplete(); |
+ base::TimeDelta ComputeCommitDelay() const; |
void ShutdownInCommitSequence(); |
@@ -131,6 +153,9 @@ class CONTENT_EXPORT DOMStorageArea |
bool is_shutdown_; |
scoped_ptr<CommitBatch> commit_batch_; |
int commit_batches_in_flight_; |
+ base::TimeTicks start_time_; |
+ RateLimiter data_rate_limiter_; |
+ RateLimiter commit_rate_limiter_; |
}; |
} // namespace content |