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

Unified Diff: base/scoped_native_library.h

Issue 3915002: Out of process Pepper (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/scoped_native_library.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/scoped_native_library.h
===================================================================
--- base/scoped_native_library.h (revision 65099)
+++ base/scoped_native_library.h (working copy)
@@ -17,23 +17,33 @@
// This class automatically unloads the loaded library in its destructor.
class ScopedNativeLibrary {
public:
- explicit ScopedNativeLibrary(const FilePath& library_path) {
- library_ = base::LoadNativeLibrary(library_path);
- }
+ // Initializes with a NULL library.
+ ScopedNativeLibrary();
- ~ScopedNativeLibrary() {
- if (library_)
- base::UnloadNativeLibrary(library_);
- }
+ // Takes ownership of the given library handle.
+ explicit ScopedNativeLibrary(NativeLibrary library);
- void* GetFunctionPointer(const char* function_name) {
- if (!library_)
- return NULL;
- return base::GetFunctionPointerFromNativeLibrary(library_, function_name);
- }
+ // Opens the given library and manages its lifetime.
+ explicit ScopedNativeLibrary(const FilePath& library_path);
+ ~ScopedNativeLibrary();
+
+ // Returns true if there's a valid library loaded.
+ bool is_valid() const { return !!library_; }
+
+ void* GetFunctionPointer(const char* function_name) const;
+
+ // Takes ownership of the given library handle. Any existing handle will
+ // be freed.
+ void Reset(NativeLibrary library);
+
+ // Returns the native library handle and removes it from this object. The
+ // caller must manage the lifetime of the handle.
+ NativeLibrary Release();
+
private:
- base::NativeLibrary library_;
+ NativeLibrary library_;
+
DISALLOW_COPY_AND_ASSIGN(ScopedNativeLibrary);
};
« no previous file with comments | « no previous file | base/scoped_native_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698