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

Unified Diff: ui/ozone/ozone_platform.cc

Issue 275263002: [wip] ozonex: X11 backend for ozone. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge 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 | « ui/ozone/ozone.gyp ('k') | ui/ozone/platform/dri/dri_surface_factory.h » ('j') | 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 12925c04ed25344d46baf5b3b8111307a2307824..26ee825106047300561e98d7d558cf8fd38f73a1 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/ozone/ozone_platform.h"
#include "ui/ozone/ozone_platform_list.h"
#include "ui/ozone/ozone_switches.h"
@@ -19,11 +22,37 @@ bool g_platform_initialized_gpu = false;
// 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();
+ }
+
+ // 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.";
+ }
+ }
- LOG(FATAL) << "Invalid ozone platform: " << platform_name;
+ NOTREACHED();
return NULL; // not reached
}
« no previous file with comments | « ui/ozone/ozone.gyp ('k') | ui/ozone/platform/dri/dri_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698