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

Side by Side Diff: base/ios/device_util.mm

Issue 16917011: mac: Replace base::mac::ScopedCFTypeRef with base::ScopedCFTypeRef. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with fixed off-by-1 in git-clang-format Created 7 years, 6 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
« no previous file with comments | « no previous file | base/mac/foundation_util.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/ios/device_util.h" 5 #include "base/ios/device_util.h"
6 6
7 #include <CommonCrypto/CommonDigest.h> 7 #include <CommonCrypto/CommonDigest.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include <ifaddrs.h> 10 #include <ifaddrs.h>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 break; 113 break;
114 } 114 }
115 } 115 }
116 freeifaddrs(addresses); 116 freeifaddrs(addresses);
117 } 117 }
118 return mac_string; 118 return mac_string;
119 } 119 }
120 120
121 std::string GetRandomId() { 121 std::string GetRandomId() {
122 base::mac::ScopedCFTypeRef<CFUUIDRef> 122 base::ScopedCFTypeRef<CFUUIDRef> uuid_object(
123 uuid_object(CFUUIDCreate(kCFAllocatorDefault)); 123 CFUUIDCreate(kCFAllocatorDefault));
124 base::mac::ScopedCFTypeRef<CFStringRef> uuid_string( 124 base::ScopedCFTypeRef<CFStringRef> uuid_string(
125 CFUUIDCreateString(kCFAllocatorDefault, uuid_object)); 125 CFUUIDCreateString(kCFAllocatorDefault, uuid_object));
126 return base::SysCFStringRefToUTF8(uuid_string); 126 return base::SysCFStringRefToUTF8(uuid_string);
127 } 127 }
128 128
129 std::string GetDeviceIdentifier(const char* salt) { 129 std::string GetDeviceIdentifier(const char* salt) {
130 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 130 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
131 131
132 NSString* last_seen_hardware = 132 NSString* last_seen_hardware =
133 [defaults stringForKey:kHardwareTypePreferenceKey]; 133 [defaults stringForKey:kHardwareTypePreferenceKey];
134 NSString* current_hardware = base::SysUTF8ToNSString(GetPlatform()); 134 NSString* current_hardware = base::SysUTF8ToNSString(GetPlatform());
(...skipping 12 matching lines...) Expand all
147 [defaults synchronize]; 147 [defaults synchronize];
148 } 148 }
149 149
150 NSData* hash_data = [[NSString stringWithFormat:@"%@%s", client_id, 150 NSData* hash_data = [[NSString stringWithFormat:@"%@%s", client_id,
151 salt ? salt : kDefaultSalt] dataUsingEncoding:NSUTF8StringEncoding]; 151 salt ? salt : kDefaultSalt] dataUsingEncoding:NSUTF8StringEncoding];
152 152
153 unsigned char hash[CC_SHA256_DIGEST_LENGTH]; 153 unsigned char hash[CC_SHA256_DIGEST_LENGTH];
154 CC_SHA256([hash_data bytes], [hash_data length], hash); 154 CC_SHA256([hash_data bytes], [hash_data length], hash);
155 CFUUIDBytes* uuid_bytes = reinterpret_cast<CFUUIDBytes*>(hash); 155 CFUUIDBytes* uuid_bytes = reinterpret_cast<CFUUIDBytes*>(hash);
156 156
157 base::mac::ScopedCFTypeRef<CFUUIDRef> 157 base::ScopedCFTypeRef<CFUUIDRef> uuid_object(
158 uuid_object(CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, *uuid_bytes)); 158 CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, *uuid_bytes));
159 base::mac::ScopedCFTypeRef<CFStringRef> device_id( 159 base::ScopedCFTypeRef<CFStringRef> device_id(
160 CFUUIDCreateString(kCFAllocatorDefault, uuid_object)); 160 CFUUIDCreateString(kCFAllocatorDefault, uuid_object));
161 return base::SysCFStringRefToUTF8(device_id); 161 return base::SysCFStringRefToUTF8(device_id);
162 } 162 }
163 163
164 } // namespace device_util 164 } // namespace device_util
165 } // namespace ios 165 } // namespace ios
OLDNEW
« no previous file with comments | « no previous file | base/mac/foundation_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698