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

Unified Diff: ash/wm/panels/panel_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/panels/panel_window_resizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/panels/panel_window_resizer.cc
diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc
index cb151b8bae08370bb7a48074a8092fd74cd3e3a1..67e4bd130340690ae0c6ea0284cd3d4fca3caf74 100644
--- a/ash/wm/panels/panel_window_resizer.cc
+++ b/ash/wm/panels/panel_window_resizer.cc
@@ -15,6 +15,7 @@
#include "ash/wm/panels/panel_layout_manager.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_properties.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"
@@ -40,8 +41,6 @@ internal::PanelLayoutManager* GetPanelLayoutManager(
} // namespace
PanelWindowResizer::~PanelWindowResizer() {
- if (destroyed_)
- *destroyed_ = true;
}
// static
@@ -59,7 +58,6 @@ PanelWindowResizer::Create(WindowResizer* next_window_resizer,
void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
last_location_ = location;
wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_);
- bool destroyed = false;
if (!did_move_or_resize_) {
did_move_or_resize_ = true;
StartedDragging();
@@ -93,15 +91,12 @@ void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
should_attach_ = AttachToLauncher(bounds, &offset);
gfx::Point modified_location(location.x() + offset.x(),
location.y() + offset.y());
- destroyed_ = &destroyed;
- next_window_resizer_->Drag(modified_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)
+ base::WeakPtr<PanelWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr());
+ next_window_resizer_->Drag(modified_location, event_flags);
+ if (!resizer)
return;
- destroyed_ = NULL;
+
if (should_attach_ &&
!(details_.bounds_change & WindowResizer::kBoundsChange_Resizes)) {
UpdateLauncherPosition();
@@ -137,7 +132,7 @@ PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
did_move_or_resize_(false),
was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)),
should_attach_(was_attached_),
- destroyed_(NULL) {
+ weak_ptr_factory_(this) {
DCHECK(details_.is_resizable);
panel_container_ = Shell::GetContainer(
details.window->GetRootWindow(),
« no previous file with comments | « ash/wm/panels/panel_window_resizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698