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

Unified Diff: ui/aura/root_window.cc

Issue 9535025: Remove the singleton instance get/delete methods from RootWindow (yay) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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/aura/root_window.h ('k') | ui/aura/root_window_host_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window.cc
===================================================================
--- ui/aura/root_window.cc (revision 124527)
+++ ui/aura/root_window.cc (working copy)
@@ -83,19 +83,52 @@
////////////////////////////////////////////////////////////////////////////////
// RootWindow, public:
-// static
-RootWindow* RootWindow::GetInstance() {
- if (!instance_) {
- instance_ = new RootWindow;
- instance_->Init();
- }
- return instance_;
+RootWindow::RootWindow()
+ : Window(NULL),
+ host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
+ ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
+ mouse_button_flags_(0),
+ last_cursor_(kCursorNull),
+ cursor_shown_(true),
+ ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))),
+ capture_window_(NULL),
+ mouse_pressed_handler_(NULL),
+ mouse_moved_handler_(NULL),
+ focused_window_(NULL),
+ touch_event_handler_(NULL),
+ gesture_handler_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ gesture_recognizer_(GestureRecognizer::Create(this))),
+ synthesize_mouse_move_(false),
+ waiting_on_compositing_end_(false),
+ draw_on_compositing_end_(false) {
+ SetName("RootWindow");
+ gfx::Screen::SetInstance(screen_);
+ last_mouse_location_ = host_->QueryMouseLocation();
+
+ ui::Compositor::Initialize(false);
+ compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
+ host_->GetSize()));
+ DCHECK(compositor_.get());
+ compositor_->AddObserver(this);
+ Init();
}
-// static
-void RootWindow::DeleteInstance() {
- delete instance_;
- instance_ = NULL;
+RootWindow::~RootWindow() {
+ compositor_->RemoveObserver(this);
+ // Make sure to destroy the compositor before terminating so that state is
+ // cleared and we don't hit asserts.
+ compositor_.reset();
+
+ // Tear down in reverse. Frees any references held by the host.
+ host_.reset(NULL);
+
+ // An observer may have been added by an animation on the RootWindow.
+ layer()->GetAnimator()->RemoveObserver(this);
+ ui::Compositor::Terminate();
+ if (instance_ == this)
+ instance_ = NULL;
}
void RootWindow::ShowRootWindow() {
@@ -453,53 +486,6 @@
////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
-RootWindow::RootWindow()
- : Window(NULL),
- host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
- ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
- mouse_button_flags_(0),
- last_cursor_(kCursorNull),
- cursor_shown_(true),
- ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))),
- capture_window_(NULL),
- mouse_pressed_handler_(NULL),
- mouse_moved_handler_(NULL),
- focused_window_(NULL),
- touch_event_handler_(NULL),
- gesture_handler_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- gesture_recognizer_(GestureRecognizer::Create(this))),
- synthesize_mouse_move_(false),
- waiting_on_compositing_end_(false),
- draw_on_compositing_end_(false) {
- SetName("RootWindow");
- gfx::Screen::SetInstance(screen_);
- last_mouse_location_ = host_->QueryMouseLocation();
-
- ui::Compositor::Initialize(false);
- compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
- host_->GetSize()));
- DCHECK(compositor_.get());
- compositor_->AddObserver(this);
-}
-
-RootWindow::~RootWindow() {
- compositor_->RemoveObserver(this);
- // Make sure to destroy the compositor before terminating so that state is
- // cleared and we don't hit asserts.
- compositor_.reset();
-
- // Tear down in reverse. Frees any references held by the host.
- host_.reset(NULL);
-
- // An observer may have been added by an animation on the RootWindow.
- layer()->GetAnimator()->RemoveObserver(this);
- ui::Compositor::Terminate();
- if (instance_ == this)
- instance_ = NULL;
-}
-
void RootWindow::HandleMouseCaptureChanged(Window* old_capture_window) {
if (capture_window_)
host_->SetCapture();
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_host_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698