| 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 #ifndef COMPONENTS_ARC_INSTANCE_HOLDER_H_ | 5 #ifndef COMPONENTS_ARC_INSTANCE_HOLDER_H_ |
| 6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_ | 6 #define COMPONENTS_ARC_INSTANCE_HOLDER_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 observer->OnInstanceReady(); | 55 observer->OnInstanceReady(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void RemoveObserver(Observer* observer) { | 58 void RemoveObserver(Observer* observer) { |
| 59 DCHECK(thread_checker_.CalledOnValidThread()); | 59 DCHECK(thread_checker_.CalledOnValidThread()); |
| 60 observer_list_.RemoveObserver(observer); | 60 observer_list_.RemoveObserver(observer); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Called when the channel is closed. | 63 // Called when the channel is closed. |
| 64 void CloseChannel() { | 64 void CloseChannel() { |
| 65 if (!ptr_) | 65 if (!raw_ptr_) |
| 66 return; | 66 return; |
| 67 | 67 |
| 68 ptr_.reset(); | 68 ptr_.reset(); |
| 69 raw_ptr_ = nullptr; | 69 raw_ptr_ = nullptr; |
| 70 version_ = 0; | 70 version_ = 0; |
| 71 if (observer_list_.might_have_observers()) { | 71 if (observer_list_.might_have_observers()) { |
| 72 typename base::ObserverList<Observer>::Iterator it(&observer_list_); | 72 typename base::ObserverList<Observer>::Iterator it(&observer_list_); |
| 73 Observer* obs; | 73 Observer* obs; |
| 74 while ((obs = it.GetNext()) != nullptr) | 74 while ((obs = it.GetNext()) != nullptr) |
| 75 obs->OnInstanceClosed(); | 75 obs->OnInstanceClosed(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // This needs to be the last member in order to cancel all inflight callbacks | 128 // This needs to be the last member in order to cancel all inflight callbacks |
| 129 // before destroying any other members. | 129 // before destroying any other members. |
| 130 base::WeakPtrFactory<InstanceHolder<T>> weak_factory_; | 130 base::WeakPtrFactory<InstanceHolder<T>> weak_factory_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>); | 132 DISALLOW_COPY_AND_ASSIGN(InstanceHolder<T>); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace arc | 135 } // namespace arc |
| 136 | 136 |
| 137 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_ | 137 #endif // COMPONENTS_ARC_INSTANCE_HOLDER_H_ |
| OLD | NEW |