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

Unified Diff: chrome/browser/policy/policy_path_parser_mac.mm

Issue 7000022: Faster way to read the hostname on mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_path_parser_mac.mm
diff --git a/chrome/browser/policy/policy_path_parser_mac.mm b/chrome/browser/policy/policy_path_parser_mac.mm
index 317325275ebc72b2789a905a8b94b1a482deef94..48d0653c574ee8765c5b7d29b0508b9590cfe185 100644
--- a/chrome/browser/policy/policy_path_parser_mac.mm
+++ b/chrome/browser/policy/policy_path_parser_mac.mm
@@ -8,6 +8,8 @@
#include "base/sys_string_conversions.h"
#import <Cocoa/Cocoa.h>
+#import <SystemConfiguration/SCDynamicStore.h>
+#import <SystemConfiguration/SCDynamicStoreCopySpecific.h>
#include <string>
@@ -62,13 +64,19 @@ FilePath::StringType ExpandPathVariables(
}
position = result.find(kMachineNamePolicyVarName);
if (position != std::string::npos) {
- NSString* machinename = [[NSHost currentHost] name];
+ SCDynamicStoreContext context = { 0, NULL, NULL, NULL };
+ SCDynamicStoreRef store = SCDynamicStoreCreate(kCFAllocatorDefault,
+ CFSTR("policy_subsystem"),
+ NULL, &context);
+ CFStringRef machinename = SCDynamicStoreCopyLocalHostName(store);
if (machinename) {
result.replace(position, strlen(kMachineNamePolicyVarName),
- base::SysNSStringToUTF8(machinename));
+ base::SysCFStringRefToUTF8(machinename));
+ CFRelease(machinename);
} else {
LOG(ERROR) << "Machine name variable can not be resolved.";
}
+ CFRelease(store);
}
return result;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698