OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/native_library.h" | 5 #include "base/native_library.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // static | 56 // static |
57 NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 57 NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
58 NativeLibraryLoadError* error) { | 58 NativeLibraryLoadError* error) { |
59 return LoadNativeLibraryHelper(library_path, LoadLibraryW, error); | 59 return LoadNativeLibraryHelper(library_path, LoadLibraryW, error); |
60 } | 60 } |
61 | 61 |
62 NativeLibrary LoadNativeLibraryDynamically(const FilePath& library_path) { | 62 NativeLibrary LoadNativeLibraryDynamically(const FilePath& library_path) { |
63 typedef HMODULE (WINAPI* LoadLibraryFunction)(const wchar_t* file_name); | 63 typedef HMODULE (WINAPI* LoadLibraryFunction)(const wchar_t* file_name); |
64 | 64 |
65 LoadLibraryFunction load_library; | 65 LoadLibraryFunction load_library = reinterpret_cast<LoadLibraryFunction>( |
66 load_library = reinterpret_cast<LoadLibraryFunction>( | |
67 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryW")); | 66 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryW")); |
68 | 67 |
69 return LoadNativeLibraryHelper(library_path, load_library, NULL); | 68 return LoadNativeLibraryHelper(library_path, load_library, NULL); |
70 } | 69 } |
71 | 70 |
72 // static | 71 // static |
73 void UnloadNativeLibrary(NativeLibrary library) { | 72 void UnloadNativeLibrary(NativeLibrary library) { |
74 FreeLibrary(library); | 73 FreeLibrary(library); |
75 } | 74 } |
76 | 75 |
77 // static | 76 // static |
78 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 77 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
79 const char* name) { | 78 StringPiece name) { |
80 return GetProcAddress(library, name); | 79 return GetProcAddress(library, name.data()); |
81 } | 80 } |
82 | 81 |
83 // static | 82 // static |
84 string16 GetNativeLibraryName(const string16& name) { | 83 string16 GetNativeLibraryName(StringPiece16 name) { |
85 return name + ASCIIToUTF16(".dll"); | 84 return name.as_string() + ASCIIToUTF16(".dll"); |
86 } | 85 } |
87 | 86 |
88 } // namespace base | 87 } // namespace base |
OLD | NEW |