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

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

Issue 605473002: Domain Reliablity: Add "domain" field to reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 9
10 namespace domain_reliability { 10 namespace domain_reliability {
11 11
12 using base::Value; 12 using base::Value;
13 using base::DictionaryValue; 13 using base::DictionaryValue;
14 14
15 DomainReliabilityBeacon::DomainReliabilityBeacon() {} 15 DomainReliabilityBeacon::DomainReliabilityBeacon() {}
16 DomainReliabilityBeacon::~DomainReliabilityBeacon() {} 16 DomainReliabilityBeacon::~DomainReliabilityBeacon() {}
17 17
18 Value* DomainReliabilityBeacon::ToValue(base::TimeTicks upload_time) const { 18 Value* DomainReliabilityBeacon::ToValue(base::TimeTicks upload_time) const {
19 DictionaryValue* beacon_value = new DictionaryValue(); 19 DictionaryValue* beacon_value = new DictionaryValue();
20 if (!url.empty()) 20 if (!url.empty())
21 beacon_value->SetString("url", url); 21 beacon_value->SetString("url", url);
22 if (!domain.empty())
23 beacon_value->SetString("domain", domain);
22 if (!resource.empty()) 24 if (!resource.empty())
23 beacon_value->SetString("resource", resource); 25 beacon_value->SetString("resource", resource);
24 beacon_value->SetString("status", status); 26 beacon_value->SetString("status", status);
25 if (chrome_error != net::OK) { 27 if (chrome_error != net::OK) {
26 DictionaryValue* failure_value = new DictionaryValue(); 28 DictionaryValue* failure_value = new DictionaryValue();
27 failure_value->SetString("custom_error", 29 failure_value->SetString("custom_error",
28 net::ErrorToString(chrome_error)); 30 net::ErrorToString(chrome_error));
29 beacon_value->Set("failure_data", failure_value); 31 beacon_value->Set("failure_data", failure_value);
30 } 32 }
31 beacon_value->SetString("server_ip", server_ip); 33 beacon_value->SetString("server_ip", server_ip);
32 beacon_value->SetString("protocol", protocol); 34 beacon_value->SetString("protocol", protocol);
33 if (http_response_code >= 0) 35 if (http_response_code >= 0)
34 beacon_value->SetInteger("http_response_code", http_response_code); 36 beacon_value->SetInteger("http_response_code", http_response_code);
35 beacon_value->SetInteger("request_elapsed_ms", 37 beacon_value->SetInteger("request_elapsed_ms",
36 elapsed.InMilliseconds()); 38 elapsed.InMilliseconds());
37 beacon_value->SetInteger("request_age_ms", 39 beacon_value->SetInteger("request_age_ms",
38 (upload_time - start_time).InMilliseconds()); 40 (upload_time - start_time).InMilliseconds());
39 return beacon_value; 41 return beacon_value;
40 } 42 }
41 43
42 } // namespace domain_reliability 44 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/beacon.h ('k') | components/domain_reliability/context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698