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" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // Convert absolute timestamps into a relative age. | 214 // Convert absolute timestamps into a relative age. |
215 int64 delta_ms = (base::Time::Now() - timestamp).InMilliseconds(); | 215 int64 delta_ms = (base::Time::Now() - timestamp).InMilliseconds(); |
216 if (delta_ms >= 0 && delta_ms < kint32max) | 216 if (delta_ms >= 0 && delta_ms < kint32max) |
217 age = static_cast<int>(delta_ms); | 217 age = static_cast<int>(delta_ms); |
218 } | 218 } |
219 | 219 |
220 base::DictionaryValue request; | 220 base::DictionaryValue request; |
221 AddWifiData(wifi_data, age, &request); | 221 AddWifiData(wifi_data, age, &request); |
222 if (!access_token.empty()) | 222 if (!access_token.empty()) |
223 request.SetString(kAccessTokenString, access_token); | 223 request.SetString(kAccessTokenString, access_token); |
224 base::JSONWriter::Write(&request, upload_data); | 224 base::JSONWriter::Write(request, upload_data); |
225 } | 225 } |
226 | 226 |
227 void AddString(const std::string& property_name, const std::string& value, | 227 void AddString(const std::string& property_name, const std::string& value, |
228 base::DictionaryValue* dict) { | 228 base::DictionaryValue* dict) { |
229 DCHECK(dict); | 229 DCHECK(dict); |
230 if (!value.empty()) | 230 if (!value.empty()) |
231 dict->SetString(property_name, value); | 231 dict->SetString(property_name, value); |
232 } | 232 } |
233 | 233 |
234 void AddInteger(const std::string& property_name, int value, | 234 void AddInteger(const std::string& property_name, int value, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 // Other fields are optional. | 424 // Other fields are optional. |
425 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); | 425 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); |
426 | 426 |
427 return true; | 427 return true; |
428 } | 428 } |
429 | 429 |
430 } // namespace | 430 } // namespace |
431 | 431 |
432 } // namespace content | 432 } // namespace content |
OLD | NEW |