OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ios/chrome/browser/geolocation/CLLocation+OmniboxGeolocation.h" | 5 #import "ios/chrome/browser/geolocation/CLLocation+OmniboxGeolocation.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 namespace { | 15 namespace { |
12 | 16 |
13 // The key needed for objc_setAssociatedObject. Any value will do, because the | 17 // The key needed for objc_setAssociatedObject. Any value will do, because the |
14 // address is the key. | 18 // address is the key. |
15 static char g_acquisitionIntervalKey = 'k'; | 19 static char g_acquisitionIntervalKey = 'k'; |
16 | 20 |
17 // Number of seconds before a location is no longer considered to be fresh | 21 // Number of seconds before a location is no longer considered to be fresh |
18 // enough to use for an Omnibox query. | 22 // enough to use for an Omnibox query. |
19 const NSTimeInterval kLocationIsFreshAge = 24.0 * 60.0 * 60.0; // 24 hours | 23 const NSTimeInterval kLocationIsFreshAge = 24.0 * 60.0 * 60.0; // 24 hours |
20 | 24 |
(...skipping 22 matching lines...) Expand all Loading... |
43 return (age >= 0) && (age <= kLocationIsFreshAge); | 47 return (age >= 0) && (age <= kLocationIsFreshAge); |
44 } | 48 } |
45 | 49 |
46 - (BOOL)cr_shouldRefresh { | 50 - (BOOL)cr_shouldRefresh { |
47 NSTimeInterval age = -[self.timestamp timeIntervalSinceNow]; | 51 NSTimeInterval age = -[self.timestamp timeIntervalSinceNow]; |
48 // Note: if age < 0 (the location is from the future), don't believe it. | 52 // Note: if age < 0 (the location is from the future), don't believe it. |
49 return (age < 0) || (age > kLocationShouldRefreshAge); | 53 return (age < 0) || (age > kLocationShouldRefreshAge); |
50 } | 54 } |
51 | 55 |
52 @end | 56 @end |
OLD | NEW |