OLD | NEW |
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 "sync/util/get_session_name_mac.h" | 5 #include "sync/util/get_session_name_mac.h" |
6 | 6 |
7 #include <sys/sysctl.h> | 7 #include <sys/sysctl.h> |
8 #import <SystemConfiguration/SCDynamicStoreCopySpecific.h> | 8 #import <SystemConfiguration/SCDynamicStoreCopySpecific.h> |
9 | 9 |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 SCDynamicStoreCopyComputerName(store.get(), NULL)); | 29 SCDynamicStoreCopyComputerName(store.get(), NULL)); |
30 if (computer_name.get()) | 30 if (computer_name.get()) |
31 return base::SysCFStringRefToUTF8(computer_name.get()); | 31 return base::SysCFStringRefToUTF8(computer_name.get()); |
32 | 32 |
33 // If all else fails, return to using a slightly nicer version of the | 33 // If all else fails, return to using a slightly nicer version of the |
34 // hardware model. | 34 // hardware model. |
35 char modelBuffer[256]; | 35 char modelBuffer[256]; |
36 size_t length = sizeof(modelBuffer); | 36 size_t length = sizeof(modelBuffer); |
37 if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) { | 37 if (!sysctlbyname("hw.model", modelBuffer, &length, NULL, 0)) { |
38 for (size_t i = 0; i < length; i++) { | 38 for (size_t i = 0; i < length; i++) { |
39 if (IsAsciiDigit(modelBuffer[i])) | 39 if (base::IsAsciiDigit(modelBuffer[i])) |
40 return std::string(modelBuffer, 0, i); | 40 return std::string(modelBuffer, 0, i); |
41 } | 41 } |
42 return std::string(modelBuffer, 0, length); | 42 return std::string(modelBuffer, 0, length); |
43 } | 43 } |
44 return "Unknown"; | 44 return "Unknown"; |
45 } | 45 } |
46 | 46 |
47 } // namespace internal | 47 } // namespace internal |
48 } // namespace syncer | 48 } // namespace syncer |
OLD | NEW |