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

Unified Diff: ui/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: rebase 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
« no previous file with comments | « ui/ozone/ozone_platform.h ('k') | ui/ozone/ozone_platform_list.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 9715e13213b3e48df64341a6050ccb1bbf7eb54b..a0840058ed42764914e0f235a2ed90a1458f73f9 100644
--- a/ui/ozone/ozone_platform.cc
+++ b/ui/ozone/ozone_platform.cc
@@ -5,9 +5,38 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "ui/ozone/ozone_platform.h"
+#include "ui/ozone/ozone_platform_list.h"
+#include "ui/ozone/ozone_switches.h"
namespace ui {
+namespace {
+
+// Helper to construct an OzonePlatform by name using the platform list.
+OzonePlatform* CreatePlatform(const std::string& platform_name) {
+ // The first platform is the defualt.
+ if (platform_name == "default" && kOzonePlatformCount > 0)
+ return kOzonePlatforms[0].constructor();
+
+ // Otherwise, search for a matching platform in the list.
+ for (int i = 0; i < kOzonePlatformCount; ++i)
+ if (platform_name == kOzonePlatforms[i].name)
+ return kOzonePlatforms[i].constructor();
+
+ LOG(FATAL) << "Invalid ozone platform: " << platform_name;
+ return NULL; // not reached
+}
+
+// Returns the name of the platform to use (value of --ozone-platform flag).
+std::string GetRequestedPlatform() {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform))
+ return "default";
+ return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kOzonePlatform);
+}
+
+} // namespace
+
OzonePlatform::OzonePlatform() {}
OzonePlatform::~OzonePlatform() {
@@ -20,7 +49,7 @@ void OzonePlatform::Initialize() {
if (instance_)
return;
- instance_ = CreateDefaultOzonePlatform();
+ instance_ = CreatePlatform(GetRequestedPlatform());
// Inject ozone interfaces.
gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
« no previous file with comments | « ui/ozone/ozone_platform.h ('k') | ui/ozone/ozone_platform_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698