summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 16:14:00 +0000
committerbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 16:14:00 +0000
commitb8fd01d79982e6f9651207f5ecb4995272770685 (patch)
tree74fada9fdae31136d36a50cf4b10afaf1ecf2fee
parent9452273017da636854aa46a54ef9d7dd88821dcc (diff)
downloadchromium_src-b8fd01d79982e6f9651207f5ecb4995272770685.zip
chromium_src-b8fd01d79982e6f9651207f5ecb4995272770685.tar.gz
chromium_src-b8fd01d79982e6f9651207f5ecb4995272770685.tar.bz2
Merge 269670 "Collect data reduction proxy UMA on all platforms"
> 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 TBR=bengr@chromium.org Review URL: https://codereview.chromium.org/288173005 git-svn-id: svn://svn.chromium.org/chrome/branches/1985/src@270680 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc2
-rw-r--r--chrome/renderer/page_load_histograms.cc9
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc25
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h3
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc8
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc2
-rw-r--r--net/http/http_response_headers.cc2
-rw-r--r--net/http/http_response_headers.h2
-rw-r--r--net/http/http_response_headers_unittest.cc2
9 files changed, 16 insertions, 39 deletions
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index b580265..1cab93d 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -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)
diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc
index 87a9252..1b60fac 100644
--- a/chrome/renderer/page_load_histograms.cc
+++ b/chrome/renderer/page_load_histograms.cc
@@ -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
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
index f673a20..3ecef8a 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
@@ -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
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
index 0e4cab2..b308742 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h
@@ -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(
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc
index f5e24f3..f113977 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc
@@ -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
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc
index 1d25a51..ee90c2e 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc
@@ -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
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index 940c048..7ecf37a 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -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 {
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h
index 2bf4514..37be9c3 100644
--- a/net/http/http_response_headers.h
+++ b/net/http/http_response_headers.h
@@ -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;
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc
index fe656e6..c9c8c46 100644
--- a/net/http/http_response_headers_unittest.cc
+++ b/net/http/http_response_headers_unittest.cc
@@ -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;