Chromium Code Reviews| Index: base/mac/mac_util.mm |
| =================================================================== |
| --- base/mac/mac_util.mm (revision 202209) |
| +++ base/mac/mac_util.mm (working copy) |
| @@ -18,7 +18,7 @@ |
| #include "base/mac/foundation_util.h" |
| #include "base/mac/mac_logging.h" |
| #include "base/mac/scoped_cftyperef.h" |
| -#include "base/memory/scoped_generic_obj.h" |
| +#include "base/mac/scoped_ioobject.h" |
| #include "base/memory/scoped_nsobject.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_piece.h" |
| @@ -647,34 +647,22 @@ |
| } |
| #endif |
| -namespace { |
| - |
| -// ScopedGenericObj functor for IOObjectRelease(). |
| -class ScopedReleaseIOObject { |
| - public: |
| - void operator()(io_object_t x) const { |
| - IOObjectRelease(x); |
| - } |
| -}; |
| - |
| -} // namespace |
| - |
| std::string GetModelIdentifier() { |
| - ScopedGenericObj<io_service_t, ScopedReleaseIOObject> |
| - platform_expert(IOServiceGetMatchingService( |
| - kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"))); |
| + std::string return_string; |
| + ScopedIOObject<io_service_t> platform_expert( |
| + IOServiceGetMatchingService(kIOMasterPortDefault, |
| + IOServiceMatching("IOPlatformExpertDevice"))); |
| if (!platform_expert) |
| - return ""; |
| + return return_string; |
|
Mark Mentovai
2013/05/28 20:52:18
Since you’ve rewritten this function to always ret
Lei Zhang
2013/05/28 21:01:18
Done.
|
| ScopedCFTypeRef<CFDataRef> model_data( |
| static_cast<CFDataRef>(IORegistryEntryCreateCFProperty( |
| platform_expert, |
| CFSTR("model"), |
| kCFAllocatorDefault, |
| 0))); |
| - if (!model_data) |
| - return ""; |
| - return reinterpret_cast<const char*>( |
| - CFDataGetBytePtr(model_data)); |
| + if (model_data) |
| + return_string = reinterpret_cast<const char*>(CFDataGetBytePtr(model_data)); |
| + return return_string; |
| } |
| bool ParseModelIdentifier(const std::string& ident, |