Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: content/browser/dom_storage/dom_storage_area.h

Issue 896643002: [DOMStorage] Rate limiting writes to disk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c92d605f87a6988db01de85ab5c138bb07f62783 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();
@@ -114,8 +135,10 @@ class CONTENT_EXPORT DOMStorageArea
// task sequence when complete.
CommitBatch* CreateCommitBatchIfNeeded();
void OnCommitTimer();
+ void PostCommitTask();
void CommitChanges(const CommitBatch* commit_batch);
void OnCommitComplete();
+ base::TimeDelta ComputeCommitDelay() const;
void ShutdownInCommitSequence();
@@ -131,6 +154,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_;
};
Alexei Svitkine (slow) 2015/02/17 01:05:20 Nit: Is there a reason this class doesn't have DIS
} // namespace content
« no previous file with comments | « no previous file | content/browser/dom_storage/dom_storage_area.cc » ('j') | content/browser/dom_storage/dom_storage_area.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698