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

Side by Side Diff: components/domain_reliability/beacon.cc

Issue 1180223006: Domain Reliability: Simplify configs and reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new configs Created 5 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/domain_reliability/beacon.h" 5 #include "components/domain_reliability/beacon.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/domain_reliability/util.h"
8 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
9 10
10 namespace domain_reliability { 11 namespace domain_reliability {
11 12
12 using base::Value; 13 using base::Value;
13 using base::DictionaryValue; 14 using base::DictionaryValue;
14 15
16 DomainReliabilityBeacon::ReportParams::ReportParams(
17 base::TimeTicks upload_time,
18 base::TimeTicks last_network_change_time,
19 const GURL& collector_url,
20 const ScopedVector<std::string>& path_prefixes)
21 : upload_time(upload_time),
22 last_network_change_time(last_network_change_time),
23 collector_url(collector_url),
24 path_prefixes(path_prefixes) {
25 }
26
15 DomainReliabilityBeacon::DomainReliabilityBeacon() {} 27 DomainReliabilityBeacon::DomainReliabilityBeacon() {}
16 DomainReliabilityBeacon::~DomainReliabilityBeacon() {} 28 DomainReliabilityBeacon::~DomainReliabilityBeacon() {}
17 29
18 Value* DomainReliabilityBeacon::ToValue( 30 Value* DomainReliabilityBeacon::ToValue(
19 base::TimeTicks upload_time, 31 const ReportParams& report_params) const {
20 base::TimeTicks last_network_change_time) const {
21 DictionaryValue* beacon_value = new DictionaryValue(); 32 DictionaryValue* beacon_value = new DictionaryValue();
22 if (!url.empty()) 33 DCHECK(url.is_valid());
23 beacon_value->SetString("url", url); 34 GURL sanitized_url = SanitizeURLForReport(url, report_params.collector_url,
24 if (!domain.empty()) 35 report_params.path_prefixes);
25 beacon_value->SetString("domain", domain); 36 beacon_value->SetString("url", sanitized_url.spec());
26 if (!resource.empty())
27 beacon_value->SetString("resource", resource);
28 beacon_value->SetString("status", status); 37 beacon_value->SetString("status", status);
29 if (chrome_error != net::OK) { 38 if (chrome_error != net::OK) {
30 DictionaryValue* failure_value = new DictionaryValue(); 39 DictionaryValue* failure_value = new DictionaryValue();
31 failure_value->SetString("custom_error", 40 failure_value->SetString("custom_error",
32 net::ErrorToString(chrome_error)); 41 net::ErrorToString(chrome_error));
33 beacon_value->Set("failure_data", failure_value); 42 beacon_value->Set("failure_data", failure_value);
34 } 43 }
35 beacon_value->SetString("server_ip", server_ip); 44 beacon_value->SetString("server_ip", server_ip);
36 beacon_value->SetBoolean("was_proxied", was_proxied); 45 beacon_value->SetBoolean("was_proxied", was_proxied);
37 beacon_value->SetString("protocol", protocol); 46 beacon_value->SetString("protocol", protocol);
38 if (http_response_code >= 0) 47 if (http_response_code >= 0)
39 beacon_value->SetInteger("http_response_code", http_response_code); 48 beacon_value->SetInteger("http_response_code", http_response_code);
40 beacon_value->SetInteger("request_elapsed_ms", 49 beacon_value->SetInteger("request_elapsed_ms", elapsed.InMilliseconds());
41 elapsed.InMilliseconds()); 50 base::TimeDelta request_age = report_params.upload_time - start_time;
42 beacon_value->SetInteger("request_age_ms", 51 beacon_value->SetInteger("request_age_ms", request_age.InMilliseconds());
43 (upload_time - start_time).InMilliseconds()); 52 bool network_changed = report_params.last_network_change_time > start_time;
44 bool network_changed = last_network_change_time > start_time;
45 beacon_value->SetBoolean("network_changed", network_changed); 53 beacon_value->SetBoolean("network_changed", network_changed);
46 return beacon_value; 54 return beacon_value;
47 } 55 }
48 56
49 } // namespace domain_reliability 57 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698