summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2014-12-02 18:17:29 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-03 02:18:17 +0000
commite94ef4a31d0591d11421fa34065d3bc0dcd1302a (patch)
tree9ee89654a8fb50cf2c9635e580cd7c14db9c6138
parent6450d054c6846df45ffb656c334d432f587a1dd3 (diff)
downloadchromium_src-e94ef4a31d0591d11421fa34065d3bc0dcd1302a.zip
chromium_src-e94ef4a31d0591d11421fa34065d3bc0dcd1302a.tar.gz
chromium_src-e94ef4a31d0591d11421fa34065d3bc0dcd1302a.tar.bz2
Revert of Speculative fix for sticky keys overlay crash. (patchset #2 id:20001 of https://codereview.chromium.org/754763005/)
Reason for revert: StickyKeysBrowserTest leaking memory. Original issue's description: > Speculative fix for sticky keys overlay crash. > > The new test case reproduces the same stack trace as in the bug, so it's very > probable that this case is causing the crash. > > BUG=435600 > > Committed: https://crrev.com/9391c0e45bc3ae50008d0aebf11437550e7f38c6 > Cr-Commit-Position: refs/heads/master@{#306504} TBR=jamescook@chromium.org,tengs@chromium.org NOTREECHECKS=true NOTRY=true BUG=435600 Review URL: https://codereview.chromium.org/757433005 Cr-Commit-Position: refs/heads/master@{#306529}
-rw-r--r--ash/sticky_keys/sticky_keys_overlay.cc12
-rw-r--r--ash/sticky_keys/sticky_keys_overlay.h6
-rw-r--r--ash/sticky_keys/sticky_keys_overlay_unittest.cc28
3 files changed, 6 insertions, 40 deletions
diff --git a/ash/sticky_keys/sticky_keys_overlay.cc b/ash/sticky_keys/sticky_keys_overlay.cc
index 464d9f6..0766ba25 100644
--- a/ash/sticky_keys/sticky_keys_overlay.cc
+++ b/ash/sticky_keys/sticky_keys_overlay.cc
@@ -109,7 +109,6 @@ class StickyKeysOverlayView : public views::WidgetDelegateView {
// views::WidgetDelegateView overrides:
void OnPaint(gfx::Canvas* canvas) override;
- void DeleteDelegate() override;
void SetKeyState(ui::EventFlags modifier, StickyKeyState state);
@@ -167,13 +166,6 @@ void StickyKeysOverlayView::OnPaint(gfx::Canvas* canvas) {
views::WidgetDelegateView::OnPaint(canvas);
}
-void StickyKeysOverlayView::DeleteDelegate() {
- // The ownership of a WidgetDelegateView is kind of tricky. It has the
- // lifetime semantics of both a View and a WidgetDelegate. We should just rely
- // on the Views semantics and do nothing here. This object will be deleted
- // when the parent widget is deleted.
-}
-
void StickyKeysOverlayView::SetKeyState(ui::EventFlags modifier,
StickyKeyState state) {
ModifierLabelMap::iterator it = modifier_label_map_.find(modifier);
@@ -287,10 +279,6 @@ StickyKeyState StickyKeysOverlay::GetModifierKeyState(
return overlay_view_->GetKeyState(modifier);
}
-views::Widget* StickyKeysOverlay::GetWidgetForTesting() {
- return overlay_widget_.get();
-}
-
gfx::Rect StickyKeysOverlay::CalculateOverlayBounds() {
int x = is_visible_ ? kHorizontalOverlayOffset : -widget_size_.width();
return gfx::Rect(gfx::Point(x, kVerticalOverlayOffset), widget_size_);
diff --git a/ash/sticky_keys/sticky_keys_overlay.h b/ash/sticky_keys/sticky_keys_overlay.h
index 3ab23464..6391794 100644
--- a/ash/sticky_keys/sticky_keys_overlay.h
+++ b/ash/sticky_keys/sticky_keys_overlay.h
@@ -51,10 +51,6 @@ class ASH_EXPORT StickyKeysOverlay : public ui::LayerAnimationObserver {
// animating, the returned value is the target of the animation.
bool is_visible() { return is_visible_; }
- // Returns the underlying views::Widget for testing purposes. The returned
- // widget is owned by StickyKeysOverlay.
- views::Widget* GetWidgetForTesting();
-
private:
// Returns the current bounds of the overlay, which is based on visibility.
gfx::Rect CalculateOverlayBounds();
@@ -66,7 +62,7 @@ class ASH_EXPORT StickyKeysOverlay : public ui::LayerAnimationObserver {
bool is_visible_;
scoped_ptr<views::Widget> overlay_widget_;
- // The |overlay_view_| will be owned by |overlay_widget_|.
+ // Ownership of |overlay_view_| is passed to the view heirarchy.
StickyKeysOverlayView* overlay_view_;
gfx::Size widget_size_;
};
diff --git a/ash/sticky_keys/sticky_keys_overlay_unittest.cc b/ash/sticky_keys/sticky_keys_overlay_unittest.cc
index 9a19e09..b607825 100644
--- a/ash/sticky_keys/sticky_keys_overlay_unittest.cc
+++ b/ash/sticky_keys/sticky_keys_overlay_unittest.cc
@@ -8,11 +8,14 @@
#include "ash/sticky_keys/sticky_keys_controller.h"
#include "ash/test/ash_test_base.h"
#include "ui/events/event.h"
-#include "ui/views/widget/widget.h"
namespace ash {
-using StickyKeysOverlayTest = test::AshTestBase;
+class StickyKeysOverlayTest : public test::AshTestBase {
+ public:
+ StickyKeysOverlayTest() {}
+ virtual ~StickyKeysOverlayTest() {}
+};
TEST_F(StickyKeysOverlayTest, OverlayVisibility) {
StickyKeysOverlay overlay;
@@ -38,27 +41,6 @@ TEST_F(StickyKeysOverlayTest, ModifierKeyState) {
overlay.GetModifierKeyState(ui::EF_COMMAND_DOWN));
}
-// This test attempts to simulate a crash report (see //crbug.com/435600).
-// The crash is speculated to be caused by the native window of the sticky keys
-// overlay widget being destroyed before the overlay object is. This test case
-// tests that the overlay object maintains full ownership of the widget and view
-// regardless.
-TEST_F(StickyKeysOverlayTest, OverlayViewOwnership) {
- StickyKeysOverlay overlay;
- views::Widget* widget = overlay.GetWidgetForTesting();
- ASSERT_TRUE(widget);
- delete widget->GetNativeWindow();
-
- // States should still be valid even after the native window associated with
- // the Widget is destroyed.
- overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_ENABLED);
- EXPECT_EQ(STICKY_KEY_STATE_ENABLED,
- overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN));
- overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED);
- EXPECT_EQ(STICKY_KEY_STATE_DISABLED,
- overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN));
-}
-
// Additional sticky key overlay tests that depend on chromeos::EventRewriter
// are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc .