Index: ui/platform_window/platform_window_factory.cc |
diff --git a/ui/platform_window/platform_window_factory.cc b/ui/platform_window/platform_window_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e9c30d7e9ca65218d1553f6506c8fb412a8563d |
--- /dev/null |
+++ b/ui/platform_window/platform_window_factory.cc |
@@ -0,0 +1,36 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/platform_window/platform_window_factory.h" |
+ |
+#include "base/at_exit.h" |
+#include "base/bind.h" |
+#include "base/logging.h" |
+ |
+namespace ui { |
+ |
+namespace { |
+ |
+PlatformWindowFactory* instance = NULL; |
+ |
+} // namespace |
+ |
+PlatformWindowFactory::PlatformWindowFactory() { |
+ CHECK(!instance) << "There can only be a single PlatformWindowFactory."; |
+ instance = this; |
+ base::AtExitManager::RegisterTask( |
+ base::Bind(&base::DeletePointer<PlatformWindowFactory>, instance)); |
+} |
+ |
+PlatformWindowFactory::~PlatformWindowFactory() { |
+ CHECK_EQ(instance, this); |
+ instance = NULL; |
+} |
+ |
+// static |
+PlatformWindowFactory* PlatformWindowFactory::GetInstance() { |
+ return instance; |
+} |
+ |
+} // namespace ui |