OLD | NEW |
(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 |
OLD | NEW |