scoped_native_library.h (959B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 // This is a cut down version of Chromium source file 8 // base/scoped_native_library.h The chromium sandbox only requires 9 // ScopedNativeLibrary class to automatically unload the library, which we can 10 // achieve with UniquePtr. 11 12 #ifndef BASE_SCOPED_NATIVE_LIBRARY_H_ 13 #define BASE_SCOPED_NATIVE_LIBRARY_H_ 14 15 #include <windows.h> 16 17 #include "mozilla/UniquePtr.h" 18 19 namespace base { 20 21 struct HModuleFreePolicy { 22 typedef HMODULE pointer; 23 void operator()(pointer hModule) { ::FreeLibrary(hModule); } 24 }; 25 26 typedef mozilla::UniquePtr<HMODULE, HModuleFreePolicy> ScopedNativeLibrary; 27 28 } // namespace base 29 30 #endif // BASE_SCOPED_NATIVE_LIBRARY_H_