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

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

Issue 284103003: Domain Reliability: Don't use error code unless request failed (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | components/domain_reliability/monitor_unittest.cc » ('j') | 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/monitor.h" 5 #include "components/domain_reliability/monitor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 void DomainReliabilityMonitor::OnRequestLegComplete( 214 void DomainReliabilityMonitor::OnRequestLegComplete(
215 const RequestInfo& request) { 215 const RequestInfo& request) {
216 int response_code; 216 int response_code;
217 if (request.response_info.headers) 217 if (request.response_info.headers)
218 response_code = request.response_info.headers->response_code(); 218 response_code = request.response_info.headers->response_code();
219 else 219 else
220 response_code = -1; 220 response_code = -1;
221 ContextMap::iterator context_it; 221 ContextMap::iterator context_it;
222 std::string beacon_status; 222 std::string beacon_status;
223 223
224 int error_code = net::OK;
225 if (request.status.status() == net::URLRequestStatus::FAILED)
226 error_code = request.status.error();
227
224 // Ignore requests where: 228 // Ignore requests where:
225 // 1. There is no context for the request host. 229 // 1. There is no context for the request host.
226 // 2. The request did not access the network. 230 // 2. The request did not access the network.
227 // 3. The request is not supposed to send cookies (to avoid associating the 231 // 3. The request is not supposed to send cookies (to avoid associating the
228 // request with any potentially unique data in the config). 232 // request with any potentially unique data in the config).
229 // 4. The request was itself a Domain Reliability upload (to avoid loops). 233 // 4. The request was itself a Domain Reliability upload (to avoid loops).
230 // 5. There is no defined beacon status for the error or HTTP response code 234 // 5. There is no defined beacon status for the error or HTTP response code
231 // (to avoid leaking network-local errors). 235 // (to avoid leaking network-local errors).
232 if ((context_it = contexts_.find(request.url.host())) == contexts_.end() || 236 if ((context_it = contexts_.find(request.url.host())) == contexts_.end() ||
233 !request.AccessedNetwork() || 237 !request.AccessedNetwork() ||
234 (request.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) || 238 (request.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) ||
235 request.is_upload || 239 request.is_upload ||
236 !GetDomainReliabilityBeaconStatus( 240 !GetDomainReliabilityBeaconStatus(
237 request.status.error(), response_code, &beacon_status)) { 241 error_code, response_code, &beacon_status)) {
238 return; 242 return;
239 } 243 }
240 244
241 DomainReliabilityBeacon beacon; 245 DomainReliabilityBeacon beacon;
242 beacon.status = beacon_status; 246 beacon.status = beacon_status;
243 beacon.chrome_error = request.status.error(); 247 beacon.chrome_error = error_code;
244 if (!request.response_info.was_fetched_via_proxy) 248 if (!request.response_info.was_fetched_via_proxy)
245 beacon.server_ip = request.response_info.socket_address.host(); 249 beacon.server_ip = request.response_info.socket_address.host();
246 else 250 else
247 beacon.server_ip.clear(); 251 beacon.server_ip.clear();
248 beacon.http_response_code = response_code; 252 beacon.http_response_code = response_code;
249 beacon.start_time = request.load_timing_info.request_start; 253 beacon.start_time = request.load_timing_info.request_start;
250 beacon.elapsed = time_->NowTicks() - beacon.start_time; 254 beacon.elapsed = time_->NowTicks() - beacon.start_time;
251 context_it->second->OnBeacon(request.url, beacon); 255 context_it->second->OnBeacon(request.url, beacon);
252 } 256 }
253 257
254 } // namespace domain_reliability 258 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « no previous file | components/domain_reliability/monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698