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

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

Issue 267633002: Domain Reliability: Don't send proxy address, other fixes (Closed) Base URL: http://git.chromium.org/chromium/src.git@domrel_security
Patch Set: Fix mis-commit Created 6 years, 7 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/context.h" 5 #include "components/domain_reliability/context.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 DomainReliabilityContext::~DomainReliabilityContext() {} 135 DomainReliabilityContext::~DomainReliabilityContext() {}
136 136
137 void DomainReliabilityContext::OnBeacon(const GURL& url, 137 void DomainReliabilityContext::OnBeacon(const GURL& url,
138 const DomainReliabilityBeacon& beacon) { 138 const DomainReliabilityBeacon& beacon) {
139 size_t index = config_->GetResourceIndexForUrl(url); 139 size_t index = config_->GetResourceIndexForUrl(url);
140 if (index == DomainReliabilityConfig::kInvalidResourceIndex) 140 if (index == DomainReliabilityConfig::kInvalidResourceIndex)
141 return; 141 return;
142 DCHECK_GT(states_.size(), index); 142 DCHECK_GT(states_.size(), index);
143 143
144 bool success = (beacon.status == "ok");
Ryan Sleevi 2014/05/06 22:43:42 unrelated?
Deprecated (see juliatuttle) 2014/05/07 03:13:09 Yes, but I spotted it writing unittests :)
145
144 ResourceState* state = states_[index]; 146 ResourceState* state = states_[index];
145 bool success = beacon.http_response_code >= 200 &&
146 beacon.http_response_code < 400;
147 if (success) 147 if (success)
148 ++state->successful_requests; 148 ++state->successful_requests;
149 else 149 else
150 ++state->failed_requests; 150 ++state->failed_requests;
151 151
152 bool reported = false; 152 bool reported = false;
153 bool evicted = false; 153 bool evicted = false;
154 if (state->config->DecideIfShouldReportRequest(success)) { 154 if (state->config->DecideIfShouldReportRequest(success)) {
155 state->beacons.push_back(beacon); 155 state->beacons.push_back(beacon);
156 ++beacon_count_; 156 ++beacon_count_;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 min_resource->RemoveOldestBeacon(); 288 min_resource->RemoveOldestBeacon();
289 --beacon_count_; 289 --beacon_count_;
290 // If that just removed a beacon counted in uploading_beacon_count_, decrement 290 // If that just removed a beacon counted in uploading_beacon_count_, decrement
291 // that. 291 // that.
292 if (uploading_beacon_count_ > 0) 292 if (uploading_beacon_count_ > 0)
293 --uploading_beacon_count_; 293 --uploading_beacon_count_;
294 } 294 }
295 295
296 } // namespace domain_reliability 296 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/config_unittest.cc ('k') | components/domain_reliability/context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698