| Index: ui/ozone/ozone_platform.cc
|
| diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
|
| index 12925c04ed25344d46baf5b3b8111307a2307824..358556497938d2e4f7b04106c446b755b8d5cae8 100644
|
| --- a/ui/ozone/ozone_platform.cc
|
| +++ b/ui/ozone/ozone_platform.cc
|
| @@ -6,8 +6,9 @@
|
| #include "base/debug/trace_event.h"
|
| #include "base/logging.h"
|
| #include "ui/ozone/ozone_platform.h"
|
| -#include "ui/ozone/ozone_platform_list.h"
|
| #include "ui/ozone/ozone_switches.h"
|
| +#include "ui/ozone/platform_object.h"
|
| +#include "ui/ozone/platform_selection.h"
|
|
|
| namespace ui {
|
|
|
| @@ -16,29 +17,8 @@ namespace {
|
| bool g_platform_initialized_ui = false;
|
| 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)
|
| - 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 GetPlatformName() {
|
| - // The first platform is the default.
|
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform) &&
|
| - kOzonePlatformCount > 0)
|
| - return kOzonePlatforms[0].name;
|
| - return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| - switches::kOzonePlatform);
|
| }
|
|
|
| -} // namespace
|
| -
|
| OzonePlatform::OzonePlatform() {
|
| CHECK(!instance_) << "There should only be a single OzonePlatform.";
|
| instance_ = this;
|
| @@ -78,9 +58,15 @@ OzonePlatform* OzonePlatform::GetInstance() {
|
| // static
|
| void OzonePlatform::CreateInstance() {
|
| if (!instance_) {
|
| - std::string platform = GetPlatformName();
|
| - TRACE_EVENT1("ozone", "OzonePlatform::Initialize", "platform", platform);
|
| - CreatePlatform(platform);
|
| + TRACE_EVENT1("ozone",
|
| + "OzonePlatform::Initialize",
|
| + "platform",
|
| + GetOzonePlatformName());
|
| + scoped_ptr<OzonePlatform> platform =
|
| + PlatformObject<OzonePlatform>::Create();
|
| +
|
| + // TODO(spang): Currently need to leak this object.
|
| + CHECK_EQ(instance_, platform.release());
|
| }
|
| }
|
|
|
|
|