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

Side by Side Diff: ios/chrome/browser/geolocation/CLLocation+XGeoHeader.mm

Issue 2528003002: [ObjC ARC] Converts ios/chrome/browser/geolocation:geolocation to ARC.Automatically generated ARC… (Closed)
Patch Set: comments, cleanup Created 4 years 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
OLDNEW
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+XGeoHeader.h" 5 #import "ios/chrome/browser/geolocation/CLLocation+XGeoHeader.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #import "third_party/google_toolbox_for_mac/src/Foundation/GTMStringEncoding.h" 9 #import "third_party/google_toolbox_for_mac/src/Foundation/GTMStringEncoding.h"
10 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
11 NSString* const kGMOLocationDescriptorFormat = 15 NSString* const kGMOLocationDescriptorFormat =
12 @"role: CURRENT_LOCATION\n" 16 @"role: CURRENT_LOCATION\n"
13 @"producer: DEVICE_LOCATION\n" 17 @"producer: DEVICE_LOCATION\n"
14 @"timestamp: %lld\n" 18 @"timestamp: %lld\n"
15 @"radius: %ld\n" 19 @"radius: %ld\n"
16 @"latlng <\n" 20 @"latlng <\n"
17 @" latitude_e7: %.f\n" 21 @" latitude_e7: %.f\n"
18 @" longitude_e7: %.f\n" 22 @" longitude_e7: %.f\n"
19 @">"; 23 @">";
20 24
21 @implementation CLLocation (XGeoHeader) 25 @implementation CLLocation (XGeoHeader)
22 26
23 - (NSString*)cr_serializeStringToWebSafeBase64String:(NSString*)data { 27 - (NSString*)cr_serializeStringToWebSafeBase64String:(NSString*)data {
24 GTMStringEncoding* encoder = 28 GTMStringEncoding* encoder =
25 [GTMStringEncoding rfc4648Base64WebsafeStringEncoding]; 29 [GTMStringEncoding rfc4648Base64WebsafeStringEncoding];
26 NSString* base64 = 30 NSString* base64 =
27 [encoder encode:[data dataUsingEncoding:NSUTF8StringEncoding] 31 [encoder encode:[data dataUsingEncoding:NSUTF8StringEncoding]
28 error:nullptr]; 32 error:nullptr];
29 if (base64) { 33 if (base64) {
30 return base64; 34 return base64;
31 } else {
32 return @"";
33 } 35 }
36 return @"";
34 } 37 }
35 38
36 // Returns the timestamp of this location in microseconds since the UNIX epoch. 39 // Returns the timestamp of this location in microseconds since the UNIX epoch.
37 // Returns 0 if the timestamp is unavailable or invalid. 40 // Returns 0 if the timestamp is unavailable or invalid.
38 - (int64_t)cr_timestampInMicroseconds { 41 - (int64_t)cr_timestampInMicroseconds {
39 NSTimeInterval seconds = [self.timestamp timeIntervalSince1970]; 42 NSTimeInterval seconds = [self.timestamp timeIntervalSince1970];
40 if (seconds > 0) { 43 if (seconds > 0) {
41 const int64_t kSecondsToMicroseconds = 1000000; 44 const int64_t kSecondsToMicroseconds = 1000000;
42 return (int64_t)(seconds * kSecondsToMicroseconds); 45 return (int64_t)(seconds * kSecondsToMicroseconds);
43 } 46 }
(...skipping 23 matching lines...) Expand all
67 70
68 - (NSString*)cr_xGeoString { 71 - (NSString*)cr_xGeoString {
69 NSString* locationDescriptor = [self cr_locationDescriptor]; 72 NSString* locationDescriptor = [self cr_locationDescriptor];
70 // The "a" indicates that it is an ASCII proto. 73 // The "a" indicates that it is an ASCII proto.
71 return [NSString 74 return [NSString
72 stringWithFormat:@"a %@", [self cr_serializeStringToWebSafeBase64String: 75 stringWithFormat:@"a %@", [self cr_serializeStringToWebSafeBase64String:
73 locationDescriptor]]; 76 locationDescriptor]];
74 } 77 }
75 78
76 @end 79 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/geolocation/CLLocation+OmniboxGeolocation.mm ('k') | ios/chrome/browser/geolocation/location_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698