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

Unified Diff: ui/ozone/ozone_platform.cc

Issue 291473002: ozone: Initialize a subsystem only if necessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r270817 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_platform.h ('k') | ui/ozone/platform/caca/ozone_platform_caca.cc » ('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 e8199b2ce93f86846235f73b8459b9f650859d5f..730be363bec8176fa8ae609cab292b08855a9fbe 100644
--- a/ui/ozone/ozone_platform.cc
+++ b/ui/ozone/ozone_platform.cc
@@ -40,31 +40,28 @@ std::string GetPlatformName() {
} // namespace
-OzonePlatform::OzonePlatform() {}
+OzonePlatform::OzonePlatform() {
+ CHECK(!instance_) << "There should only be a single OzonePlatform.";
+ instance_ = this;
+}
OzonePlatform::~OzonePlatform() {
- gfx::SurfaceFactoryOzone::SetInstance(NULL);
- ui::EventFactoryOzone::SetInstance(NULL);
- ui::CursorFactoryOzone::SetInstance(NULL);
+ CHECK_EQ(instance_, this);
+ instance_ = NULL;
}
// static
-void OzonePlatform::Initialize() {
- if (instance_)
- return;
-
- std::string platform = GetPlatformName();
-
- TRACE_EVENT1("ozone", "OzonePlatform::Initialize", "platform", platform);
-
- instance_ = CreatePlatform(platform);
-
- // Inject ozone interfaces.
- gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
- ui::EventFactoryOzone::SetInstance(instance_->GetEventFactoryOzone());
+void OzonePlatform::InitializeForUI() {
+ CreateInstance();
+ instance_->InitializeUI();
ui::InputMethodContextFactoryOzone::SetInstance(
instance_->GetInputMethodContextFactoryOzone());
- ui::CursorFactoryOzone::SetInstance(instance_->GetCursorFactoryOzone());
+}
+
+// static
+void OzonePlatform::InitializeForGPU() {
+ CreateInstance();
+ instance_->InitializeGPU();
}
// static
@@ -74,6 +71,15 @@ OzonePlatform* OzonePlatform::GetInstance() {
}
// static
+void OzonePlatform::CreateInstance() {
+ if (!instance_) {
+ std::string platform = GetPlatformName();
+ TRACE_EVENT1("ozone", "OzonePlatform::Initialize", "platform", platform);
+ CreatePlatform(platform);
+ }
+}
+
+// static
OzonePlatform* OzonePlatform::instance_;
} // namespace ui
« no previous file with comments | « ui/ozone/ozone_platform.h ('k') | ui/ozone/platform/caca/ozone_platform_caca.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698