Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chrome/browser/geolocation/geoposition.cc

Issue 552250: Port the gears geolocation network provider to Chromium... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/geolocation/geoposition.h"
6
7 namespace {
8 // Sentinel values to mark invalid data. (WebKit carries companion is_valid
9 // bools for this purpose; we may eventually follow that approach, but
10 // sentinels worked OK in the gears code this is based on.)
11 const double kBadLatLng = 200;
12 // Lowest point on land is at approximately -400 metres.
13 const int kBadAltitude = -1000;
14 const int kBadAccuracy = -1; // Accuracy must be non-negative.
15 const int64 kBadTimestamp = kint64min;
16 }
17
18 Position::Position()
19 : latitude(kBadLatLng),
20 longitude(kBadLatLng),
21 altitude(kBadAltitude),
22 accuracy(kBadAccuracy),
23 altitude_accuracy(kBadAccuracy),
24 timestamp(kBadTimestamp),
25 error_code(ERROR_CODE_NONE) {
26 }
27
28 bool Position::is_valid_latlong() const {
29 return latitude >= -90.0 && latitude <= 90.0 &&
30 longitude >= -180.0 && longitude <= 180.0;
31 }
32
33 bool Position::is_valid_altitude() const {
34 return altitude > kBadAltitude;
35 }
36
37 bool Position::is_valid_accuracy() const {
38 return accuracy >= 0.0;
39 }
40
41 bool Position::is_valid_altitude_accuracy() const {
42 return altitude_accuracy >= 0.0;
43 }
44
45 bool Position::is_valid_timestamp() const {
46 return timestamp != kBadTimestamp;
47 }
48
49 bool Position::IsValidFix() const {
50 return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp();
51 }
52
53 bool Position::IsInitialized() const {
54 return error_code != ERROR_CODE_NONE || IsValidFix();
55 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geoposition.h ('k') | chrome/browser/geolocation/location_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698