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

Unified Diff: ash/wm/drag_window_resizer.cc

Issue 23645008: Use a weak pointer to determine if resizer was destroyed by nested Drag calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « ash/wm/drag_window_resizer.h ('k') | ash/wm/panels/panel_window_resizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/drag_window_resizer.cc
diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc
index e8f977e6418ba041b27c87755a4298423c8a84e4..e07c96ef35b24e08f2e5d101c46653cdb98676d8 100644
--- a/ash/wm/drag_window_resizer.cc
+++ b/ash/wm/drag_window_resizer.cc
@@ -10,6 +10,7 @@
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/drag_window_controller.h"
#include "ash/wm/property_util.h"
+#include "base/memory/weak_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
@@ -56,9 +57,6 @@ DragWindowResizer::~DragWindowResizer() {
shell->mouse_cursor_filter()->HideSharedEdgeIndicator();
if (instance_ == this)
instance_ = NULL;
-
- if (destroyed_)
- *destroyed_ = true;
}
// static
@@ -74,18 +72,12 @@ DragWindowResizer* DragWindowResizer::Create(
}
void DragWindowResizer::Drag(const gfx::Point& location, int event_flags) {
- bool destroyed = false;
- destroyed_ = &destroyed;
+ base::WeakPtr<DragWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr());
next_window_resizer_->Drag(location, event_flags);
-
- // TODO(flackr): Refactor the way WindowResizer calls into other window
- // resizers to avoid the awkward pattern here for checking if
- // next_window_resizer_ destroys the resizer object.
- if (destroyed)
+ if (!resizer)
return;
- destroyed_ = NULL;
- last_mouse_location_ = location;
+ last_mouse_location_ = location;
// Show a phantom window for dragging in another root window.
if (HasSecondaryRootWindow()) {
gfx::Point location_in_screen = location;
@@ -140,7 +132,7 @@ DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer,
const Details& details)
: next_window_resizer_(next_window_resizer),
details_(details),
- destroyed_(NULL) {
+ weak_ptr_factory_(this) {
// The pointer should be confined in one display during resizing a window
// because the window cannot span two displays at the same time anyway. The
// exception is window/tab dragging operation. During that operation,
« no previous file with comments | « ash/wm/drag_window_resizer.h ('k') | ash/wm/panels/panel_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698