Make castv2 performance test work.
[chromium-blink-merge.git] / ui / views / widget / widget_deletion_observer.cc
blobdb3a44e7d8ed744bbf0fdb1c92565f525ed451a4
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/widget/widget_deletion_observer.h"
7 #include "ui/views/widget/widget.h"
9 namespace views {
11 WidgetDeletionObserver::WidgetDeletionObserver(Widget* widget)
12 : widget_(widget) {
13 if (widget_)
14 widget_->AddObserver(this);
17 WidgetDeletionObserver::~WidgetDeletionObserver() {
18 CleanupWidget();
21 void WidgetDeletionObserver::OnWidgetDestroying(Widget* widget) {
22 CleanupWidget();
25 void WidgetDeletionObserver::CleanupWidget() {
26 if (widget_) {
27 widget_->RemoveObserver(this);
28 widget_ = NULL;
32 } // namespace views