Commit ef589afc authored by oshima@chromium.org's avatar oshima@chromium.org

Delete desktop/shell instance correctly upon shutdown.

* Moved parts->PostMainMessageLoopRun call from PostDestroyThreads to the right place (PostMainMessageLoopRun() method)
* Renamed Shell::DeleteInstanceForTesting to DeleteInstance as this is no longer for testing.

BUG=106070
TEST=browser_tests on aura will not crash as described in the bug

Review URL: http://codereview.chromium.org/8774029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112836 0039d316-1c4b-4281-b951-d872f2087c98
parent ede5e61a
...@@ -2002,6 +2002,9 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() { ...@@ -2002,6 +2002,9 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
// Disarm the startup hang detector time bomb if it is still Arm'ed. // Disarm the startup hang detector time bomb if it is still Arm'ed.
startup_watcher_->Disarm(); startup_watcher_->Disarm();
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
#if defined(OS_WIN) #if defined(OS_WIN)
// If it's the first run, log the search engine chosen. We wait until // If it's the first run, log the search engine chosen. We wait until
// shutdown because otherwise we can't be sure the user has finished // shutdown because otherwise we can't be sure the user has finished
...@@ -2102,9 +2105,6 @@ void ChromeBrowserMainParts::PostDestroyThreads() { ...@@ -2102,9 +2105,6 @@ void ChromeBrowserMainParts::PostDestroyThreads() {
// to bypass this code. Perhaps we need a *final* hook that is called on all // to bypass this code. Perhaps we need a *final* hook that is called on all
// paths from content/browser/browser_main. // paths from content/browser/browser_main.
CHECK(MetricsService::UmaMetricsProperlyShutdown()); CHECK(MetricsService::UmaMetricsProperlyShutdown());
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
} }
// Public members: // Public members:
......
...@@ -28,3 +28,8 @@ void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() { ...@@ -28,3 +28,8 @@ void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() {
// Make sure the singleton ScreenOrientationListener object is created. // Make sure the singleton ScreenOrientationListener object is created.
ScreenOrientationListener::GetInstance(); ScreenOrientationListener::GetInstance();
} }
void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() {
aura_shell::Shell::DeleteInstance();
aura::Desktop::DeleteInstance();
}
...@@ -14,6 +14,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts { ...@@ -14,6 +14,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
ChromeBrowserMainExtraPartsAura(); ChromeBrowserMainExtraPartsAura();
virtual void PostBrowserProcessInit() OVERRIDE; virtual void PostBrowserProcessInit() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
private: private:
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura); DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura);
......
...@@ -592,7 +592,7 @@ void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) { ...@@ -592,7 +592,7 @@ void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) {
} }
void DesktopHostLinux::WillDestroyCurrentMessageLoop() { void DesktopHostLinux::WillDestroyCurrentMessageLoop() {
desktop_->DeleteInstance(); aura::Desktop::DeleteInstance();
} }
bool DesktopHostLinux::IsWindowManagerPresent() { bool DesktopHostLinux::IsWindowManagerPresent() {
......
...@@ -35,7 +35,8 @@ ShelfLayoutController::ShelfLayoutController(views::Widget* launcher, ...@@ -35,7 +35,8 @@ ShelfLayoutController::ShelfLayoutController(views::Widget* launcher,
} }
ShelfLayoutController::~ShelfLayoutController() { ShelfLayoutController::~ShelfLayoutController() {
GetLayer(launcher_)->GetAnimator()->RemoveObserver(this); // Do not try to remove observer from layer as the Launcher is
// already deleted.
} }
void ShelfLayoutController::LayoutShelf() { void ShelfLayoutController::LayoutShelf() {
......
...@@ -127,6 +127,21 @@ Shell::~Shell() { ...@@ -127,6 +127,21 @@ Shell::~Shell() {
RemoveDesktopEventFilter(tooltip_manager_.get()); RemoveDesktopEventFilter(tooltip_manager_.get());
aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey, aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey,
NULL); NULL);
// Make sure we delete WorkspaceController before launcher is
// deleted as it has a reference to launcher model.
workspace_controller_.reset();
launcher_.reset();
// Delete containers now so that child windows does not access
// observers when they are destructed. This has to be after launcher
// is destructed because launcher closes the widget in its destructor.
aura::Desktop* desktop_window = aura::Desktop::GetInstance();
while (!desktop_window->children().empty()) {
aura::Window* child = desktop_window->children()[0];
delete child;
}
tooltip_manager_.reset(); tooltip_manager_.reset();
// Drag drop controller needs a valid shell instance. We destroy it first. // Drag drop controller needs a valid shell instance. We destroy it first.
...@@ -134,10 +149,6 @@ Shell::~Shell() { ...@@ -134,10 +149,6 @@ Shell::~Shell() {
DCHECK(instance_ == this); DCHECK(instance_ == this);
instance_ = NULL; instance_ = NULL;
// Make sure we delete WorkspaceController before launcher is
// deleted as it has a reference to launcher model.
workspace_controller_.reset();
} }
// static // static
...@@ -155,7 +166,7 @@ Shell* Shell::GetInstance() { ...@@ -155,7 +166,7 @@ Shell* Shell::GetInstance() {
} }
// static // static
void Shell::DeleteInstanceForTesting() { void Shell::DeleteInstance() {
delete instance_; delete instance_;
instance_ = NULL; instance_ = NULL;
} }
......
...@@ -54,7 +54,7 @@ class AURA_SHELL_EXPORT Shell { ...@@ -54,7 +54,7 @@ class AURA_SHELL_EXPORT Shell {
// Should never be called before |CreateInstance()|. // Should never be called before |CreateInstance()|.
static Shell* GetInstance(); static Shell* GetInstance();
static void DeleteInstanceForTesting(); static void DeleteInstance();
aura::Window* GetContainer(int container_id); aura::Window* GetContainer(int container_id);
const aura::Window* GetContainer(int container_id) const; const aura::Window* GetContainer(int container_id) const;
......
...@@ -27,7 +27,7 @@ void AuraShellTestBase::TearDown() { ...@@ -27,7 +27,7 @@ void AuraShellTestBase::TearDown() {
RunAllPendingInMessageLoop(); RunAllPendingInMessageLoop();
// Tear down the shell. // Tear down the shell.
aura_shell::Shell::DeleteInstanceForTesting(); aura_shell::Shell::DeleteInstance();
aura::test::AuraTestBase::TearDown(); aura::test::AuraTestBase::TearDown();
} }
......
...@@ -372,10 +372,10 @@ void NativeWidgetAura::Close() { ...@@ -372,10 +372,10 @@ void NativeWidgetAura::Close() {
// and ownership is WIDGET_OWNS_NATIVE_WIDGET. // and ownership is WIDGET_OWNS_NATIVE_WIDGET.
DCHECK(window_ || DCHECK(window_ ||
ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET);
if (window_) if (window_) {
Hide(); Hide();
window_->SetIntProperty(aura::kModalKey, 0);
window_->SetIntProperty(aura::kModalKey, 0); }
if (!close_widget_factory_.HasWeakPtrs()) { if (!close_widget_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostTask( MessageLoop::current()->PostTask(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment