OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/domain_reliability/util.h" | 10 #include "components/domain_reliability/util.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 | 12 |
13 namespace domain_reliability { | 13 namespace domain_reliability { |
14 | 14 |
15 using base::Value; | 15 using base::Value; |
16 using base::DictionaryValue; | 16 using base::DictionaryValue; |
17 | 17 |
18 DomainReliabilityBeacon::DomainReliabilityBeacon() {} | 18 DomainReliabilityBeacon::DomainReliabilityBeacon() {} |
19 DomainReliabilityBeacon::DomainReliabilityBeacon( | 19 DomainReliabilityBeacon::DomainReliabilityBeacon( |
20 const DomainReliabilityBeacon& other) = default; | 20 const DomainReliabilityBeacon& other) = default; |
21 DomainReliabilityBeacon::~DomainReliabilityBeacon() {} | 21 DomainReliabilityBeacon::~DomainReliabilityBeacon() {} |
22 | 22 |
23 std::unique_ptr<Value> DomainReliabilityBeacon::ToValue( | 23 std::unique_ptr<Value> DomainReliabilityBeacon::ToValue( |
24 base::TimeTicks upload_time, | 24 base::TimeTicks upload_time, |
25 base::TimeTicks last_network_change_time, | 25 base::TimeTicks last_network_change_time, |
26 const GURL& collector_url, | 26 const GURL& collector_url, |
27 const ScopedVector<std::string>& path_prefixes) const { | 27 const std::vector<std::unique_ptr<std::string>>& path_prefixes) const { |
28 std::unique_ptr<DictionaryValue> beacon_value(new DictionaryValue()); | 28 std::unique_ptr<DictionaryValue> beacon_value(new DictionaryValue()); |
29 DCHECK(url.is_valid()); | 29 DCHECK(url.is_valid()); |
30 GURL sanitized_url = SanitizeURLForReport(url, collector_url, path_prefixes); | 30 GURL sanitized_url = SanitizeURLForReport(url, collector_url, path_prefixes); |
31 beacon_value->SetString("url", sanitized_url.spec()); | 31 beacon_value->SetString("url", sanitized_url.spec()); |
32 beacon_value->SetString("status", status); | 32 beacon_value->SetString("status", status); |
33 if (!quic_error.empty()) | 33 if (!quic_error.empty()) |
34 beacon_value->SetString("quic_error", quic_error); | 34 beacon_value->SetString("quic_error", quic_error); |
35 if (chrome_error != net::OK) { | 35 if (chrome_error != net::OK) { |
36 DictionaryValue* failure_value = new DictionaryValue(); | 36 DictionaryValue* failure_value = new DictionaryValue(); |
37 failure_value->SetString("custom_error", | 37 failure_value->SetString("custom_error", |
(...skipping 13 matching lines...) Expand all Loading... |
51 beacon_value->SetInteger("request_elapsed_ms", elapsed.InMilliseconds()); | 51 beacon_value->SetInteger("request_elapsed_ms", elapsed.InMilliseconds()); |
52 base::TimeDelta request_age = upload_time - start_time; | 52 base::TimeDelta request_age = upload_time - start_time; |
53 beacon_value->SetInteger("request_age_ms", request_age.InMilliseconds()); | 53 beacon_value->SetInteger("request_age_ms", request_age.InMilliseconds()); |
54 bool network_changed = last_network_change_time > start_time; | 54 bool network_changed = last_network_change_time > start_time; |
55 beacon_value->SetBoolean("network_changed", network_changed); | 55 beacon_value->SetBoolean("network_changed", network_changed); |
56 beacon_value->SetDouble("sample_rate", sample_rate); | 56 beacon_value->SetDouble("sample_rate", sample_rate); |
57 return std::move(beacon_value); | 57 return std::move(beacon_value); |
58 } | 58 } |
59 | 59 |
60 } // namespace domain_reliability | 60 } // namespace domain_reliability |
OLD | NEW |