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

Unified Diff: ui/ozone/ozone_platform.cc

Issue 284253006: ozone: Make sure the platform doesn't get initialized more than once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | no next file » | 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 730be363bec8176fa8ae609cab292b08855a9fbe..7dc860595f12a3a499de8e0f82b25f35b772ac1a 100644
--- a/ui/ozone/ozone_platform.cc
+++ b/ui/ozone/ozone_platform.cc
@@ -17,6 +17,9 @@ namespace ui {
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.
@@ -43,6 +46,8 @@ std::string GetPlatformName() {
OzonePlatform::OzonePlatform() {
CHECK(!instance_) << "There should only be a single OzonePlatform.";
instance_ = this;
+ g_platform_initialized_ui = false;
+ g_platform_initialized_gpu = false;
}
OzonePlatform::~OzonePlatform() {
@@ -53,6 +58,9 @@ OzonePlatform::~OzonePlatform() {
// static
void OzonePlatform::InitializeForUI() {
CreateInstance();
+ if (g_platform_initialized_ui)
+ return;
+ g_platform_initialized_ui = true;
instance_->InitializeUI();
ui::InputMethodContextFactoryOzone::SetInstance(
instance_->GetInputMethodContextFactoryOzone());
@@ -61,6 +69,9 @@ void OzonePlatform::InitializeForUI() {
// static
void OzonePlatform::InitializeForGPU() {
CreateInstance();
+ if (g_platform_initialized_gpu)
+ return;
+ g_platform_initialized_gpu = true;
instance_->InitializeGPU();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698