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

Side by Side Diff: components/user_prefs/tracked/device_id_mac.cc

Issue 2782803002: Move tracked prefs into services/preferences/tracked. (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "components/user_prefs/tracked/device_id.h"
6
7 #include <IOKit/IOKitLib.h>
8
9 #include "base/mac/foundation_util.h"
10 #include "base/mac/scoped_cftyperef.h"
11 #include "base/mac/scoped_ioobject.h"
12 #include "base/strings/sys_string_conversions.h"
13
14 MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) {
15 base::mac::ScopedIOObject<io_service_t> platform_expert(
16 IOServiceGetMatchingService(kIOMasterPortDefault,
17 IOServiceMatching("IOPlatformExpertDevice")));
18 if (!platform_expert.get())
19 return MachineIdStatus::FAILURE;
20
21 base::ScopedCFTypeRef<CFTypeRef> uuid(IORegistryEntryCreateCFProperty(
22 platform_expert, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0));
23 if (!uuid.get())
24 return MachineIdStatus::FAILURE;
25
26 CFStringRef uuid_string = base::mac::CFCast<CFStringRef>(uuid);
27 if (!uuid_string)
28 return MachineIdStatus::FAILURE;
29
30 *machine_id = base::SysCFStringRefToUTF8(uuid_string);
31 return MachineIdStatus::SUCCESS;
32 }
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/device_id.h ('k') | components/user_prefs/tracked/device_id_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698