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

Unified Diff: ui/base/ozone/ozone_platform.cc

Issue 44053005: Implement --ozone-platform flag to select OzonePlatform implementation at runtime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove obsolete CreateDefaultOzonePlatform() prototype Created 7 years, 2 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
Index: ui/base/ozone/ozone_platform.cc
diff --git a/ui/base/ozone/ozone_platform.cc b/ui/base/ozone/ozone_platform.cc
index ea638c24719b2ee256cbe9829feeb3e28b6f4fbb..28f24cd0b8fd45f3339b8bd19f64a6dd5cec10a2 100644
--- a/ui/base/ozone/ozone_platform.cc
+++ b/ui/base/ozone/ozone_platform.cc
@@ -5,9 +5,31 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "ui/base/ozone/ozone_platform.h"
+#include "ui/base/ozone/ozone_platform_list.h"
+#include "ui/base/ozone/ozone_switches.h"
namespace ui {
+namespace {
+
+OzonePlatform* CreatePlatform(const std::string& platform_name) {
+ for (int i = 0; i < kOzonePlatformCount; ++i)
rjkroege 2013/10/28 16:02:15 default maps to the first element in the list righ
spang 2013/10/28 16:27:39 Done.
+ if (platform_name == kOzonePlatforms[i].name || platform_name == "default")
+ return kOzonePlatforms[i].constructor();
+
+ LOG(FATAL) << "Invalid ozone platform: " << platform_name;
+ return NULL; // not reached
+}
+
+std::string GetRequestedPlatform() {
rjkroege 2013/10/28 16:02:15 maybe add a comment here saying "returns the name
spang 2013/10/28 16:27:39 Done.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform))
+ return "default";
+ return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kOzonePlatform);
+}
+
+} // namespace
+
OzonePlatform::OzonePlatform() {}
OzonePlatform::~OzonePlatform() {
@@ -17,7 +39,7 @@ OzonePlatform::~OzonePlatform() {
// static
OzonePlatform* OzonePlatform::Create() {
- OzonePlatform* platform = CreateDefaultOzonePlatform();
+ OzonePlatform* platform = CreatePlatform(GetRequestedPlatform());
gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone());
ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone());

Powered by Google App Engine
This is Rietveld 408576698