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

Side by Side Diff: mojo/public/cpp/bindings/lib/destruction_tracker.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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 2017 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 "mojo/public/cpp/bindings/lib/destruction_tracker.h"
6
7 namespace mojo {
8
9 DestructionTracker::Flag::Flag(DestructionTracker* tracker)
10 : tracker_(tracker), outer_flag_(tracker->flag_) {
11 tracker_->SetFlag(this);
12 }
13
14 DestructionTracker::Flag::~Flag() {
15 if (tracker_)
16 tracker_->SetFlag(outer_flag_);
17 }
18
19 void DestructionTracker::Flag::NotifyDestroyed() {
20 was_destroyed_ = true;
21 tracker_ = nullptr;
22 if (outer_flag_)
23 outer_flag_->NotifyDestroyed();
24 }
25
26 DestructionTracker::DestructionTracker() = default;
27
28 DestructionTracker::~DestructionTracker() {
29 if (flag_)
30 flag_->NotifyDestroyed();
31 }
32
33 void DestructionTracker::SetFlag(Flag* flag) {
34 flag_ = flag;
35 }
36
37 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698