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

Unified Diff: ui/ozone/ozone_platform.cc

Issue 274193005: ozone: Allow loading the platform implementation from a system library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/ozone_platform.cc
diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
index e8199b2ce93f86846235f73b8459b9f650859d5f..7bfa1fd167013d8d6517fad60ca0ac6e0dfb9cd4 100644
--- a/ui/ozone/ozone_platform.cc
+++ b/ui/ozone/ozone_platform.cc
@@ -5,6 +5,9 @@
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
+#include "base/scoped_native_library.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_restrictions.h"
#include "ui/base/cursor/ozone/cursor_factory_ozone.h"
#include "ui/events/ozone/event_factory_ozone.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
@@ -20,11 +23,37 @@ namespace {
// Helper to construct an OzonePlatform by name using the platform list.
OzonePlatform* CreatePlatform(const std::string& platform_name) {
// Search for a matching platform in the list.
- for (int i = 0; i < kOzonePlatformCount; ++i)
+ for (int i = 0; i < kOzonePlatformCount; ++i) {
if (platform_name == kOzonePlatforms[i].name)
return kOzonePlatforms[i].constructor();
-
- LOG(FATAL) << "Invalid ozone platform: " << platform_name;
+ }
+
+ // Try to load the module for the paltform.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::NativeLibraryLoadError load_error;
+ base::string16 platform_module_path =
+ base::GetNativeLibraryName(base::ASCIIToUTF16(platform_name));
+ const char kPlatformConstructor[] = "CreateOzonePlatform";
+ base::NativeLibrary platform_module = base::LoadNativeLibrary(
+ base::FilePath(base::UTF16ToASCII(platform_module_path)), &load_error);
+ if (!platform_module) {
+ LOG(FATAL) << "Failed to load library (error: " << load_error.ToString()
+ << ")";
+ } else {
+ OzonePlatformConstructor platform_constructor =
+ reinterpret_cast<OzonePlatformConstructor>(
+ base::GetFunctionPointerFromNativeLibrary(platform_module,
+ kPlatformConstructor));
+ if (platform_constructor) {
+ return platform_constructor();
+ } else {
+ LOG(FATAL) << "Module " << platform_module_path
+ << " does not have the constructor function ("
+ << kPlatformConstructor << ") to initialize the platform.";
+ }
+ }
+
+ NOTREACHED();
return NULL; // not reached
}
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698