OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 --ref_count_; | 70 --ref_count_; |
71 LOG(LS_VERBOSE) << "Number of references: " << ref_count_; | 71 LOG(LS_VERBOSE) << "Number of references: " << ref_count_; |
72 if (ref_count_ == 0) { | 72 if (ref_count_ == 0) { |
73 CleanupInstance(); | 73 CleanupInstance(); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 CriticalSection crit_; | 77 CriticalSection crit_; |
78 int ref_count_; | 78 int ref_count_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(ReferenceCountedSingletonFactory); | 80 RTC_DISALLOW_COPY_AND_ASSIGN(ReferenceCountedSingletonFactory); |
81 }; | 81 }; |
82 | 82 |
83 template <typename Interface> | 83 template <typename Interface> |
84 class rcsf_ptr { | 84 class rcsf_ptr { |
85 public: | 85 public: |
86 // Create a pointer that uses the factory to get the instance. | 86 // Create a pointer that uses the factory to get the instance. |
87 // This is lazy - it won't generate the instance until it is requested. | 87 // This is lazy - it won't generate the instance until it is requested. |
88 explicit rcsf_ptr(ReferenceCountedSingletonFactory<Interface>* factory) | 88 explicit rcsf_ptr(ReferenceCountedSingletonFactory<Interface>* factory) |
89 : instance_(NULL), | 89 : instance_(NULL), |
90 factory_(factory) { | 90 factory_(factory) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Since we're getting a singleton back, acquire is a noop if instance is | 142 // Since we're getting a singleton back, acquire is a noop if instance is |
143 // already populated. | 143 // already populated. |
144 if (!instance_) { | 144 if (!instance_) { |
145 instance_ = factory_->GetInstance(); | 145 instance_ = factory_->GetInstance(); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 Interface* instance_; | 149 Interface* instance_; |
150 ReferenceCountedSingletonFactory<Interface>* factory_; | 150 ReferenceCountedSingletonFactory<Interface>* factory_; |
151 | 151 |
152 DISALLOW_IMPLICIT_CONSTRUCTORS(rcsf_ptr); | 152 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(rcsf_ptr); |
153 }; | 153 }; |
154 | 154 |
155 }; // namespace rtc | 155 }; // namespace rtc |
156 | 156 |
157 #endif // WEBRTC_BASE_REFERENCECOUNTEDSINGLETONFACTORY_H_ | 157 #endif // WEBRTC_BASE_REFERENCECOUNTEDSINGLETONFACTORY_H_ |
OLD | NEW |