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

Side by Side Diff: services/ui/public/cpp/scoped_window_ptr.cc

Issue 2651593002: mus: Remove the old client lib. (Closed)
Patch Set: restore test Created 3 years, 11 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
« no previous file with comments | « services/ui/public/cpp/scoped_window_ptr.h ('k') | services/ui/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/public/cpp/scoped_window_ptr.h"
6
7 #include "services/ui/public/cpp/window.h"
8 #include "services/ui/public/cpp/window_observer.h"
9 #include "services/ui/public/cpp/window_tree_client.h"
10
11 namespace ui {
12
13 ScopedWindowPtr::ScopedWindowPtr(Window* window) : window_(window) {
14 window_->AddObserver(this);
15 }
16
17 ScopedWindowPtr::~ScopedWindowPtr() {
18 if (window_)
19 DeleteWindowOrWindowManager(window_);
20 DetachFromWindow();
21 }
22
23 // static
24 void ScopedWindowPtr::DeleteWindowOrWindowManager(Window* window) {
25 if (window->window_tree()->GetRoots().count(window) > 0)
26 delete window->window_tree();
27 else
28 window->Destroy();
29 }
30
31 void ScopedWindowPtr::DetachFromWindow() {
32 if (!window_)
33 return;
34
35 window_->RemoveObserver(this);
36 window_ = nullptr;
37 }
38
39 void ScopedWindowPtr::OnWindowDestroying(Window* window) {
40 DCHECK_EQ(window_, window);
41 DetachFromWindow();
42 }
43
44 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/scoped_window_ptr.h ('k') | services/ui/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698