Commit c93b585e authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Clear data saver network properties when cache is cleared

Bug: 813184
Change-Id: I0e3dc1d458b96ebcb31506a38cdac177e2f9a859
Reviewed-on: https://chromium-review.googlesource.com/924397
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538824}
parent 1b488764
......@@ -946,6 +946,25 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
ui_nqe_service->ClearPrefs();
}
// Notify data reduction component.
data_reduction_proxy::DataReductionProxySettings*
data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
profile_);
// |data_reduction_proxy_settings| is null if |profile_| is off the record.
// Skip notification if the user clears cache for only a finite set of
// sites.
if (data_reduction_proxy_settings &&
filter_builder.GetMode() != BrowsingDataFilterBuilder::WHITELIST) {
data_reduction_proxy::DataReductionProxyService*
data_reduction_proxy_service =
data_reduction_proxy_settings->data_reduction_proxy_service();
if (data_reduction_proxy_service) {
data_reduction_proxy_service->OnCacheCleared(delete_begin_,
delete_end_);
}
}
#if defined(OS_ANDROID)
// For now we're considering offline pages as cache, so if we're removing
// cache we should remove offline pages as well.
......
......@@ -247,6 +247,12 @@ void DataReductionProxyIOData::DeleteBrowsingHistory(const base::Time start,
network_properties_manager_->DeleteHistory();
}
void DataReductionProxyIOData::OnCacheCleared(const base::Time start,
const base::Time end) {
DCHECK(io_task_runner_->BelongsToCurrentThread());
network_properties_manager_->DeleteHistory();
}
std::unique_ptr<net::URLRequestInterceptor>
DataReductionProxyIOData::CreateInterceptor() {
DCHECK(io_task_runner_->BelongsToCurrentThread());
......
......@@ -141,6 +141,11 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
// Called when the user clears the browsing history.
void DeleteBrowsingHistory(const base::Time start, const base::Time end);
// Notifies |this| that the user has requested to clear the browser
// cache. This method is not called if only a subset of site entries are
// cleared.
void OnCacheCleared(const base::Time start, const base::Time end);
// Various accessor methods.
DataReductionProxyConfigurator* configurator() const {
return configurator_.get();
......
......@@ -205,6 +205,14 @@ void DataReductionProxyService::SetPingbackReportingFraction(
pingback_client_->SetPingbackReportingFraction(pingback_reporting_fraction);
}
void DataReductionProxyService::OnCacheCleared(const base::Time start,
const base::Time end) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
io_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&DataReductionProxyIOData::OnCacheCleared,
io_data_, start, end));
}
void DataReductionProxyService::LoadHistoricalDataUsage(
const HistoricalDataUsageCallback& load_data_usage_callback) {
std::unique_ptr<std::vector<DataUsageBucket>> data_usage(
......
......@@ -127,6 +127,11 @@ class DataReductionProxyService
// Sets the reporting fraction in the pingback client.
void SetPingbackReportingFraction(float pingback_reporting_fraction);
// Notifies |this| that the user has requested to clear the browser
// cache. This method is not called if only a subset of site entries are
// cleared.
void OnCacheCleared(const base::Time start, const base::Time end);
// Accessor methods.
DataReductionProxyCompressionStats* compression_stats() const {
return compression_stats_.get();
......
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