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

Unified Diff: athena/env/athena_env_impl.cc

Issue 558823002: Fix crash during shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « athena/athena.gyp ('k') | athena/env/athena_env_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/env/athena_env_impl.cc
diff --git a/athena/env/athena_env_impl.cc b/athena/env/athena_env_impl.cc
index d94291bbfda37b54ba0e7205dd3a07ba09459101..98658ca6baed0ff108cb2d6537f8f981ac3ce446 100644
--- a/athena/env/athena_env_impl.cc
+++ b/athena/env/athena_env_impl.cc
@@ -34,6 +34,61 @@ namespace {
AthenaEnv* instance = NULL;
+// Screen object used during shutdown.
+gfx::Screen* screen_for_shutdown = NULL;
+
+class ScreenForShutdown : public gfx::Screen {
sadrul 2014/09/09 23:27:44 Any chance this could be consolidated with the ash
oshima 2014/09/09 23:52:46 That'll be done when we switch the display code to
+ 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 +237,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);
@@ -233,6 +288,8 @@ class AthenaEnvImpl : public AthenaEnv,
scoped_ptr<ui::DisplayConfigurator> display_configurator_;
scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
+ std::vector<base::Closure> terminating_callbacks_;
+
sadrul 2014/09/09 23:27:44 This doesn't seem to be used?
oshima 2014/09/09 23:52:46 Oops, forgot to cleanup. Removed.
DISALLOW_COPY_AND_ASSIGN(AthenaEnvImpl);
};
« no previous file with comments | « athena/athena.gyp ('k') | athena/env/athena_env_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698