OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/view_manager/public/cpp/scoped_view_ptr.h" | 5 #include "components/mus/public/cpp/scoped_view_ptr.h" |
6 | 6 |
7 #include "components/view_manager/public/cpp/view.h" | 7 #include "components/mus/public/cpp/view.h" |
8 #include "components/view_manager/public/cpp/view_observer.h" | 8 #include "components/mus/public/cpp/view_observer.h" |
9 #include "components/view_manager/public/cpp/view_tree_connection.h" | 9 #include "components/mus/public/cpp/view_tree_connection.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 ScopedViewPtr::ScopedViewPtr(View* view) | 13 ScopedViewPtr::ScopedViewPtr(View* view) : view_(view) { |
14 : view_(view) { | |
15 view_->AddObserver(this); | 14 view_->AddObserver(this); |
16 } | 15 } |
17 | 16 |
18 ScopedViewPtr::~ScopedViewPtr() { | 17 ScopedViewPtr::~ScopedViewPtr() { |
19 if (view_) | 18 if (view_) |
20 DeleteViewOrViewManager(view_); | 19 DeleteViewOrViewManager(view_); |
21 DetachFromView(); | 20 DetachFromView(); |
22 } | 21 } |
23 | 22 |
24 // static | 23 // static |
(...skipping 11 matching lines...) Expand all Loading... |
36 view_->RemoveObserver(this); | 35 view_->RemoveObserver(this); |
37 view_ = nullptr; | 36 view_ = nullptr; |
38 } | 37 } |
39 | 38 |
40 void ScopedViewPtr::OnViewDestroying(View* view) { | 39 void ScopedViewPtr::OnViewDestroying(View* view) { |
41 DCHECK_EQ(view_, view); | 40 DCHECK_EQ(view_, view); |
42 DetachFromView(); | 41 DetachFromView(); |
43 } | 42 } |
44 | 43 |
45 } // namespace mojo | 44 } // namespace mojo |
OLD | NEW |