Commit f843ae38 authored by Jarryd's avatar Jarryd Committed by Commit Bot

Quota: Add SequenceChecker to QuotaTemporaryStorageEvictor

The purpose of this change is to make it easy to reason about the thread
safety of QuotaTemporaryStorageEvictor.

Change-Id: I6dc9c684f9e1d0c70a8f8703ed2e7ac5ec8bd15d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503901Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638211}
parent d1ae8bc1
...@@ -57,6 +57,7 @@ QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() { ...@@ -57,6 +57,7 @@ QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() {
void QuotaTemporaryStorageEvictor::GetStatistics( void QuotaTemporaryStorageEvictor::GetStatistics(
std::map<std::string, int64_t>* statistics) { std::map<std::string, int64_t>* statistics) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(statistics); DCHECK(statistics);
(*statistics)["errors-on-evicting-origin"] = (*statistics)["errors-on-evicting-origin"] =
...@@ -72,6 +73,7 @@ void QuotaTemporaryStorageEvictor::GetStatistics( ...@@ -72,6 +73,7 @@ void QuotaTemporaryStorageEvictor::GetStatistics(
} }
void QuotaTemporaryStorageEvictor::ReportPerRoundHistogram() { void QuotaTemporaryStorageEvictor::ReportPerRoundHistogram() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(round_statistics_.in_round); DCHECK(round_statistics_.in_round);
DCHECK(round_statistics_.is_initialized); DCHECK(round_statistics_.is_initialized);
...@@ -93,6 +95,7 @@ void QuotaTemporaryStorageEvictor::ReportPerRoundHistogram() { ...@@ -93,6 +95,7 @@ void QuotaTemporaryStorageEvictor::ReportPerRoundHistogram() {
} }
void QuotaTemporaryStorageEvictor::ReportPerHourHistogram() { void QuotaTemporaryStorageEvictor::ReportPerHourHistogram() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Statistics stats_in_hour(statistics_); Statistics stats_in_hour(statistics_);
stats_in_hour.subtract_assign(previous_statistics_); stats_in_hour.subtract_assign(previous_statistics_);
previous_statistics_ = statistics_; previous_statistics_ = statistics_;
...@@ -110,6 +113,7 @@ void QuotaTemporaryStorageEvictor::ReportPerHourHistogram() { ...@@ -110,6 +113,7 @@ void QuotaTemporaryStorageEvictor::ReportPerHourHistogram() {
} }
void QuotaTemporaryStorageEvictor::OnEvictionRoundStarted() { void QuotaTemporaryStorageEvictor::OnEvictionRoundStarted() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (round_statistics_.in_round) if (round_statistics_.in_round)
return; return;
round_statistics_.in_round = true; round_statistics_.in_round = true;
...@@ -118,6 +122,7 @@ void QuotaTemporaryStorageEvictor::OnEvictionRoundStarted() { ...@@ -118,6 +122,7 @@ void QuotaTemporaryStorageEvictor::OnEvictionRoundStarted() {
} }
void QuotaTemporaryStorageEvictor::OnEvictionRoundFinished() { void QuotaTemporaryStorageEvictor::OnEvictionRoundFinished() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
in_progress_eviction_origins_.clear(); in_progress_eviction_origins_.clear();
// Check if skipped round // Check if skipped round
...@@ -146,6 +151,7 @@ void QuotaTemporaryStorageEvictor::Start() { ...@@ -146,6 +151,7 @@ void QuotaTemporaryStorageEvictor::Start() {
} }
void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) { void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (eviction_timer_.IsRunning() || timer_disabled_for_testing_) if (eviction_timer_.IsRunning() || timer_disabled_for_testing_)
return; return;
eviction_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms), eviction_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms),
...@@ -153,6 +159,7 @@ void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) { ...@@ -153,6 +159,7 @@ void QuotaTemporaryStorageEvictor::StartEvictionTimerWithDelay(int delay_ms) {
} }
void QuotaTemporaryStorageEvictor::ConsiderEviction() { void QuotaTemporaryStorageEvictor::ConsiderEviction() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
OnEvictionRoundStarted(); OnEvictionRoundStarted();
quota_eviction_handler_->GetEvictionRoundInfo( quota_eviction_handler_->GetEvictionRoundInfo(
base::BindOnce(&QuotaTemporaryStorageEvictor::OnGotEvictionRoundInfo, base::BindOnce(&QuotaTemporaryStorageEvictor::OnGotEvictionRoundInfo,
...@@ -166,6 +173,7 @@ void QuotaTemporaryStorageEvictor::OnGotEvictionRoundInfo( ...@@ -166,6 +173,7 @@ void QuotaTemporaryStorageEvictor::OnGotEvictionRoundInfo(
int64_t total_space, int64_t total_space,
int64_t current_usage, int64_t current_usage,
bool current_usage_is_complete) { bool current_usage_is_complete) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_GE(current_usage, 0); DCHECK_GE(current_usage, 0);
// Note: if there is no storage pressure, |current_usage| // Note: if there is no storage pressure, |current_usage|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment