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

Unified Diff: views/widget/widget.h

Issue 7031053: Make Widget ownership a little clearer by expressing it in terms of an enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 | « views/widget/native_widget_win_unittest.cc ('k') | views/widget/widget.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget.h
===================================================================
--- views/widget/widget.h (revision 86623)
+++ views/widget/widget.h (working copy)
@@ -56,14 +56,14 @@
//
// A special note on ownership:
//
-// Depending on the value of "delete_on_destroy", the Widget either owns or
-// is owned by its NativeWidget:
+// Depending on the value of the InitParams' ownership field, the Widget
+// either owns or is owned by its NativeWidget:
//
-// delete_on_destroy = true (default)
+// ownership = NATIVE_WIDGET_OWNS_WIDGET (default)
// The Widget instance is owned by its NativeWidget. When the NativeWidget
// is destroyed (in response to a native destruction message), it deletes
// the Widget from its destructor.
-// delete_on_destroy = false (non-default)
+// ownership = WIDGET_OWNS_NATIVE_WIDGET (non-default)
// The Widget instance owns its NativeWidget. This state implies someone
// else wants to control the lifetime of this object. When they destroy
// the Widget it is responsible for destroying the NativeWidget (from its
@@ -80,6 +80,15 @@
TYPE_MENU // An undecorated Window, with transient properties
// specialized to menus.
};
+ enum Ownership {
+ // Default. Creator is not responsible for managing the lifetime of the
+ // Widget, it is destroyed when the corresponding NativeWidget is
+ // destroyed.
+ NATIVE_WIDGET_OWNS_WIDGET,
+ // Used when the Widget is owned by someone other than the NativeWidget,
+ // e.g. a scoped_ptr in tests.
+ WIDGET_OWNS_NATIVE_WIDGET
+ };
InitParams();
explicit InitParams(Type type);
@@ -91,7 +100,7 @@
bool accept_events;
bool can_activate;
bool keep_on_top;
- bool delete_on_destroy;
+ Ownership ownership;
bool mirror_origin_in_rtl;
bool has_dropshadow;
// Should the widget be double buffered? Default is false.
@@ -400,7 +409,7 @@
scoped_refptr<ui::Compositor> compositor_;
// See class documentation for Widget above for a note about ownership.
- bool delete_on_destroy_;
+ InitParams::Ownership ownership_;
// See set_is_secondary_widget().
bool is_secondary_widget_;
« no previous file with comments | « views/widget/native_widget_win_unittest.cc ('k') | views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698