OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium 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 CORE_FXCRT_INCLUDE_CFX_OBSERVABLE_H_ | 5 #ifndef CORE_FXCRT_CFX_OBSERVABLE_H_ |
6 #define CORE_FXCRT_INCLUDE_CFX_OBSERVABLE_H_ | 6 #define CORE_FXCRT_CFX_OBSERVABLE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "core/fxcrt/include/fx_system.h" | 10 #include "core/fxcrt/fx_system.h" |
11 #include "third_party/base/stl_util.h" | 11 #include "third_party/base/stl_util.h" |
12 | 12 |
13 template <class T> | 13 template <class T> |
14 class CFX_Observable { | 14 class CFX_Observable { |
15 public: | 15 public: |
16 class ObservedPtr { | 16 class ObservedPtr { |
17 public: | 17 public: |
18 ObservedPtr() : m_pObservedPtr(nullptr) {} | 18 ObservedPtr() : m_pObservedPtr(nullptr) {} |
19 explicit ObservedPtr(T* pObservedPtr) : m_pObservedPtr(pObservedPtr) { | 19 explicit ObservedPtr(T* pObservedPtr) : m_pObservedPtr(pObservedPtr) { |
20 if (m_pObservedPtr) | 20 if (m_pObservedPtr) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 CFX_Observable& operator=(const CFX_Observable& that) = delete; | 69 CFX_Observable& operator=(const CFX_Observable& that) = delete; |
70 | 70 |
71 protected: | 71 protected: |
72 size_t ActiveObservedPtrsForTesting() const { return m_ObservedPtrs.size(); } | 72 size_t ActiveObservedPtrsForTesting() const { return m_ObservedPtrs.size(); } |
73 | 73 |
74 private: | 74 private: |
75 std::set<ObservedPtr*> m_ObservedPtrs; | 75 std::set<ObservedPtr*> m_ObservedPtrs; |
76 }; | 76 }; |
77 | 77 |
78 #endif // CORE_FXCRT_INCLUDE_CFX_OBSERVABLE_H_ | 78 #endif // CORE_FXCRT_CFX_OBSERVABLE_H_ |
OLD | NEW |