summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/io_thread.cc8
-rw-r--r--chrome/browser/net/chrome_network_data_saving_metrics.cc360
-rw-r--r--chrome/browser/net/chrome_network_data_saving_metrics.h40
-rw-r--r--chrome/browser/net/chrome_network_data_saving_metrics_unittest.cc260
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc41
-rw-r--r--chrome/browser/net/chrome_network_delegate.h3
-rw-r--r--chrome/common/pref_names.cc13
-rw-r--r--chrome/common/pref_names.h4
-rw-r--r--tools/metrics/histograms/histograms.xml81
9 files changed, 667 insertions, 143 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 770fa84..337adfe 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -880,6 +880,14 @@ void IOThread::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabled);
registry->RegisterListPref(
+ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxy);
registry->RegisterListPref(
prefs::kDailyContentLengthViaDataReductionProxy);
diff --git a/chrome/browser/net/chrome_network_data_saving_metrics.cc b/chrome/browser/net/chrome_network_data_saving_metrics.cc
index 6a71b77..bf8dfcf 100644
--- a/chrome/browser/net/chrome_network_data_saving_metrics.cc
+++ b/chrome/browser/net/chrome_network_data_saving_metrics.cc
@@ -8,11 +8,24 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
+#include "content/public/common/url_constants.h"
+#include "net/base/host_port_pair.h"
+#include "net/http/http_response_headers.h"
+#include "net/proxy/proxy_retry_info.h"
+#include "net/proxy/proxy_service.h"
+#include "net/url_request/url_request_context.h"
-#if defined(OS_ANDROID) || defined(OS_IOS)
namespace {
+// A bypass delay more than this is treated as a long delay.
+const int kLongBypassDelayInSeconds = 30 * 60;
+
+#if defined(OS_ANDROID) || defined(OS_IOS)
+
// The number of days of history stored in the content lengths prefs.
const size_t kNumDaysInHistory = 60;
@@ -54,7 +67,11 @@ void RecordDailyContentLengthHistograms(
int64 original_length_with_data_reduction_enabled,
int64 received_length_with_data_reduction_enabled,
int64 original_length_via_data_reduction_proxy,
- int64 received_length_via_data_reduction_proxy) {
+ int64 received_length_via_data_reduction_proxy,
+ int64 https_length_with_data_reduction_enabled,
+ int64 short_bypass_length_with_data_reduction_enabled,
+ int64 long_bypass_length_with_data_reduction_enabled,
+ int64 unknown_length_with_data_reduction_enabled) {
// Report daily UMA only for days having received content.
if (original_length <= 0 || received_length <= 0)
return;
@@ -100,6 +117,45 @@ void RecordDailyContentLengthHistograms(
"Net.DailyContentPercent_DataReductionProxyEnabled",
(100 * received_length_with_data_reduction_enabled) / received_length);
+ if (https_length_with_data_reduction_enabled > 0) {
+ UMA_HISTOGRAM_COUNTS(
+ "Net.DailyContentLength_DataReductionProxyEnabled_Https",
+ https_length_with_data_reduction_enabled >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Net.DailyContentPercent_DataReductionProxyEnabled_Https",
+ (100 * https_length_with_data_reduction_enabled) / received_length);
+ }
+
+ if (short_bypass_length_with_data_reduction_enabled > 0) {
+ UMA_HISTOGRAM_COUNTS(
+ "Net.DailyContentLength_DataReductionProxyEnabled_ShortBypass",
+ short_bypass_length_with_data_reduction_enabled >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Net.DailyContentPercent_DataReductionProxyEnabled_ShortBypass",
+ ((100 * short_bypass_length_with_data_reduction_enabled) /
+ received_length));
+ }
+
+ if (long_bypass_length_with_data_reduction_enabled > 0) {
+ UMA_HISTOGRAM_COUNTS(
+ "Net.DailyContentLength_DataReductionProxyEnabled_LongBypass",
+ long_bypass_length_with_data_reduction_enabled >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Net.DailyContentPercent_DataReductionProxyEnabled_LongBypass",
+ ((100 * long_bypass_length_with_data_reduction_enabled) /
+ received_length));
+ }
+
+ if (unknown_length_with_data_reduction_enabled > 0) {
+ UMA_HISTOGRAM_COUNTS(
+ "Net.DailyContentLength_DataReductionProxyEnabled_Unknown",
+ unknown_length_with_data_reduction_enabled >> 10);
+ UMA_HISTOGRAM_PERCENTAGE(
+ "Net.DailyContentPercent_DataReductionProxyEnabled_Unknown",
+ ((100 * unknown_length_with_data_reduction_enabled) /
+ received_length));
+ }
+
if (original_length_via_data_reduction_proxy <= 0 ||
received_length_via_data_reduction_proxy <= 0) {
return;
@@ -140,44 +196,72 @@ void MaintainContentLengthPrefsWindow(base::ListValue* list, size_t length) {
DCHECK_EQ(length, list->GetSize());
}
-// Update list for date change and ensure list has exactly |length| elements.
-// The last entry in each list will be for the current day after the update.
-void MaintainContentLengthPrefsForDateChange(
- base::ListValue* original_update,
- base::ListValue* received_update,
- int days_since_last_update) {
- if (days_since_last_update == -1) {
- // The system may go backwards in time by up to a day for legitimate
- // reasons, such as with changes to the time zone. In such cases, we
- // keep adding to the current day.
- // Note: we accept the fact that some reported data is shifted to
- // the adjacent day if users travel back and forth across time zones.
- days_since_last_update = 0;
- } else if (days_since_last_update < -1) {
- // Erase all entries if the system went backwards in time by more than
- // a day.
- original_update->Clear();
- received_update->Clear();
-
- days_since_last_update = kNumDaysInHistory;
+// DailyContentLengthUpdate maintains a data saving pref. The pref is a list
+// of |kNumDaysInHistory| elements of daily total content lengths for the past
+// |kNumDaysInHistory| days.
+class DailyContentLengthUpdate {
+ public:
+ DailyContentLengthUpdate(
+ const char* pref,
+ PrefService* pref_service)
+ : update_(pref_service, pref) {
}
- DCHECK_GE(days_since_last_update, 0);
-
- // Add entries for days since last update event. This will make the
- // lists longer than kNumDaysInHistory. The additional items will be cut off
- // from the head of the lists by |MaintainContentLengthPrefsWindow|, below.
- for (int i = 0;
- i < days_since_last_update && i < static_cast<int>(kNumDaysInHistory);
- ++i) {
- original_update->AppendString(base::Int64ToString(0));
- received_update->AppendString(base::Int64ToString(0));
+
+ void UpdateForDataChange(int days_since_last_update) {
+ // New empty lists may have been created. Maintain the invariant that
+ // there should be exactly |kNumDaysInHistory| days in the histories.
+ MaintainContentLengthPrefsWindow(update_.Get(), kNumDaysInHistory);
+ if (days_since_last_update) {
+ MaintainContentLengthPrefForDateChange(days_since_last_update);
+ }
}
- // Entries for new days may have been appended. Maintain the invariant that
- // there should be exactly |kNumDaysInHistory| days in the histories.
- MaintainContentLengthPrefsWindow(original_update, kNumDaysInHistory);
- MaintainContentLengthPrefsWindow(received_update, kNumDaysInHistory);
-}
+ // Update the lengths for the current day.
+ void Add(int content_length) {
+ AddInt64ToListPref(kNumDaysInHistory - 1, content_length, update_.Get());
+ }
+
+ int64 GetListPrefValue(size_t index) {
+ return ListPrefInt64Value(*update_, index);
+ }
+
+ private:
+ // Update the list for date change and ensure the list has exactly |length|
+ // elements. The last entry in the list will be for the current day after
+ // the update.
+ void MaintainContentLengthPrefForDateChange(int days_since_last_update) {
+ if (days_since_last_update == -1) {
+ // The system may go backwards in time by up to a day for legitimate
+ // reasons, such as with changes to the time zone. In such cases, we
+ // keep adding to the current day.
+ // Note: we accept the fact that some reported data is shifted to
+ // the adjacent day if users travel back and forth across time zones.
+ days_since_last_update = 0;
+ } else if (days_since_last_update < -1) {
+ // Erase all entries if the system went backwards in time by more than
+ // a day.
+ update_->Clear();
+
+ days_since_last_update = kNumDaysInHistory;
+ }
+ DCHECK_GE(days_since_last_update, 0);
+
+ // Add entries for days since last update event. This will make the
+ // lists longer than kNumDaysInHistory. The additional items will be cut off
+ // from the head of the lists by |MaintainContentLengthPrefsWindow|, below.
+ for (int i = 0;
+ i < days_since_last_update && i < static_cast<int>(kNumDaysInHistory);
+ ++i) {
+ update_->AppendString(base::Int64ToString(0));
+ }
+
+ // Entries for new days may have been appended. Maintain the invariant that
+ // there should be exactly |kNumDaysInHistory| days in the histories.
+ MaintainContentLengthPrefsWindow(update_.Get(), kNumDaysInHistory);
+ }
+
+ ListPrefUpdate update_;
+};
// DailyDataSavingUpdate maintains a pair of data saving prefs, original_update_
// and received_update_. pref_original is a list of |kNumDaysInHistory| elements
@@ -187,57 +271,147 @@ void MaintainContentLengthPrefsForDateChange(
class DailyDataSavingUpdate {
public:
DailyDataSavingUpdate(
- const char* pref_original, const char* pref_received,
+ const char* pref_original,
+ const char* pref_received,
PrefService* pref_service)
- : pref_original_(pref_original),
- pref_received_(pref_received),
- original_update_(pref_service, pref_original_),
- received_update_(pref_service, pref_received_) {
+ : original_(pref_original, pref_service),
+ received_(pref_received, pref_service) {
}
void UpdateForDataChange(int days_since_last_update) {
- // New empty lists may have been created. Maintain the invariant that
- // there should be exactly |kNumDaysInHistory| days in the histories.
- MaintainContentLengthPrefsWindow(original_update_.Get(), kNumDaysInHistory);
- MaintainContentLengthPrefsWindow(received_update_.Get(), kNumDaysInHistory);
- if (days_since_last_update) {
- MaintainContentLengthPrefsForDateChange(
- original_update_.Get(), received_update_.Get(),
- days_since_last_update);
- }
+ original_.UpdateForDataChange(days_since_last_update);
+ received_.UpdateForDataChange(days_since_last_update);
}
// Update the lengths for the current day.
void Add(int original_content_length, int received_content_length) {
- AddInt64ToListPref(
- kNumDaysInHistory - 1, original_content_length, original_update_.Get());
- AddInt64ToListPref(
- kNumDaysInHistory - 1, received_content_length, received_update_.Get());
+ original_.Add(original_content_length);
+ received_.Add(received_content_length);
}
int64 GetOriginalListPrefValue(size_t index) {
- return ListPrefInt64Value(*original_update_, index);
+ return original_.GetListPrefValue(index);
}
int64 GetReceivedListPrefValue(size_t index) {
- return ListPrefInt64Value(*received_update_, index);
+ return received_.GetListPrefValue(index);
}
private:
- const char* pref_original_;
- const char* pref_received_;
- ListPrefUpdate original_update_;
- ListPrefUpdate received_update_;
+ DailyContentLengthUpdate original_;
+ DailyContentLengthUpdate received_;
};
-} // namespace
#endif // defined(OS_ANDROID) || defined(OS_IOS)
+// Returns true if the request is bypassed by all configured data reduction
+// proxies. It returns the bypass delay in delay_seconds (if not NULL). If
+// the request is bypassed by more than one proxy, delay_seconds returns
+// shortest delay.
+bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) {
+#if defined(OS_ANDROID) || defined(OS_IOS)
+ DataReductionProxySettings::DataReductionProxyList proxies =
+ DataReductionProxySettings::GetDataReductionProxies();
+ if (proxies.size() == 0)
+ return false;
+
+ if (request == NULL || request->context() == NULL ||
+ request->context()->proxy_service() == NULL) {
+ return false;
+ }
+
+ const net::ProxyRetryInfoMap& retry_map =
+ request->context()->proxy_service()->proxy_retry_info();
+ if (retry_map.size() == 0)
+ return false;
+
+ int64 shortest_delay = 0;
+ // The request is bypassed if all configured proxies are in the retry map.
+ for (size_t i = 0; i < proxies.size(); ++i) {
+ std::string proxy = net::HostPortPair::FromURL(proxies[i]).ToString();
+ // The retry list has the scheme prefix for https but not for http.
+ if (proxies[i].SchemeIs(content::kHttpsScheme))
+ proxy = std::string(content::kHttpsScheme) + "://" + proxy;
+
+ net::ProxyRetryInfoMap::const_iterator found = retry_map.find(proxy);
+ if (found == retry_map.end())
+ return false;
+ if (shortest_delay == 0 ||
+ shortest_delay > found->second.current_delay.InSeconds()) {
+ shortest_delay = found->second.current_delay.InSeconds();
+ }
+ }
+ if (delay_seconds != NULL)
+ *delay_seconds = shortest_delay;
+ return true;
+#else
+ return false;
+#endif // defined(OS_ANDROID) || defined(OS_IOS)
+}
+
+// IsDataReductionProxyReponse returns true if response_headers contains the
+// data reduction proxy Via header value.
+bool IsDataReductionProxyReponse(
+ const net::HttpResponseHeaders* response_headers) {
+ const char kDatReductionProxyViaValue[] = "1.1 Chrome Compression Proxy";
+ size_t value_len = strlen(kDatReductionProxyViaValue);
+ void* iter = NULL;
+ std::string temp;
+ while (response_headers->EnumerateHeader(&iter, "Via", &temp)) {
+ string::const_iterator it =
+ std::search(temp.begin(),
+ temp.end(),
+ kDatReductionProxyViaValue,
+ kDatReductionProxyViaValue + value_len,
+ base::CaseInsensitiveCompareASCII<char>());
+ if (it != temp.end()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+
namespace chrome_browser_net {
+DataReductionRequestType GetDataReductionRequestType(
+ const Profile* profile, const net::URLRequest* request) {
+ if (profile != NULL && profile->IsOffTheRecord())
+ return OFF_THE_RECORD;
+ if (request->url().SchemeIs(content::kHttpsScheme))
+ return HTTPS;
+ if (!request->url().SchemeIs(content::kHttpScheme)) {
+ NOTREACHED();
+ return UNKNOWN_TYPE;
+ }
+ int64 bypass_delay = 0;
+ if (IsBypassRequest(request, &bypass_delay)) {
+ return (bypass_delay > kLongBypassDelayInSeconds) ?
+ LONG_BYPASS : SHORT_BYPASS;
+ }
+ return IsDataReductionProxyReponse(request->response_info().headers) ?
+ VIA_DATA_REDUCTION_PROXY: UNKNOWN_TYPE;
+}
+
+int64 GetAdjustedOriginalContentLength(
+ DataReductionRequestType data_reduction_type,
+ int64 original_content_length,
+ int64 received_content_length) {
+ // Since there was no indication of the original content length, presume
+ // it is no different from the number of bytes read.
+ if (original_content_length == -1 ||
+ data_reduction_type != chrome_browser_net::VIA_DATA_REDUCTION_PROXY) {
+ return received_content_length;
+ }
+ return original_content_length;
+}
+
#if defined(OS_ANDROID) || defined(OS_IOS)
void UpdateContentLengthPrefsForDataReductionProxy(
- int received_content_length, int original_content_length,
- bool with_data_reduction_proxy_enabled, bool via_data_reduction_proxy,
+ int received_content_length,
+ int original_content_length,
+ bool with_data_reduction_proxy_enabled,
+ DataReductionRequestType data_reduction_type,
base::Time now, PrefService* prefs) {
// TODO(bengr): Remove this check once the underlying cause of
// http://crbug.com/287821 is fixed. For now, only continue if the current
@@ -282,14 +456,47 @@ void UpdateContentLengthPrefsForDataReductionProxy(
prefs);
via_proxy.UpdateForDataChange(days_since_last_update);
+ DailyContentLengthUpdate https(
+ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled, prefs);
+ https.UpdateForDataChange(days_since_last_update);
+
+ DailyContentLengthUpdate short_bypass(
+ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled,
+ prefs);
+ short_bypass.UpdateForDataChange(days_since_last_update);
+
+ DailyContentLengthUpdate long_bypass(
+ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled, prefs);
+ long_bypass.UpdateForDataChange(days_since_last_update);
+
+ DailyContentLengthUpdate unknown(
+ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled, prefs);
+ unknown.UpdateForDataChange(days_since_last_update);
+
total.Add(original_content_length, received_content_length);
if (with_data_reduction_proxy_enabled) {
proxy_enabled.Add(original_content_length, received_content_length);
- // Ignore cases, if exist, when
- // "with_data_reduction_proxy_enabled == false", and
- // "via_data_reduction_proxy == true"
- if (via_data_reduction_proxy) {
- via_proxy.Add(original_content_length, received_content_length);
+ // Ignore data source cases, if exist, when
+ // "with_data_reduction_proxy_enabled == false"
+ switch (data_reduction_type) {
+ case VIA_DATA_REDUCTION_PROXY:
+ via_proxy.Add(original_content_length, received_content_length);
+ break;
+ case OFF_THE_RECORD:
+ // We don't measure off-the-record data.
+ break;
+ case HTTPS:
+ https.Add(received_content_length);
+ break;
+ case SHORT_BYPASS:
+ short_bypass.Add(received_content_length);
+ break;
+ case LONG_BYPASS:
+ long_bypass.Add(received_content_length);
+ break;
+ case UNKNOWN_TYPE:
+ unknown.Add(received_content_length);
+ break;
}
}
@@ -304,21 +511,28 @@ void UpdateContentLengthPrefsForDataReductionProxy(
// associated with an accurate date.
if (days_since_last_update == 1) {
// The previous day's data point is the second one from the tail.
+ // Therefore (kNumDaysInHistory - 2) below.
RecordDailyContentLengthHistograms(
total.GetOriginalListPrefValue(kNumDaysInHistory - 2),
total.GetReceivedListPrefValue(kNumDaysInHistory - 2),
proxy_enabled.GetOriginalListPrefValue(kNumDaysInHistory - 2),
proxy_enabled.GetReceivedListPrefValue(kNumDaysInHistory - 2),
via_proxy.GetOriginalListPrefValue(kNumDaysInHistory - 2),
- via_proxy.GetReceivedListPrefValue(kNumDaysInHistory - 2));
+ via_proxy.GetReceivedListPrefValue(kNumDaysInHistory - 2),
+ https.GetListPrefValue(kNumDaysInHistory - 2),
+ short_bypass.GetListPrefValue(kNumDaysInHistory - 2),
+ long_bypass.GetListPrefValue(kNumDaysInHistory - 2),
+ unknown.GetListPrefValue(kNumDaysInHistory - 2));
}
}
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
void UpdateContentLengthPrefs(
- int received_content_length, int original_content_length,
- bool with_data_reduction_proxy_enabled, bool via_data_reduction_proxy,
+ int received_content_length,
+ int original_content_length,
+ bool with_data_reduction_proxy_enabled,
+ DataReductionRequestType data_reduction_type,
PrefService* prefs) {
int64 total_received = prefs->GetInt64(prefs::kHttpReceivedContentLength);
int64 total_original = prefs->GetInt64(prefs::kHttpOriginalContentLength);
@@ -332,7 +546,7 @@ void UpdateContentLengthPrefs(
received_content_length,
original_content_length,
with_data_reduction_proxy_enabled,
- via_data_reduction_proxy,
+ data_reduction_type,
base::Time::Now(),
prefs);
#endif // defined(OS_ANDROID) || defined(OS_IOS)
diff --git a/chrome/browser/net/chrome_network_data_saving_metrics.h b/chrome/browser/net/chrome_network_data_saving_metrics.h
index 6b7f890..2414717 100644
--- a/chrome/browser/net/chrome_network_data_saving_metrics.h
+++ b/chrome/browser/net/chrome_network_data_saving_metrics.h
@@ -7,16 +7,50 @@
#include "base/time/time.h"
+namespace net {
+class URLRequest;
+}
+
class PrefService;
+class Profile;
namespace chrome_browser_net {
+enum DataReductionRequestType {
+ VIA_DATA_REDUCTION_PROXY, // A request served by the data reduction proxy.
+
+ // Below are reasons why a request is not served by the enabled data
+ // saving proxy.
+ OFF_THE_RECORD, // An off-the-record (incognito) request, either http
+ // or https.
+ HTTPS, // An https request that is not from an off-the-record profile.
+ SHORT_BYPASS, // The client is bypassed by the proxy for a short time.
+ LONG_BYPASS, // The client is bypassed by the proxy for a long time (due
+ // to country bypass policy, for example).
+ UNKNOWN_TYPE, // Any other reason not listed above.
+};
+
+// Returns DataReductionRequestType for |request|.
+DataReductionRequestType GetDataReductionRequestType(
+ const Profile* profile,
+ const net::URLRequest* request);
+
+// Returns |received_content_length| as adjusted original content length if
+// |original_content_length| has the invalid value (-1) or |data_reduction_type|
+// is not |VIA_DATA_REDUCTION_PROXY|.
+int64 GetAdjustedOriginalContentLength(
+ DataReductionRequestType data_reduction_type,
+ int64 original_content_length,
+ int64 received_content_length);
+
#if defined(OS_ANDROID) || defined(OS_IOS)
// This is only exposed for testing. It is normally called by
// UpdateContentLengthPrefs.
void UpdateContentLengthPrefsForDataReductionProxy(
- int received_content_length, int original_content_length,
- bool with_data_reduction_proxy_enabled, bool via_data_reduction_proxy,
+ int received_content_length,
+ int original_content_length,
+ bool with_data_reduction_proxy_enabled,
+ DataReductionRequestType data_reduction_type,
base::Time now, PrefService* prefs);
#endif
@@ -25,7 +59,7 @@ void UpdateContentLengthPrefs(
int received_content_length,
int original_content_length,
bool with_data_reduction_proxy_enabled,
- bool via_data_reduction_proxy,
+ DataReductionRequestType data_reduction_type,
PrefService* prefs);
} // namespace chrome_browser_net
diff --git a/chrome/browser/net/chrome_network_data_saving_metrics_unittest.cc b/chrome/browser/net/chrome_network_data_saving_metrics_unittest.cc
index c4045a1..63562e4 100644
--- a/chrome/browser/net/chrome_network_data_saving_metrics_unittest.cc
+++ b/chrome/browser/net/chrome_network_data_saving_metrics_unittest.cc
@@ -48,6 +48,14 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test {
registry->RegisterListPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabled);
registry->RegisterListPref(
+ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
+ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled);
+ registry->RegisterListPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxy);
registry->RegisterListPref(
prefs::kDailyContentLengthViaDataReductionProxy);
@@ -65,7 +73,7 @@ TEST_F(ChromeNetworkDataSavingMetricsTest, TotalLengths) {
chrome_browser_net::UpdateContentLengthPrefs(
kReceivedLength, kOriginalLength,
- false, false, &pref_service_);
+ false, chrome_browser_net::UNKNOWN_TYPE, &pref_service_);
EXPECT_EQ(kReceivedLength,
pref_service_.GetInt64(prefs::kHttpReceivedContentLength));
EXPECT_EQ(kOriginalLength,
@@ -74,7 +82,7 @@ TEST_F(ChromeNetworkDataSavingMetricsTest, TotalLengths) {
// Record the same numbers again, and total lengths should be dobuled.
chrome_browser_net::UpdateContentLengthPrefs(
kReceivedLength, kOriginalLength,
- false, false, &pref_service_);
+ false, chrome_browser_net::UNKNOWN_TYPE, &pref_service_);
EXPECT_EQ(kReceivedLength * 2,
pref_service_.GetInt64(prefs::kHttpReceivedContentLength));
EXPECT_EQ(kOriginalLength * 2,
@@ -144,8 +152,8 @@ class ChromeNetworkDailyDataSavingMetricsTest
}
}
- // Verify all daily pref list values.
- void VerifyDailyContentLengthPrefLists(
+ // Verify all daily data saving pref list values.
+ void VerifyDailyDataSavingContentLengthPrefLists(
const int64* original_values, size_t original_count,
const int64* received_values, size_t received_count,
const int64* original_with_data_reduction_proxy_enabled_values,
@@ -178,6 +186,52 @@ class ChromeNetworkDailyDataSavingMetricsTest
received_via_data_reduction_proxy_count);
}
+ // Verify daily data saving pref for request types.
+ void VerifyDailyRequestTypeContentLengthPrefLists(
+ const int64* original_values, size_t original_count,
+ const int64* received_values, size_t received_count,
+ const int64* original_with_data_reduction_proxy_enabled_values,
+ size_t original_with_data_reduction_proxy_enabled_count,
+ const int64* received_with_data_reduction_proxy_enabled_values,
+ size_t received_with_data_reduction_proxy_count,
+ const int64* https_with_data_reduction_proxy_enabled_values,
+ size_t https_with_data_reduction_proxy_enabled_count,
+ const int64* short_bypass_with_data_reduction_proxy_enabled_values,
+ size_t short_bypass_with_data_reduction_proxy_enabled_count,
+ const int64* long_bypass_with_data_reduction_proxy_enabled_values,
+ size_t long_bypass_with_data_reduction_proxy_enabled_count,
+ const int64* unknown_with_data_reduction_proxy_enabled_values,
+ size_t unknown_with_data_reduction_proxy_enabled_count) {
+ VerifyPrefList(prefs::kDailyHttpOriginalContentLength,
+ original_values, original_count);
+ VerifyPrefList(prefs::kDailyHttpReceivedContentLength,
+ received_values, received_count);
+ VerifyPrefList(
+ prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled,
+ original_with_data_reduction_proxy_enabled_values,
+ original_with_data_reduction_proxy_enabled_count);
+ VerifyPrefList(
+ prefs::kDailyContentLengthWithDataReductionProxyEnabled,
+ received_with_data_reduction_proxy_enabled_values,
+ received_with_data_reduction_proxy_count);
+ VerifyPrefList(
+ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled,
+ https_with_data_reduction_proxy_enabled_values,
+ https_with_data_reduction_proxy_enabled_count);
+ VerifyPrefList(
+ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled,
+ short_bypass_with_data_reduction_proxy_enabled_values,
+ short_bypass_with_data_reduction_proxy_enabled_count);
+ VerifyPrefList(
+ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled,
+ long_bypass_with_data_reduction_proxy_enabled_values,
+ long_bypass_with_data_reduction_proxy_enabled_count);
+ VerifyPrefList(
+ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled,
+ unknown_with_data_reduction_proxy_enabled_values,
+ unknown_with_data_reduction_proxy_enabled_count);
+ }
+
private:
base::Time now_;
base::TimeDelta now_delta_;
@@ -191,8 +245,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, OneResponse) {
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
- VerifyDailyContentLengthPrefLists(
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original, 1, received, 1,
original, 1, received, 1);
@@ -205,67 +260,166 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) {
int64 received[] = {kReceivedLength};
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- false, false, FakeNow(), &pref_service_);
- VerifyDailyContentLengthPrefLists(
+ false, chrome_browser_net::UNKNOWN_TYPE,
+ FakeNow(), &pref_service_);
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
NULL, 0, NULL, 0, NULL, 0, NULL, 0);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, false, FakeNow(), &pref_service_);
+ true, chrome_browser_net::UNKNOWN_TYPE,
+ FakeNow(), &pref_service_);
original[0] += kOriginalLength;
received[0] += kReceivedLength;
int64 original_proxy_enabled[] = {kOriginalLength};
int64 received_proxy_enabled[] = {kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original_proxy_enabled, 1, received_proxy_enabled, 1,
NULL, 0, NULL, 0);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
original[0] += kOriginalLength;
received[0] += kReceivedLength;
original_proxy_enabled[0] += kOriginalLength;
received_proxy_enabled[0] += kReceivedLength;
int64 original_via_proxy[] = {kOriginalLength};
int64 received_via_proxy[] = {kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original_proxy_enabled, 1, received_proxy_enabled, 1,
original_via_proxy, 1, received_via_proxy, 1);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, false, FakeNow(), &pref_service_);
+ true, chrome_browser_net::UNKNOWN_TYPE, FakeNow(), &pref_service_);
original[0] += kOriginalLength;
received[0] += kReceivedLength;
original_proxy_enabled[0] += kOriginalLength;
received_proxy_enabled[0] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original_proxy_enabled, 1, received_proxy_enabled, 1,
original_via_proxy, 1, received_via_proxy, 1);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- false, false, FakeNow(), &pref_service_);
+ false, chrome_browser_net::UNKNOWN_TYPE, FakeNow(), &pref_service_);
original[0] += kOriginalLength;
received[0] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original_proxy_enabled, 1, received_proxy_enabled, 1,
original_via_proxy, 1, received_via_proxy, 1);
}
+TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) {
+ const int64 kContentLength = 200;
+ int64 received[] = {0};
+ int64 https_received[] = {0};
+ int64 total_received[] = {0};
+ int64 proxy_enabled_received[] = {0};
+
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ true, chrome_browser_net::HTTPS,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ proxy_enabled_received[0] += kContentLength;
+ https_received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1,
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 0, // short bypass
+ received, 0, // long bypass
+ received, 0); // unknown
+
+ // Data reduction proxy is not enabled.
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ false, chrome_browser_net::HTTPS,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1,
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 0, // short bypass
+ received, 0, // long bypass
+ received, 0); // unknown
+
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ true, chrome_browser_net::HTTPS,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ proxy_enabled_received[0] += kContentLength;
+ https_received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1,
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 0, // short bypass
+ received, 0, // long bypass
+ received, 0); // unknown
+
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ true, chrome_browser_net::SHORT_BYPASS,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ proxy_enabled_received[0] += kContentLength;
+ received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1,
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 1, // short bypass
+ received, 0, // long bypass
+ received, 0); // unknown
+
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ true, chrome_browser_net::LONG_BYPASS,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ proxy_enabled_received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1, // total
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 1, // short bypass
+ received, 1, // long bypass
+ received, 0); // unknown
+
+ chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
+ kContentLength, kContentLength,
+ true, chrome_browser_net::UNKNOWN_TYPE,
+ FakeNow(), &pref_service_);
+ total_received[0] += kContentLength;
+ proxy_enabled_received[0] += kContentLength;
+ VerifyDailyRequestTypeContentLengthPrefLists(
+ total_received, 1, total_received, 1,
+ proxy_enabled_received, 1, proxy_enabled_received, 1,
+ https_received, 1,
+ received, 1, // short bypass
+ received, 1, // long bypass
+ received, 1); // unknown
+}
+
TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) {
const int64 kOriginalLength = 200;
const int64 kReceivedLength = 100;
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
// Forward one day.
SetFakeTimeDeltaInHours(24);
@@ -273,7 +427,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) {
// Proxy not enabled. Not via proxy.
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- false, false, FakeNow(), &pref_service_);
+ false, chrome_browser_net::UNKNOWN_TYPE, FakeNow(), &pref_service_);
int64 original[] = {kOriginalLength, kOriginalLength};
int64 received[] = {kReceivedLength, kReceivedLength};
@@ -281,7 +435,7 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) {
int64 received_with_data_reduction_proxy_enabled[] = {kReceivedLength, 0};
int64 original_via_data_reduction_proxy[] = {kOriginalLength, 0};
int64 received_via_data_reduction_proxy[] = {kReceivedLength, 0};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 2,
received, 2,
original_with_data_reduction_proxy_enabled, 2,
@@ -292,12 +446,12 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) {
// Proxy enabled. Not via proxy.
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, false, FakeNow(), &pref_service_);
+ true, chrome_browser_net::UNKNOWN_TYPE, FakeNow(), &pref_service_);
original[1] += kOriginalLength;
received[1] += kReceivedLength;
original_with_data_reduction_proxy_enabled[1] += kOriginalLength;
received_with_data_reduction_proxy_enabled[1] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 2,
received, 2,
original_with_data_reduction_proxy_enabled, 2,
@@ -308,14 +462,15 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) {
// Proxy enabled and via proxy.
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
original[1] += kOriginalLength;
received[1] += kReceivedLength;
original_with_data_reduction_proxy_enabled[1] += kOriginalLength;
received_with_data_reduction_proxy_enabled[1] += kReceivedLength;
original_via_data_reduction_proxy[1] += kOriginalLength;
received_via_data_reduction_proxy[1] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 2,
received, 2,
original_with_data_reduction_proxy_enabled, 2,
@@ -332,8 +487,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) {
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
- VerifyDailyContentLengthPrefLists(
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 2, received, 2,
original, 2, received, 2,
original, 2, received, 2);
@@ -343,10 +499,11 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) {
SetFakeTimeDeltaInHours(10);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
original[1] += kOriginalLength;
received[1] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 2, received, 2,
original, 2, received, 2,
original, 2, received, 2);
@@ -355,10 +512,11 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) {
AddFakeTimeDeltaInHours(11);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
int64 original2[] = {kOriginalLength * 2, kOriginalLength};
int64 received2[] = {kReceivedLength * 2, kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original2, 2, received2, 2,
original2, 2, received2, 2,
original2, 2, received2, 2);
@@ -369,18 +527,20 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) {
const int64 kReceivedLength = 100;
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
// Forward three days.
SetFakeTimeDeltaInHours(3 * 24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
int64 original[] = {kOriginalLength, 0, 0, kOriginalLength};
int64 received[] = {kReceivedLength, 0, 0, kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 4, received, 4,
original, 4, received, 4,
original, 4, received, 4);
@@ -389,14 +549,15 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) {
AddFakeTimeDeltaInHours(4 * 24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
int64 original2[] = {
kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength,
};
int64 received2[] = {
kReceivedLength, 0, 0, kReceivedLength, 0, 0, 0, kReceivedLength,
};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original2, 8, received2, 8,
original2, 8, received2, 8,
original2, 8, received2, 8);
@@ -405,10 +566,11 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) {
AddFakeTimeDeltaInHours(kNumDaysInHistory * 24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
int64 original3[] = {kOriginalLength};
int64 received3[] = {kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original3, 1, received3, 1,
original3, 1, received3, 1,
original3, 1, received3, 1);
@@ -417,8 +579,9 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) {
AddFakeTimeDeltaInHours((kNumDaysInHistory + 1)* 24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
- VerifyDailyContentLengthPrefLists(
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
+ VerifyDailyDataSavingContentLengthPrefLists(
original3, 1, received3, 1,
original3, 1, received3, 1,
original3, 1, received3, 1);
@@ -432,16 +595,18 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) {
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
// Backward one day.
SetFakeTimeDeltaInHours(-24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
original[0] += kOriginalLength;
received[0] += kReceivedLength;
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original, 1, received, 1,
original, 1, received, 1);
@@ -450,10 +615,11 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) {
AddFakeTimeDeltaInHours(24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
int64 original2[] = {kOriginalLength * 2, kOriginalLength};
int64 received2[] = {kReceivedLength * 2, kReceivedLength};
- VerifyDailyContentLengthPrefLists(
+ VerifyDailyDataSavingContentLengthPrefLists(
original2, 2, received2, 2,
original2, 2, received2, 2,
original2, 2, received2, 2);
@@ -467,13 +633,15 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) {
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
// Backward two days.
SetFakeTimeDeltaInHours(-2 * 24);
chrome_browser_net::UpdateContentLengthPrefsForDataReductionProxy(
kReceivedLength, kOriginalLength,
- true, true, FakeNow(), &pref_service_);
- VerifyDailyContentLengthPrefLists(
+ true, chrome_browser_net::VIA_DATA_REDUCTION_PROXY,
+ FakeNow(), &pref_service_);
+ VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1,
original, 1, received, 1,
original, 1, received, 1);
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index e021791..240c127 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -215,9 +215,10 @@ void ForwardRequestStatus(
}
}
-void UpdateContentLengthPrefs(int received_content_length,
- int original_content_length,
- bool via_data_reduction_proxy) {
+void UpdateContentLengthPrefs(
+ int received_content_length,
+ int original_content_length,
+ chrome_browser_net::DataReductionRequestType data_reduction_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0);
@@ -242,16 +243,17 @@ void UpdateContentLengthPrefs(int received_content_length,
received_content_length,
original_content_length,
with_data_reduction_proxy_enabled,
- via_data_reduction_proxy, prefs);
+ data_reduction_type, prefs);
}
-void StoreAccumulatedContentLength(int received_content_length,
- int original_content_length,
- bool data_reduction_proxy_was_used) {
+void StoreAccumulatedContentLength(
+ int received_content_length,
+ int original_content_length,
+ chrome_browser_net::DataReductionRequestType data_reduction_type) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&UpdateContentLengthPrefs,
received_content_length, original_content_length,
- data_reduction_proxy_was_used));
+ data_reduction_type));
}
void RecordContentLengthHistograms(
@@ -525,21 +527,20 @@ void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
int64 original_content_length =
request->response_info().headers->GetInt64HeaderValue(
"x-original-content-length");
- bool via_data_reduction_proxy =
- request->response_info().headers->HasHeaderValue(
- "via", "1.1 Chrome Compression Proxy");
-
- // Since there was no indication of the original content length, presume
- // it is no different from the number of bytes read.
- int64 adjusted_original_content_length = original_content_length;
- if (adjusted_original_content_length == -1)
- adjusted_original_content_length = received_content_length;
+ chrome_browser_net::DataReductionRequestType data_reduction_type =
+ chrome_browser_net::GetDataReductionRequestType(
+ reinterpret_cast<Profile*>(profile_), request);
+
base::TimeDelta freshness_lifetime =
request->response_info().headers->GetFreshnessLifetime(
request->response_info().response_time);
+ int64 adjusted_original_content_length =
+ chrome_browser_net::GetAdjustedOriginalContentLength(
+ data_reduction_type, original_content_length,
+ received_content_length);
AccumulateContentLength(received_content_length,
adjusted_original_content_length,
- via_data_reduction_proxy);
+ data_reduction_type);
RecordContentLengthHistograms(received_content_length,
original_content_length,
freshness_lifetime);
@@ -759,12 +760,12 @@ void ChromeNetworkDelegate::OnRequestWaitStateChange(
void ChromeNetworkDelegate::AccumulateContentLength(
int64 received_content_length, int64 original_content_length,
- bool via_data_reduction_proxy) {
+ chrome_browser_net::DataReductionRequestType data_reduction_type) {
DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0);
StoreAccumulatedContentLength(received_content_length,
original_content_length,
- via_data_reduction_proxy);
+ data_reduction_type);
received_content_length_ += received_content_length;
original_content_length_ += original_content_length;
}
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index 84f5d09..6d268b6 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
+#include "chrome/browser/net/chrome_network_data_saving_metrics.h"
#include "net/base/network_delegate.h"
class ClientHints;
@@ -181,7 +182,7 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
void AccumulateContentLength(
int64 received_payload_byte_count, int64 original_payload_byte_count,
- bool data_reduction_proxy_was_used);
+ chrome_browser_net::DataReductionRequestType data_reduction_type);
scoped_refptr<extensions::EventRouterForwarder> event_router_;
void* profile_;
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 1144e72..6bb3d91 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -2065,6 +2065,19 @@ const char kDailyOriginalContentLengthWithDataReductionProxyEnabled[] =
const char kDailyContentLengthWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_with_data_reduction_proxy_enabled";
+const char kDailyContentLengthHttpsWithDataReductionProxyEnabled[] =
+ "data_reduction.daily_received_length_https_with_"
+ "data_reduction_proxy_enabled";
+const char kDailyContentLengthShortBypassWithDataReductionProxyEnabled[] =
+ "data_reduction.daily_received_length_short_bypass_with_"
+ "data_reduction_proxy_enabled";
+const char kDailyContentLengthLongBypassWithDataReductionProxyEnabled[] =
+ "data_reduction.daily_received_length_long_bypass_with_"
+ "data_reduction_proxy_enabled";
+const char kDailyContentLengthUnknownWithDataReductionProxyEnabled[] =
+ "data_reduction.daily_received_length_unknown_with_"
+ "data_reduction_proxy_enabled";
+
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// that was received via the data reduction proxy.
const char kDailyOriginalContentLengthViaDataReductionProxy[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 12ee71c..a47c283 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -807,6 +807,10 @@ extern const char kDailyHttpOriginalContentLength[];
extern const char kDailyHttpReceivedContentLength[];
extern const char kDailyOriginalContentLengthWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthWithDataReductionProxyEnabled[];
+extern const char kDailyContentLengthHttpsWithDataReductionProxyEnabled[];
+extern const char kDailyContentLengthShortBypassWithDataReductionProxyEnabled[];
+extern const char kDailyContentLengthLongBypassWithDataReductionProxyEnabled[];
+extern const char kDailyContentLengthUnknownWithDataReductionProxyEnabled[];
extern const char kDailyOriginalContentLengthViaDataReductionProxy[];
extern const char kDailyContentLengthViaDataReductionProxy[];
extern const char kDailyHttpContentLengthLastUpdateDate[];
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index faa942f..8a23b401 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -7755,6 +7755,46 @@ other types of suffix sets.
</summary>
</histogram>
+<histogram name="Net.DailyContentLength_DataReductionProxyEnabled_Https"
+ units="KB">
+ <summary>
+ The total content size in KB of all HTTPS response bodies in the previous
+ calendar day while the data reduction proxy setting was enabled. The metric
+ is reported when the first response in the current day is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentLength_DataReductionProxyEnabled_LongBypass"
+ units="KB">
+ <summary>
+ The total content size in KB of all long-bypassed HTTP response bodies in
+ the previous calendar day while the data reduction proxy setting was
+ enabled. The metric is reported when the first response in the current day
+ is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentLength_DataReductionProxyEnabled_ShortBypass"
+ units="KB">
+ <summary>
+ The total content size in KB of all short-bypassed HTTP response bodies in
+ the previous calendar day while the data reduction proxy setting was
+ enabled. The metric is reported when the first response in the current day
+ is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentLength_DataReductionProxyEnabled_Unknown"
+ units="KB">
+ <summary>
+ The total content size in KB of all HTTP response bodies for requests that
+ were not served by the enabled data reduction proxy for unknown reasons in
+ the previous calendar day while the data reduction proxy setting was
+ enabled. The metric is reported when the first response in the current day
+ is received.
+ </summary>
+</histogram>
+
<histogram name="Net.DailyContentLength_ViaDataReductionProxy" units="KB">
<summary>
The total content size in KB of all HTTP/HTTPS response bodies in the
@@ -7773,6 +7813,47 @@ other types of suffix sets.
</summary>
</histogram>
+<histogram name="Net.DailyContentPercent_DataReductionProxyEnabled_Https"
+ units="Percent">
+ <summary>
+ The percentage of total HTTPS response body size while the data reduction
+ proxy is enabled to total HTTP/HTTPS response body size in the previous
+ calendar day. The metric is reported when the first response in the current
+ day is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentPercent_DataReductionProxyEnabled_LongBypass"
+ units="Percent">
+ <summary>
+ The percentage of total long-bypassed response body size while the data
+ reduction proxy is enabled to total HTTP/HTTPS response body size in the
+ previous calendar day. The metric is reported when the first response in the
+ current day is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentPercent_DataReductionProxyEnabled_ShortBypass"
+ units="Percent">
+ <summary>
+ The percentage of total short-bypassed response body size while the data
+ reduction proxy is enabled to total HTTP/HTTPS response body size in the
+ previous calendar day. The metric is reported when the first response in the
+ current day is received.
+ </summary>
+</histogram>
+
+<histogram name="Net.DailyContentPercent_DataReductionProxyEnabled_Unknown"
+ units="Percent">
+ <summary>
+ The percentage of total body size of responses that were not served by the
+ data reduction proxy for unknown reason while the data reduction proxy is
+ enabled to total HTTP/HTTPS response body size in the previous calendar day.
+ The metric is reported when the first response in the current day is
+ received.
+ </summary>
+</histogram>
+
<histogram name="Net.DailyContentPercent_ViaDataReductionProxy" units="Percent">
<summary>
The percentage of total HTTP/HTTPS response body size via the data reduction