Commit 13ba9b2b authored by oshima's avatar oshima Committed by Commit bot

Fix crash during shutdown

* keep alive has to be incremented at startup.
* exclude more code that depends on ash.
* create a screen for shutdown

Minor cleanup
* remove all containers when ScreenManager is deleted.

BUG=397167, 401044
TEST=AthenaShutdownTest.Shutdown

Review URL: https://codereview.chromium.org/558823002

Cr-Commit-Position: refs/heads/master@{#294083}
parent 6a4d1490
......@@ -244,6 +244,7 @@
'activity/activity_manager_unittest.cc',
'util/fill_layout_manager_unittest.cc',
'content/app_activity_unittest.cc',
'env/athena_env_unittest.cc',
'home/athena_start_page_view_unittest.cc',
'home/home_card_gesture_manager_unittest.cc',
'home/home_card_unittest.cc',
......
......@@ -34,6 +34,63 @@ namespace {
AthenaEnv* instance = NULL;
// Screen object used during shutdown.
gfx::Screen* screen_for_shutdown = NULL;
// TODO(flackr:oshima): Remove this once athena switches to share
// ash::DisplayManager.
class ScreenForShutdown : public gfx::Screen {
public:
// Creates and sets the screen for shutdown. Deletes existing one if any.
static void Create(const gfx::Screen* screen) {
delete screen_for_shutdown;
screen_for_shutdown = new ScreenForShutdown(screen->GetPrimaryDisplay());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
screen_for_shutdown);
}
private:
explicit ScreenForShutdown(const gfx::Display& primary_display)
: primary_display_(primary_display) {}
// gfx::Screen overrides:
virtual bool IsDIPEnabled() OVERRIDE { return true; }
virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); }
virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { return NULL; }
virtual gfx::NativeWindow GetWindowAtScreenPoint(
const gfx::Point& point) OVERRIDE {
return NULL;
}
virtual int GetNumDisplays() const OVERRIDE { return 1; }
virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE {
std::vector<gfx::Display> displays(1, primary_display_);
return displays;
}
virtual gfx::Display GetDisplayNearestWindow(
gfx::NativeView view) const OVERRIDE {
return primary_display_;
}
virtual gfx::Display GetDisplayNearestPoint(
const gfx::Point& point) const OVERRIDE {
return primary_display_;
}
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE {
return primary_display_;
}
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE {
return primary_display_;
}
virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
NOTREACHED() << "Observer should not be added during shutdown";
}
virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {}
const gfx::Display primary_display_;
DISALLOW_COPY_AND_ASSIGN(ScreenForShutdown);
};
// A class that bridges the gap between CursorManager and Aura. It borrows
// heavily from AshNativeCursorManager.
class AthenaNativeCursorManager : public wm::NativeCursorManager {
......@@ -182,9 +239,9 @@ class AthenaEnvImpl : public AthenaEnv,
input_method_filter_.reset();
host_.reset();
screen_.reset();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
ScreenForShutdown::Create(screen_.get());
screen_.reset();
aura::Env::DeleteInstance();
display_configurator_->RemoveObserver(this);
......
// 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 "athena/env/public/athena_env.h"
#include "athena/test/athena_test_base.h"
#include "base/bind.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
namespace athena {
namespace {
class AthenaShutdownTest : public test::AthenaTestBase {
public:
AthenaShutdownTest() {}
virtual ~AthenaShutdownTest() {}
virtual void TearDown() {
test::AthenaTestBase::TearDown();
ASSERT_NE(
gfx::Display::kInvalidDisplayID,
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
}
private:
DISALLOW_COPY_AND_ASSIGN(AthenaShutdownTest);
};
} // namespace
// gfx::Screen should be accessible after shutdown.
TEST_F(AthenaShutdownTest, Shutdown) {
}
} // namespace athena
......@@ -240,6 +240,13 @@ ScreenManagerImpl::~ScreenManagerImpl() {
root_window_->RemovePreTargetHandler(focus_controller);
aura::client::SetActivationClient(root_window_, NULL);
aura::client::SetFocusClient(root_window_, NULL);
aura::Window::Windows children = root_window_->children();
// Close All children:
for (aura::Window::Windows::iterator iter = children.begin();
iter != children.end();
++iter) {
delete *iter;
}
instance = NULL;
}
......
......@@ -35,9 +35,6 @@ namespace athena {
typedef test::AthenaTestBase WindowManagerTest;
TEST_F(WindowManagerTest, Empty) {
}
TEST_F(WindowManagerTest, OverviewModeBasics) {
aura::test::TestWindowDelegate delegate;
scoped_ptr<aura::Window> first(CreateWindow(&delegate));
......
......@@ -627,11 +627,11 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
#endif
data_promo_notification_.reset(new DataPromoNotification());
#if !defined(USE_ATHENA)
// TODO(oshima): Support accessibility on athena. crbug.com/408733.
keyboard_event_rewriters_.reset(new EventRewriterController());
keyboard_event_rewriters_->AddEventRewriter(
scoped_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter()));
#if !defined(USE_ATHENA)
// TODO(oshima): Support accessibility on athena. crbug.com/408733.
keyboard_event_rewriters_->AddEventRewriter(scoped_ptr<ui::EventRewriter>(
new EventRewriter(ash::Shell::GetInstance()->sticky_keys_controller())));
keyboard_event_rewriters_->Init();
......@@ -705,7 +705,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
power_button_observer_.reset();
idle_action_warning_observer_.reset();
#if !defined(USE_ATHENA)
MagnificationManager::Shutdown();
#endif
AccessibilityManager::Shutdown();
media::SoundsManager::Shutdown();
......
......@@ -6,26 +6,36 @@
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/main/public/athena_launcher.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h"
namespace {
class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts {
public:
ChromeBrowserMainExtraPartsAthena() {}
ChromeBrowserMainExtraPartsAthena() {
}
virtual ~ChromeBrowserMainExtraPartsAthena() {}
private:
// Overridden from ChromeBrowserMainExtraParts:
virtual void PreProfileInit() OVERRIDE {
athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE));
}
virtual void PostProfileInit() OVERRIDE {
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableZeroBrowsersOpenForTests)) {
chrome::IncrementKeepAliveCount();
}
Profile* profile =
g_browser_process->profile_manager()->GetActiveUserProfile();
// TODO(oshima|polukhin): Start OOBE/Login process.
......@@ -34,7 +44,6 @@ class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts {
}
virtual void PostMainMessageLoopRun() OVERRIDE { athena::ShutdownAthena(); }
private:
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAthena);
};
......
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