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

Issue 7000022: Faster way to read the hostname on mac. (Closed)

Created:
9 years, 7 months ago by pastarmovj
Modified:
9 years, 7 months ago
Reviewers:
Bernhard Bauer
CC:
chromium-reviews, pam+watch_chromium.org, Ilya Sherman
Visibility:
Public.

Description

Faster way to read the hostname on mac. BUG=81634 TEST=unit_tests --gtest_filter=PolicyPathParser.* Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=85470

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -2 lines) Patch
M chrome/browser/policy/policy_path_parser_mac.mm View 2 chunks +10 lines, -2 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
pastarmovj
Please have a look at the change as proposed by isherman@chromium.org - it seems to ...
9 years, 7 months ago (2011-05-11 14:56:01 UTC) #1
Bernhard Bauer
9 years, 7 months ago (2011-05-11 16:02:20 UTC) #2
LGTM.

On Wed, May 11, 2011 at 16:56,  <pastarmovj@chromium.org> wrote:
> Reviewers: Bernhard Bauer,
>
> Message:
> Please have a look at the change as proposed by isherman@chromium.org - it
> seems
> to be working fine.
>
> Description:
> Faster way to read the hostname on mac.
>
> BUG=81634
> TEST=unit_tests --gtest_filter=PolicyPathParser.*
>
>
> Please review this at http://codereview.chromium.org/7000022/
>
> SVN Base: svn://svn.chromium.org/chrome/trunk/src
>
> Affected files:
>  M chrome/browser/policy/policy_path_parser_mac.mm
>
>
> 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;
>  }
>
>
>

Powered by Google App Engine
This is Rietveld 408576698