Commit deb75386 authored by bengr@chromium.org's avatar bengr@chromium.org

Collect data reduction proxy UMA on all platforms

UMA for the data reduction proxy was gated behind preprocessor
directives that resticted the logic to Android and iOS. This
change opens UMA calculations and collection up to all platforms.

BUG=369619

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=269026

Review URL: https://codereview.chromium.org/266033002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269670 0039d316-1c4b-4281-b951-d872f2087c98
parent 11f57082
......@@ -275,7 +275,6 @@ void RecordContentLengthHistograms(
int64 received_content_length,
int64 original_content_length,
const base::TimeDelta& freshness_lifetime) {
#if defined(OS_ANDROID)
// Add the current resource to these histograms only when a valid
// X-Original-Content-Length header is present.
if (original_content_length >= 0) {
......@@ -313,7 +312,6 @@ void RecordContentLengthHistograms(
return;
UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable24Hours",
received_content_length);
#endif // defined(OS_ANDROID)
}
#if defined(OS_ANDROID)
......
......@@ -24,6 +24,7 @@
#include "content/public/renderer/render_view.h"
#include "extensions/common/url_pattern.h"
#include "net/base/url_util.h"
#include "net/http/http_response_headers.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebDocument.h"
......@@ -32,10 +33,6 @@
#include "third_party/WebKit/public/web/WebView.h"
#include "url/gurl.h"
#if defined(SPDY_PROXY_AUTH_ORIGIN)
#include "net/http/http_response_headers.h"
#endif
using blink::WebDataSource;
using blink::WebFrame;
using blink::WebPerformance;
......@@ -199,7 +196,6 @@ bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) {
// TODO(bengr): Plumb the hostname of the proxy and check if it matches
// |SPDY_PROXY_AUTH_ORIGIN|.
bool DataReductionProxyWasUsed(WebFrame* frame) {
#if defined(SPDY_PROXY_AUTH_ORIGIN)
DocumentState* document_state =
DocumentState::FromDataSource(frame->dataSource());
if (!document_state->was_fetched_via_proxy())
......@@ -216,9 +212,6 @@ bool DataReductionProxyWasUsed(WebFrame* frame) {
scoped_refptr<net::HttpResponseHeaders> response_headers(
new net::HttpResponseHeaders(headers));
return response_headers->IsDataReductionProxyResponse();
#else
return false;
#endif
}
// Returns true if the provided URL is a referrer string that came from
......
......@@ -24,8 +24,6 @@ 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)
// Increments an int64, stored as a string, in a ListPref at the specified
// index. The value must already exist and be a string representation of a
// number.
......@@ -298,14 +296,11 @@ class DailyDataSavingUpdate {
DailyContentLengthUpdate received_;
};
#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)
......@@ -340,9 +335,6 @@ bool IsBypassRequest(const net::URLRequest* request, int64* delay_seconds) {
if (delay_seconds != NULL)
*delay_seconds = shortest_delay;
return true;
#else
return false;
#endif // defined(OS_ANDROID) || defined(OS_IOS)
}
} // namespace
......@@ -360,12 +352,10 @@ DataReductionProxyRequestType GetDataReductionProxyRequestType(
return (bypass_delay > kLongBypassDelayInSeconds) ?
LONG_BYPASS : SHORT_BYPASS;
}
#if defined(SPDY_PROXY_AUTH_ORIGIN)
if (request->response_info().headers &&
request->response_info().headers->IsDataReductionProxyResponse()) {
return VIA_DATA_REDUCTION_PROXY;
}
#endif
return UNKNOWN_TYPE;
}
......@@ -382,7 +372,6 @@ int64 GetAdjustedOriginalContentLength(
return original_content_length;
}
#if defined(OS_ANDROID) || defined(OS_IOS)
void UpdateContentLengthPrefsForDataReductionProxy(
int received_content_length,
int original_content_length,
......@@ -403,10 +392,20 @@ void UpdateContentLengthPrefsForDataReductionProxy(
// Determine how many days it has been since the last update.
int64 then_internal = prefs->GetInt64(
data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate);
#if defined(OS_WIN)
base::Time then_midnight = base::Time::FromInternalValue(then_internal);
base::Time midnight =
base::Time::FromInternalValue(
(now.ToInternalValue() / base::Time::kMicrosecondsPerDay) *
base::Time::kMicrosecondsPerDay);
#else
// Local midnight could have been shifted due to time zone change.
base::Time then_midnight =
base::Time::FromInternalValue(then_internal).LocalMidnight();
base::Time midnight = now.LocalMidnight();
#endif
int days_since_last_update = (midnight - then_midnight).InDays();
// Each day, we calculate the total number of bytes received and the total
......@@ -511,7 +510,6 @@ void UpdateContentLengthPrefsForDataReductionProxy(
}
}
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
void UpdateContentLengthPrefs(
int received_content_length,
......@@ -530,7 +528,6 @@ void UpdateContentLengthPrefs(
prefs->SetInt64(data_reduction_proxy::prefs::kHttpOriginalContentLength,
total_original);
#if defined(OS_ANDROID) || defined(OS_IOS)
UpdateContentLengthPrefsForDataReductionProxy(
received_content_length,
original_content_length,
......@@ -538,8 +535,6 @@ void UpdateContentLengthPrefs(
request_type,
base::Time::Now(),
prefs);
#endif // defined(OS_ANDROID) || defined(OS_IOS)
}
} // namespace data_reduction_proxy
......@@ -39,8 +39,6 @@ int64 GetAdjustedOriginalContentLength(
int64 original_content_length,
int64 received_content_length);
#if defined(OS_ANDROID) || defined(OS_IOS)
// TODO(bengr): Remove platform-specific ifdefs.
// This is only exposed for testing. It is normally called by
// UpdateContentLengthPrefs.
void UpdateContentLengthPrefsForDataReductionProxy(
......@@ -49,7 +47,6 @@ void UpdateContentLengthPrefsForDataReductionProxy(
bool with_data_reduction_proxy_enabled,
DataReductionProxyRequestType request_type,
base::Time now, PrefService* prefs);
#endif
// Records daily data savings statistics to prefs and reports data savings UMA.
void UpdateContentLengthPrefs(
......
......@@ -15,7 +15,6 @@
namespace {
#if defined(OS_ANDROID) || defined(OS_IOS)
const size_t kNumDaysInHistory = 60;
int64 GetListPrefInt64Value(
......@@ -28,8 +27,6 @@ int64 GetListPrefInt64Value(
return value;
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
} // namespace
namespace data_reduction_proxy {
......@@ -46,7 +43,6 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test {
registry->RegisterInt64Pref(
data_reduction_proxy::prefs::kHttpOriginalContentLength, 0);
#if defined(OS_ANDROID) || defined(OS_IOS)
registry->RegisterListPref(data_reduction_proxy::prefs::
kDailyHttpOriginalContentLength);
registry->RegisterListPref(data_reduction_proxy::prefs::
......@@ -78,7 +74,6 @@ class ChromeNetworkDataSavingMetricsTest : public testing::Test {
registry->RegisterInt64Pref(
data_reduction_proxy::prefs::
kDailyHttpContentLengthLastUpdateDate, 0L);
#endif // defined(OS_ANDROID) || defined(OS_IOS)
}
TestingPrefServiceSimple pref_service_;
......@@ -110,8 +105,6 @@ TEST_F(ChromeNetworkDataSavingMetricsTest, TotalLengths) {
data_reduction_proxy::prefs::kHttpOriginalContentLength));
}
#if defined(OS_ANDROID) || defined(OS_IOS)
// The initial last update time used in test. There is no leap second a few
// days around this time used in the test.
// Note: No time zone is specified. Local time will be assumed by
......@@ -679,6 +672,5 @@ TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) {
original, 1, received, 1,
original, 1, received, 1);
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
} // namespace data_reduction_proxy
......@@ -35,7 +35,6 @@ void RegisterPrefs(PrefRegistrySimple* registry) {
prefs::kHttpReceivedContentLength, 0);
registry->RegisterInt64Pref(
prefs::kHttpOriginalContentLength, 0);
#if defined(OS_ANDROID) || defined(OS_IOS)
registry->RegisterListPref(
prefs::kDailyHttpOriginalContentLength);
registry->RegisterListPref(
......@@ -58,7 +57,6 @@ void RegisterPrefs(PrefRegistrySimple* registry) {
prefs::kDailyContentLengthViaDataReductionProxy);
registry->RegisterInt64Pref(
prefs::kDailyHttpContentLengthLastUpdateDate, 0L);
#endif
}
} // namespace data_reduction_proxy
......@@ -1451,6 +1451,7 @@ bool HttpResponseHeaders::GetDataReductionProxyInfo(
}
return false;
}
#endif // SPDY_PROXY_AUTH_ORIGIN
bool HttpResponseHeaders::IsDataReductionProxyResponse() const {
const size_t kVersionSize = 4;
......@@ -1479,6 +1480,7 @@ bool HttpResponseHeaders::IsDataReductionProxyResponse() const {
return false;
}
#if defined(SPDY_PROXY_AUTH_ORIGIN)
ProxyService::DataReductionProxyBypassEventType
HttpResponseHeaders::GetDataReductionProxyBypassEventType(
DataReductionProxyInfo* data_reduction_proxy_info) const {
......
......@@ -294,11 +294,11 @@ class NET_EXPORT HttpResponseHeaders
ProxyService::DataReductionProxyBypassEventType
GetDataReductionProxyBypassEventType(
DataReductionProxyInfo* proxy_info) const;
#endif
// Returns true if response headers contain the data reduction proxy Via
// header value.
bool IsDataReductionProxyResponse() const;
#endif
// Creates a Value for use with the NetLog containing the response headers.
base::Value* NetLogCallback(NetLog::LogLevel log_level) const;
......
......@@ -2107,6 +2107,7 @@ TEST(HttpResponseHeadersTest, GetProxyBypassInfo) {
data_reduction_proxy_info.bypass_all);
}
}
#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
TEST(HttpResponseHeadersTest, IsDataReductionProxyResponse) {
const struct {
......@@ -2182,6 +2183,7 @@ TEST(HttpResponseHeadersTest, IsDataReductionProxyResponse) {
}
}
#if defined(SPDY_PROXY_AUTH_ORIGIN)
TEST(HttpResponseHeadersTest, GetDataReductionProxyBypassEventType) {
const struct {
const char* headers;
......
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