Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc

Issue 1406993010: Crop urls in Data Saver feedback reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test 4 minutes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc
index 4bc17d0f9fd7a63b252993c43d3918992881b109..9534a301ca60e5ddee643b746a96129d1314e149 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc
@@ -4,11 +4,14 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h"
+#include <stdint.h>
+
#include <vector>
#include "base/basictypes.h"
#include "base/json/json_writer.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -18,6 +21,10 @@ namespace {
const size_t kMaxEventsToStore = 100;
+// Used by Data Reduction Proxy feedback reports. If the last bypass happened in
+// the last 5 minutes, the url will be cropped to only the host.
+const int kLastBypassTimeDeltaInMinutes = 5;
+
struct StringToConstant {
const char* name;
const int constant;
@@ -239,9 +246,6 @@ std::string DataReductionProxyEventStore::SanitizedLastBypassEvent() const {
std::string str_value;
int int_value;
- if (bypass_dict->GetString("time", &str_value))
- last_bypass->SetString("bypass_time", str_value);
-
if (params_dict->GetInteger("bypass_type", &int_value))
last_bypass->SetInteger("bypass_type", int_value);
@@ -251,12 +255,34 @@ std::string DataReductionProxyEventStore::SanitizedLastBypassEvent() const {
if (params_dict->GetString("bypass_duration_seconds", &str_value))
last_bypass->SetString("bypass_seconds", str_value);
+ bool truncate_url_to_host = true;
+ if (bypass_dict->GetString("time", &str_value)) {
+ last_bypass->SetString("bypass_time", str_value);
+
+ int64_t bypass_ticks_ms;
+ base::StringToInt64(str_value, &bypass_ticks_ms);
+
+ base::TimeTicks bypass_ticks =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(bypass_ticks_ms);
+
+ // If the last bypass happened in the last 5 minutes, don't crop the url to
+ // the host.
+ if (base::TimeTicks::Now() - bypass_ticks <
+ base::TimeDelta::FromMinutes(kLastBypassTimeDeltaInMinutes)) {
+ truncate_url_to_host = false;
+ }
+ }
+
if (params_dict->GetString("url", &str_value)) {
GURL url(str_value);
- GURL::Replacements replacements;
- replacements.ClearQuery();
- GURL clean_url = url.ReplaceComponents(replacements);
- last_bypass->SetString("url", clean_url.spec());
+ if (truncate_url_to_host) {
+ last_bypass->SetString("url", url.host());
+ } else {
+ GURL::Replacements replacements;
+ replacements.ClearQuery();
+ GURL clean_url = url.ReplaceComponents(replacements);
+ last_bypass->SetString("url", clean_url.spec());
+ }
}
std::string json;
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698