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

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

Issue 398173003: Domain Reliability: Return http.error for HTTP errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/util.h" 5 #include "components/domain_reliability/util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/strings/stringprintf.h"
11 #include "base/time/time.h" 10 #include "base/time/time.h"
12 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
13 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
14 13
15 namespace domain_reliability { 14 namespace domain_reliability {
16 15
17 namespace { 16 namespace {
18 17
19 class ActualTimer : public MockableTime::Timer { 18 class ActualTimer : public MockableTime::Timer {
20 public: 19 public:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 76
78 } // namespace 77 } // namespace
79 78
80 // static 79 // static
81 bool GetDomainReliabilityBeaconStatus( 80 bool GetDomainReliabilityBeaconStatus(
82 int net_error, 81 int net_error,
83 int http_response_code, 82 int http_response_code,
84 std::string* beacon_status_out) { 83 std::string* beacon_status_out) {
85 if (net_error == net::OK) { 84 if (net_error == net::OK) {
86 if (http_response_code >= 400 && http_response_code < 600) 85 if (http_response_code >= 400 && http_response_code < 600)
87 *beacon_status_out = base::StringPrintf("http.%d", http_response_code); 86 *beacon_status_out = "http.error";
88 else 87 else
89 *beacon_status_out = "ok"; 88 *beacon_status_out = "ok";
90 return true; 89 return true;
91 } 90 }
92 91
93 // TODO(ttuttle): Consider sorting and using binary search? 92 // TODO(ttuttle): Consider sorting and using binary search?
94 for (size_t i = 0; i < arraysize(net_error_map); i++) { 93 for (size_t i = 0; i < arraysize(net_error_map); i++) {
95 if (net_error_map[i].net_error == net_error) { 94 if (net_error_map[i].net_error == net_error) {
96 *beacon_status_out = net_error_map[i].beacon_status; 95 *beacon_status_out = net_error_map[i].beacon_status;
97 return true; 96 return true;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ActualTime::~ActualTime() {} 133 ActualTime::~ActualTime() {}
135 134
136 base::Time ActualTime::Now() { return base::Time::Now(); } 135 base::Time ActualTime::Now() { return base::Time::Now(); }
137 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); } 136 base::TimeTicks ActualTime::NowTicks() { return base::TimeTicks::Now(); }
138 137
139 scoped_ptr<MockableTime::Timer> ActualTime::CreateTimer() { 138 scoped_ptr<MockableTime::Timer> ActualTime::CreateTimer() {
140 return scoped_ptr<MockableTime::Timer>(new ActualTimer()); 139 return scoped_ptr<MockableTime::Timer>(new ActualTimer());
141 } 140 }
142 141
143 } // namespace domain_reliability 142 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698