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