diff options
author | satorux <satorux@chromium.org> | 2014-12-12 14:30:37 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-12 22:31:11 +0000 |
commit | de6a5dcfdef67c2ef141db012293b633fc96ae42 (patch) | |
tree | 640d57068e183413ad08224e7ed86eebed78e9bc /chromeos/geolocation/geoposition.cc | |
parent | 2209d5e44d1271b3c60d7517639697759b1f5275 (diff) | |
download | chromium_src-de6a5dcfdef67c2ef141db012293b633fc96ae42.zip chromium_src-de6a5dcfdef67c2ef141db012293b633fc96ae42.tar.gz chromium_src-de6a5dcfdef67c2ef141db012293b633fc96ae42.tar.bz2 |
Move chrome/browser/chromeos/geolocation to chromeos/geolocation
In favor of less things to have in chrome/browser/chromeos.
BUG=437691
TEST=everything builds as before
Review URL: https://codereview.chromium.org/786693002
Cr-Commit-Position: refs/heads/master@{#308183}
Diffstat (limited to 'chromeos/geolocation/geoposition.cc')
-rw-r--r-- | chromeos/geolocation/geoposition.cc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/chromeos/geolocation/geoposition.cc b/chromeos/geolocation/geoposition.cc new file mode 100644 index 0000000..8909d4a --- /dev/null +++ b/chromeos/geolocation/geoposition.cc @@ -0,0 +1,54 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/geolocation/geoposition.h" + +#include "base/strings/stringprintf.h" + +namespace { + +// Sentinel values to mark invalid data. +const double kBadLatitudeLongitude = 200; +const int kBadAccuracy = -1; // Accuracy must be non-negative. + +} // namespace + +namespace chromeos { + +Geoposition::Geoposition() + : latitude(kBadLatitudeLongitude), + longitude(kBadLatitudeLongitude), + accuracy(kBadAccuracy), + error_code(0), + status(STATUS_NONE) { +} + +bool Geoposition::Valid() const { + return latitude >= -90. && latitude <= 90. && longitude >= -180. && + longitude <= 180. && accuracy >= 0. && !timestamp.is_null() && + status == STATUS_OK; +} + +std::string Geoposition::ToString() const { + static const char* const status2string[] = { + "NONE", + "OK", + "SERVER_ERROR", + "NETWORK_ERROR", + "TIMEOUT" + }; + + return base::StringPrintf( + "latitude=%f, longitude=%f, accuracy=%f, error_code=%u, " + "error_message='%s', status=%u (%s)", + latitude, + longitude, + accuracy, + error_code, + error_message.c_str(), + (unsigned)status, + (status < arraysize(status2string) ? status2string[status] : "unknown")); +} + +} // namespace chromeos |