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/suggestions/suggestions_service.h" | 5 #include "components/suggestions/suggestions_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( | 260 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( |
261 request->GetOriginalURL(), false, false, &headers); | 261 request->GetOriginalURL(), false, false, &headers); |
262 request->SetExtraRequestHeaders(headers.ToString()); | 262 request->SetExtraRequestHeaders(headers.ToString()); |
263 return request; | 263 return request; |
264 } | 264 } |
265 | 265 |
266 void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { | 266 void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { |
267 DCHECK(thread_checker_.CalledOnValidThread()); | 267 DCHECK(thread_checker_.CalledOnValidThread()); |
268 DCHECK_EQ(pending_request_.get(), source); | 268 DCHECK_EQ(pending_request_.get(), source); |
269 | 269 |
270 // Before deleting the request we record traffic use of this service | |
bengr
2015/08/07 18:00:01
// Before deleting the request, record the data us
amohammadkhan
2015/08/11 22:04:36
Done.
| |
271 pending_request_->ReportYourUsage("Suggestion"); | |
272 | |
270 // The fetcher will be deleted when the request is handled. | 273 // The fetcher will be deleted when the request is handled. |
271 scoped_ptr<const net::URLFetcher> request(pending_request_.release()); | 274 scoped_ptr<const net::URLFetcher> request(pending_request_.release()); |
272 | 275 |
273 const net::URLRequestStatus& request_status = request->GetStatus(); | 276 const net::URLRequestStatus& request_status = request->GetStatus(); |
274 if (request_status.status() != net::URLRequestStatus::SUCCESS) { | 277 if (request_status.status() != net::URLRequestStatus::SUCCESS) { |
275 // This represents network errors (i.e. the server did not provide a | 278 // This represents network errors (i.e. the server did not provide a |
276 // response). | 279 // response). |
277 UMA_HISTOGRAM_SPARSE_SLOWLY("Suggestions.FailedRequestErrorCode", | 280 UMA_HISTOGRAM_SPARSE_SLOWLY("Suggestions.FailedRequestErrorCode", |
278 -request_status.error()); | 281 -request_status.error()); |
279 DVLOG(1) << "Suggestions server request failed with error: " | 282 DVLOG(1) << "Suggestions server request failed with error: " |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); | 397 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); |
395 } else { | 398 } else { |
396 TimeDelta candidate_delay = | 399 TimeDelta candidate_delay = |
397 scheduling_delay_ * kSchedulingBackoffMultiplier; | 400 scheduling_delay_ * kSchedulingBackoffMultiplier; |
398 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) | 401 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) |
399 scheduling_delay_ = candidate_delay; | 402 scheduling_delay_ = candidate_delay; |
400 } | 403 } |
401 } | 404 } |
402 | 405 |
403 } // namespace suggestions | 406 } // namespace suggestions |
OLD | NEW |