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 "chromeos/geolocation/simple_geolocation_request.h" | 5 #include "chromeos/geolocation/simple_geolocation_request.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 RecordUmaResponseTime(base::Time::Now() - request_started_at_, false); | 288 RecordUmaResponseTime(base::Time::Now() - request_started_at_, false); |
289 RecordUmaResult(SIMPLE_GEOLOCATION_REQUEST_RESULT_CANCELLED, retries_); | 289 RecordUmaResult(SIMPLE_GEOLOCATION_REQUEST_RESULT_CANCELLED, retries_); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 void SimpleGeolocationRequest::StartRequest() { | 293 void SimpleGeolocationRequest::StartRequest() { |
294 DCHECK(thread_checker_.CalledOnValidThread()); | 294 DCHECK(thread_checker_.CalledOnValidThread()); |
295 RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_REQUEST_START); | 295 RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_REQUEST_START); |
296 ++retries_; | 296 ++retries_; |
297 | 297 |
298 url_fetcher_.reset( | 298 url_fetcher_ = |
299 net::URLFetcher::Create(request_url_, net::URLFetcher::POST, this)); | 299 net::URLFetcher::Create(request_url_, net::URLFetcher::POST, this); |
300 url_fetcher_->SetRequestContext(url_context_getter_.get()); | 300 url_fetcher_->SetRequestContext(url_context_getter_.get()); |
301 url_fetcher_->SetUploadData("application/json", | 301 url_fetcher_->SetUploadData("application/json", |
302 std::string(kSimpleGeolocationRequestBody)); | 302 std::string(kSimpleGeolocationRequestBody)); |
303 url_fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | | 303 url_fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | |
304 net::LOAD_DISABLE_CACHE | | 304 net::LOAD_DISABLE_CACHE | |
305 net::LOAD_DO_NOT_SAVE_COOKIES | | 305 net::LOAD_DO_NOT_SAVE_COOKIES | |
306 net::LOAD_DO_NOT_SEND_COOKIES | | 306 net::LOAD_DO_NOT_SEND_COOKIES | |
307 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 307 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
308 url_fetcher_->Start(); | 308 url_fetcher_->Start(); |
309 } | 309 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 ? SIMPLE_GEOLOCATION_REQUEST_RESULT_SERVER_ERROR | 381 ? SIMPLE_GEOLOCATION_REQUEST_RESULT_SERVER_ERROR |
382 : SIMPLE_GEOLOCATION_REQUEST_RESULT_FAILURE); | 382 : SIMPLE_GEOLOCATION_REQUEST_RESULT_FAILURE); |
383 RecordUmaResult(result, retries_); | 383 RecordUmaResult(result, retries_); |
384 position_.status = Geoposition::STATUS_TIMEOUT; | 384 position_.status = Geoposition::STATUS_TIMEOUT; |
385 const base::TimeDelta elapsed = base::Time::Now() - request_started_at_; | 385 const base::TimeDelta elapsed = base::Time::Now() - request_started_at_; |
386 ReplyAndDestroySelf(elapsed, true /* server_error */); | 386 ReplyAndDestroySelf(elapsed, true /* server_error */); |
387 // "this" is already destroyed here. | 387 // "this" is already destroyed here. |
388 } | 388 } |
389 | 389 |
390 } // namespace chromeos | 390 } // namespace chromeos |
OLD | NEW |