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

Side by Side Diff: components/view_manager/public/cpp/lib/scoped_view_ptr.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/view_manager/public/cpp/scoped_view_ptr.h"
6
7 #include "components/view_manager/public/cpp/view.h"
8 #include "components/view_manager/public/cpp/view_observer.h"
9 #include "components/view_manager/public/cpp/view_tree_connection.h"
10
11 namespace mojo {
12
13 ScopedViewPtr::ScopedViewPtr(View* view)
14 : view_(view) {
15 view_->AddObserver(this);
16 }
17
18 ScopedViewPtr::~ScopedViewPtr() {
19 if (view_)
20 DeleteViewOrViewManager(view_);
21 DetachFromView();
22 }
23
24 // static
25 void ScopedViewPtr::DeleteViewOrViewManager(View* view) {
26 if (view->connection()->GetRoot() == view)
27 delete view->connection();
28 else
29 view->Destroy();
30 }
31
32 void ScopedViewPtr::DetachFromView() {
33 if (!view_)
34 return;
35
36 view_->RemoveObserver(this);
37 view_ = nullptr;
38 }
39
40 void ScopedViewPtr::OnViewDestroying(View* view) {
41 DCHECK_EQ(view_, view);
42 DetachFromView();
43 }
44
45 } // namespace mojo
OLDNEW
« no previous file with comments | « components/view_manager/public/cpp/lib/args.cc ('k') | components/view_manager/public/cpp/lib/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698