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

Side by Side Diff: base/native_library_win.cc

Issue 2042103002: Clean up some nits in base::NativeLibrary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« base/native_library_mac.mm ('K') | « base/native_library_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« base/native_library_mac.mm ('K') | « base/native_library_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698