OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/geolocation/network_location_request.h" | 5 #include "content/browser/geolocation/network_location_request.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "content/public/common/geoposition.h" | 15 #include "content/public/common/geoposition.h" |
16 #include "content/public/common/url_fetcher.h" | |
17 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
18 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 18 #include "net/url_request/url_fetcher.h" |
19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
20 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const size_t kMaxRequestLength = 2048; | 24 const size_t kMaxRequestLength = 2048; |
25 | 25 |
26 const char kAccessTokenString[] = "access_token"; | 26 const char kAccessTokenString[] = "access_token"; |
27 const char kLocationString[] = "location"; | 27 const char kLocationString[] = "location"; |
28 const char kLatitudeString[] = "lat"; | 28 const char kLatitudeString[] = "lat"; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const base::Time& timestamp) { | 78 const base::Time& timestamp) { |
79 if (url_fetcher_ != NULL) { | 79 if (url_fetcher_ != NULL) { |
80 DVLOG(1) << "NetworkLocationRequest : Cancelling pending request"; | 80 DVLOG(1) << "NetworkLocationRequest : Cancelling pending request"; |
81 url_fetcher_.reset(); | 81 url_fetcher_.reset(); |
82 } | 82 } |
83 wifi_data_ = wifi_data; | 83 wifi_data_ = wifi_data; |
84 timestamp_ = timestamp; | 84 timestamp_ = timestamp; |
85 | 85 |
86 GURL request_url = FormRequestURL(url_.spec(), access_token, | 86 GURL request_url = FormRequestURL(url_.spec(), access_token, |
87 wifi_data, timestamp_); | 87 wifi_data, timestamp_); |
88 url_fetcher_.reset(content::URLFetcher::Create( | 88 url_fetcher_.reset(net::URLFetcher::Create( |
89 url_fetcher_id_for_tests, request_url, net::URLFetcher::GET, this)); | 89 url_fetcher_id_for_tests, request_url, net::URLFetcher::GET, this)); |
90 url_fetcher_->SetRequestContext(url_context_); | 90 url_fetcher_->SetRequestContext(url_context_); |
91 url_fetcher_->SetLoadFlags( | 91 url_fetcher_->SetLoadFlags( |
92 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 92 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
93 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | | 93 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | |
94 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 94 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
95 | 95 |
96 url_fetcher_->Start(); | 96 url_fetcher_->Start(); |
97 return true; | 97 return true; |
98 } | 98 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 position->longitude = longitude; | 406 position->longitude = longitude; |
407 position->timestamp = timestamp; | 407 position->timestamp = timestamp; |
408 | 408 |
409 // Other fields are optional. | 409 // Other fields are optional. |
410 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); | 410 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); |
411 | 411 |
412 return true; | 412 return true; |
413 } | 413 } |
414 | 414 |
415 } // namespace | 415 } // namespace |
OLD | NEW |