Commit 2fcf3b65 authored by rajendrant's avatar rajendrant Committed by Commit Bot

Remove bandwidth netlog stats from data saver

This CL removes session network stats and historic network stats shown in
net-log bandwidth tab.

Bug: 894946
Change-Id: I8a18f2ae62c17bf877af398c61168b05da315c6c
Reviewed-on: https://chromium-review.googlesource.com/c/1297646Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602424}
parent ac9ac88f
...@@ -5,14 +5,9 @@ ...@@ -5,14 +5,9 @@
#include "chrome/browser/net/net_export_helper.h" #include "chrome/browser/net/net_export_helper.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
#include "extensions/buildflags/buildflags.h" #include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
...@@ -43,17 +38,6 @@ std::unique_ptr<base::DictionaryValue> GetPrerenderInfo(Profile* profile) { ...@@ -43,17 +38,6 @@ std::unique_ptr<base::DictionaryValue> GetPrerenderInfo(Profile* profile) {
return value; return value;
} }
std::unique_ptr<base::Value> GetHistoricNetworkStats(Profile* profile) {
DataReductionProxyChromeSettings* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile);
return data_reduction_proxy_settings
? data_reduction_proxy_settings->data_reduction_proxy_service()
->compression_stats()
->HistoricNetworkStatsInfoToValue()
: nullptr;
}
std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile) { std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile) {
auto extension_list = std::make_unique<base::ListValue>(); auto extension_list = std::make_unique<base::ListValue>();
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
...@@ -80,17 +64,6 @@ std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile) { ...@@ -80,17 +64,6 @@ std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile) {
return extension_list; return extension_list;
} }
std::unique_ptr<base::Value> GetSessionNetworkStats(Profile* profile) {
DataReductionProxyChromeSettings* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile);
return data_reduction_proxy_settings
? data_reduction_proxy_settings->data_reduction_proxy_service()
->compression_stats()
->SessionNetworkStatsInfoToValue()
: nullptr;
}
#if defined(OS_WIN) #if defined(OS_WIN)
std::unique_ptr<base::DictionaryValue> GetWindowsServiceProviders() { std::unique_ptr<base::DictionaryValue> GetWindowsServiceProviders() {
auto service_providers = std::make_unique<base::DictionaryValue>(); auto service_providers = std::make_unique<base::DictionaryValue>();
......
...@@ -18,14 +18,11 @@ namespace chrome_browser_net { ...@@ -18,14 +18,11 @@ namespace chrome_browser_net {
// Methods for getting Value summaries of net log polled data that need to be // Methods for getting Value summaries of net log polled data that need to be
// retrieved on the UI thread. All functions are expected to run on the UI // retrieved on the UI thread. All functions are expected to run on the UI
// thread. GetHistoricNetworkStats() and GetSessionNetworkStats() may return // thread. GetSessionNetworkStats() may return null if the info does not exist;
// null if the info does not exist; others will always return a Value (possibly // others will always return a Value (possibly empty).
// empty).
std::unique_ptr<base::DictionaryValue> GetPrerenderInfo(Profile* profile); std::unique_ptr<base::DictionaryValue> GetPrerenderInfo(Profile* profile);
std::unique_ptr<base::Value> GetHistoricNetworkStats(Profile* profile);
std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile); std::unique_ptr<base::ListValue> GetExtensionInfo(Profile* profile);
std::unique_ptr<base::Value> GetSessionNetworkStats(Profile* profile);
#if defined(OS_WIN) #if defined(OS_WIN)
std::unique_ptr<base::DictionaryValue> GetWindowsServiceProviders(); std::unique_ptr<base::DictionaryValue> GetWindowsServiceProviders();
#endif #endif
......
...@@ -250,12 +250,8 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) { ...@@ -250,12 +250,8 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
new base::DictionaryValue()); new base::DictionaryValue());
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
SetIfNotNull(ui_thread_polled_data.get(), "historicNetworkStats",
chrome_browser_net::GetHistoricNetworkStats(profile));
SetIfNotNull(ui_thread_polled_data.get(), "prerenderInfo", SetIfNotNull(ui_thread_polled_data.get(), "prerenderInfo",
chrome_browser_net::GetPrerenderInfo(profile)); chrome_browser_net::GetPrerenderInfo(profile));
SetIfNotNull(ui_thread_polled_data.get(), "sessionNetworkStats",
chrome_browser_net::GetSessionNetworkStats(profile));
SetIfNotNull(ui_thread_polled_data.get(), "extensionInfo", SetIfNotNull(ui_thread_polled_data.get(), "extensionInfo",
chrome_browser_net::GetExtensionInfo(profile)); chrome_browser_net::GetExtensionInfo(profile));
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -429,8 +429,6 @@ DataReductionProxyCompressionStats::DataReductionProxyCompressionStats( ...@@ -429,8 +429,6 @@ DataReductionProxyCompressionStats::DataReductionProxyCompressionStats(
pref_service_(prefs), pref_service_(prefs),
delay_(delay), delay_(delay),
data_usage_map_is_dirty_(false), data_usage_map_is_dirty_(false),
session_total_received_(0),
session_total_original_(0),
current_data_usage_load_status_(NOT_LOADED), current_data_usage_load_status_(NOT_LOADED),
weak_factory_(this) { weak_factory_(this) {
DCHECK(service); DCHECK(service);
...@@ -528,8 +526,6 @@ void DataReductionProxyCompressionStats::RecordDataUseWithMimeType( ...@@ -528,8 +526,6 @@ void DataReductionProxyCompressionStats::RecordDataUseWithMimeType(
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("loader", TRACE_EVENT0("loader",
"DataReductionProxyCompressionStats::RecordDataUseWithMimeType") "DataReductionProxyCompressionStats::RecordDataUseWithMimeType")
session_total_received_ += data_used;
session_total_original_ += original_size;
IncreaseInt64Pref(data_reduction_proxy::prefs::kHttpReceivedContentLength, IncreaseInt64Pref(data_reduction_proxy::prefs::kHttpReceivedContentLength,
data_used); data_used);
...@@ -608,34 +604,6 @@ void DataReductionProxyCompressionStats::WritePrefs() { ...@@ -608,34 +604,6 @@ void DataReductionProxyCompressionStats::WritePrefs() {
} }
} }
std::unique_ptr<base::Value>
DataReductionProxyCompressionStats::HistoricNetworkStatsInfoToValue() {
DCHECK(thread_checker_.CalledOnValidThread());
int64_t total_received = GetInt64(prefs::kHttpReceivedContentLength);
int64_t total_original = GetInt64(prefs::kHttpOriginalContentLength);
auto dict = std::make_unique<base::DictionaryValue>();
// Use strings to avoid overflow. base::Value only supports 32-bit integers.
dict->SetString("historic_received_content_length",
base::Int64ToString(total_received));
dict->SetString("historic_original_content_length",
base::Int64ToString(total_original));
return std::move(dict);
}
std::unique_ptr<base::Value>
DataReductionProxyCompressionStats::SessionNetworkStatsInfoToValue() const {
DCHECK(thread_checker_.CalledOnValidThread());
auto dict = std::make_unique<base::DictionaryValue>();
// Use strings to avoid overflow. base::Value only supports 32-bit integers.
dict->SetString("session_received_content_length",
base::Int64ToString(session_total_received_));
dict->SetString("session_original_content_length",
base::Int64ToString(session_total_original_));
return std::move(dict);
}
int64_t DataReductionProxyCompressionStats::GetLastUpdateTime() { int64_t DataReductionProxyCompressionStats::GetLastUpdateTime() {
int64_t last_update_internal = int64_t last_update_internal =
GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate); GetInt64(prefs::kDailyHttpContentLengthLastUpdateDate);
......
...@@ -101,15 +101,6 @@ class DataReductionProxyCompressionStats { ...@@ -101,15 +101,6 @@ class DataReductionProxyCompressionStats {
int64_t data_used, int64_t data_used,
const base::Time time); const base::Time time);
// Creates a |Value| summary of the persistent state of the network
// statistics.
// Must be called on the UI thread.
std::unique_ptr<base::Value> HistoricNetworkStatsInfoToValue();
// Creates a |Value| summary of the the session network statistics.
// Must be called on the UI thread.
std::unique_ptr<base::Value> SessionNetworkStatsInfoToValue() const;
// Returns the time in milliseconds since epoch that the last update was made // Returns the time in milliseconds since epoch that the last update was made
// to the daily original and received content lengths. // to the daily original and received content lengths.
int64_t GetLastUpdateTime(); int64_t GetLastUpdateTime();
...@@ -298,12 +289,6 @@ class DataReductionProxyCompressionStats { ...@@ -298,12 +289,6 @@ class DataReductionProxyCompressionStats {
// persisted to storage. // persisted to storage.
bool data_usage_map_is_dirty_; bool data_usage_map_is_dirty_;
// Total size of all content that has been received over the network.
int64_t session_total_received_;
// Total original size of all content before it was proxied.
int64_t session_total_original_;
// Tracks state of loading data usage from storage. // Tracks state of loading data usage from storage.
CurrentDataUsageLoadStatus current_data_usage_load_status_; CurrentDataUsageLoadStatus current_data_usage_load_status_;
......
...@@ -533,46 +533,6 @@ TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDelayed) { ...@@ -533,46 +533,6 @@ TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDelayed) {
VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength);
} }
TEST_F(DataReductionProxyCompressionStatsTest,
HistoricNetworkStatsInfoToValue) {
const int64_t kOriginalLength = 150;
const int64_t kReceivedLength = 100;
ResetCompressionStatsWithDelay(
base::TimeDelta::FromMinutes(kWriteDelayMinutes));
base::DictionaryValue* dict = nullptr;
std::unique_ptr<base::Value> stats_value(
compression_stats()->HistoricNetworkStatsInfoToValue());
EXPECT_TRUE(stats_value->GetAsDictionary(&dict));
VerifyPrefs(dict);
SetInt64(prefs::kHttpOriginalContentLength, kOriginalLength);
SetInt64(prefs::kHttpReceivedContentLength, kReceivedLength);
stats_value = compression_stats()->HistoricNetworkStatsInfoToValue();
EXPECT_TRUE(stats_value->GetAsDictionary(&dict));
VerifyPrefs(dict);
}
TEST_F(DataReductionProxyCompressionStatsTest,
HistoricNetworkStatsInfoToValueDirect) {
const int64_t kOriginalLength = 150;
const int64_t kReceivedLength = 100;
base::DictionaryValue* dict = nullptr;
std::unique_ptr<base::Value> stats_value(
compression_stats()->HistoricNetworkStatsInfoToValue());
EXPECT_TRUE(stats_value->GetAsDictionary(&dict));
VerifyPrefs(dict);
SetInt64(prefs::kHttpOriginalContentLength, kOriginalLength);
SetInt64(prefs::kHttpReceivedContentLength, kReceivedLength);
stats_value = compression_stats()->HistoricNetworkStatsInfoToValue();
EXPECT_TRUE(stats_value->GetAsDictionary(&dict));
VerifyPrefs(dict);
}
TEST_F(DataReductionProxyCompressionStatsTest, StatsRestoredOnOnRestart) { TEST_F(DataReductionProxyCompressionStatsTest, StatsRestoredOnOnRestart) {
base::ListValue list_value; base::ListValue list_value;
list_value.Insert(0, list_value.Insert(0,
......
...@@ -221,12 +221,14 @@ class DataReductionProxyDelegateTest : public testing::Test { ...@@ -221,12 +221,14 @@ class DataReductionProxyDelegateTest : public testing::Test {
int64_t total_received_bytes() const { int64_t total_received_bytes() const {
test_context_->RunUntilIdle(); test_context_->RunUntilIdle();
return GetSessionNetworkStatsInfoInt64("session_received_content_length"); return test_context_->pref_service()->GetInt64(
prefs::kHttpReceivedContentLength);
} }
int64_t total_original_received_bytes() const { int64_t total_original_received_bytes() const {
test_context_->RunUntilIdle(); test_context_->RunUntilIdle();
return GetSessionNetworkStatsInfoInt64("session_original_content_length"); return test_context_->pref_service()->GetInt64(
prefs::kHttpOriginalContentLength);
} }
net::MockClientSocketFactory* mock_socket_factory() { net::MockClientSocketFactory* mock_socket_factory() {
...@@ -252,21 +254,6 @@ class DataReductionProxyDelegateTest : public testing::Test { ...@@ -252,21 +254,6 @@ class DataReductionProxyDelegateTest : public testing::Test {
} }
private: private:
int64_t GetSessionNetworkStatsInfoInt64(const char* key) const {
std::unique_ptr<base::DictionaryValue> session_network_stats_info =
base::DictionaryValue::From(test_context_->settings()
->data_reduction_proxy_service()
->compression_stats()
->SessionNetworkStatsInfoToValue());
EXPECT_TRUE(session_network_stats_info);
std::string string_value;
EXPECT_TRUE(session_network_stats_info->GetString(key, &string_value));
int64_t value = 0;
EXPECT_TRUE(base::StringToInt64(string_value, &value));
return value;
}
base::MessageLoopForIO message_loop_; base::MessageLoopForIO message_loop_;
net::MockClientSocketFactory mock_socket_factory_; net::MockClientSocketFactory mock_socket_factory_;
net::TestURLRequestContext context_; net::TestURLRequestContext context_;
......
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