Chromium Code Reviews| Index: base/native_library_mac.mm |
| diff --git a/base/native_library_mac.mm b/base/native_library_mac.mm |
| index 16848858fd09b0cd92df29a3c3abf9080894c596..b50c6968a3ea5abfb2f905ac572be208699fb4ad 100644 |
| --- a/base/native_library_mac.mm |
| +++ b/base/native_library_mac.mm |
| @@ -23,22 +23,10 @@ static NativeLibraryObjCStatus GetObjCStatusForImage( |
| if (!dladdr(function_pointer, &info)) |
| return OBJC_UNKNOWN; |
| - // See if the the image contains an "ObjC image info" segment. This method |
|
Lei Zhang
2016/06/07 01:25:39
And self-reviewing after sending out the CL... I p
|
| - // of testing is used in _CFBundleGrokObjcImageInfoFromFile in |
| - // CF-744/CFBundle.c, around lines 2447-2474. |
| - // |
| - // In 32-bit images, ObjC can be recognized in __OBJC,__image_info, whereas |
| - // in 64-bit, the data is in __DATA,__objc_imageinfo. |
| -#if __LP64__ |
| const section_64* section = getsectbynamefromheader_64( |
| reinterpret_cast<const struct mach_header_64*>(info.dli_fbase), |
| SEG_DATA, "__objc_imageinfo"); |
| -#else |
| - const section* section = getsectbynamefromheader( |
| - reinterpret_cast<const struct mach_header*>(info.dli_fbase), |
| - SEG_OBJC, "__image_info"); |
| -#endif |
| - return section == NULL ? OBJC_NOT_PRESENT : OBJC_PRESENT; |
| + return section ? OBJC_PRESENT : OBJC_NOT_PRESENT; |
| } |
| std::string NativeLibraryLoadError::ToString() const { |
| @@ -46,7 +34,7 @@ std::string NativeLibraryLoadError::ToString() const { |
| } |
| // static |
| -NativeLibrary LoadNativeLibrary(const base::FilePath& library_path, |
| +NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
| NativeLibraryLoadError* error) { |
| // dlopen() etc. open the file off disk. |
| if (library_path.Extension() == "dylib" || !DirectoryExists(library_path)) { |
| @@ -62,7 +50,7 @@ NativeLibrary LoadNativeLibrary(const base::FilePath& library_path, |
| native_lib->objc_status = OBJC_UNKNOWN; |
| return native_lib; |
| } |
| - base::ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation( |
| + ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation( |
| kCFAllocatorDefault, |
| (const UInt8*)library_path.value().c_str(), |
| library_path.value().length(), |
| @@ -103,17 +91,17 @@ void UnloadNativeLibrary(NativeLibrary library) { |
| // static |
| void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| - const char* name) { |
| + StringPiece name) { |
| void* function_pointer = NULL; |
| // Get the function pointer using the right API for the type. |
| if (library->type == BUNDLE) { |
| - base::ScopedCFTypeRef<CFStringRef> symbol_name(CFStringCreateWithCString( |
| - kCFAllocatorDefault, name, kCFStringEncodingUTF8)); |
| + ScopedCFTypeRef<CFStringRef> symbol_name(CFStringCreateWithCString( |
| + kCFAllocatorDefault, name.data(), kCFStringEncodingUTF8)); |
| function_pointer = CFBundleGetFunctionPointerForName(library->bundle, |
| symbol_name); |
| } else { |
| - function_pointer = dlsym(library->dylib, name); |
| + function_pointer = dlsym(library->dylib, name.data()); |
| } |
| // If this library hasn't been tested for having ObjC, use the function |
| @@ -125,8 +113,8 @@ void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| } |
| // static |
| -string16 GetNativeLibraryName(const string16& name) { |
| - return name + ASCIIToUTF16(".dylib"); |
| +string16 GetNativeLibraryName(StringPiece16 name) { |
| + return name.as_string() + ASCIIToUTF16(".dylib"); |
|
Lei Zhang
2016/06/07 01:39:52
BTW, I suspect this is wrong, and it should be lib
xhwang
2016/06/07 16:39:27
+1
Mark Mentovai
2016/06/10 20:06:18
Lei Zhang wrote:
|
| } |
| } // namespace base |