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

Unified Diff: ui/ozone/ozone_platform.cc

Issue 313963007: ozone: Implement PlatformObject<T> for platform-specific objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix namespacing Created 6 years, 6 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/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());
}
}
« no previous file with comments | « ui/ozone/ozone.gyp ('k') | ui/ozone/ozone_platform_list.h » ('j') | ui/ozone/platform_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698