OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 26 matching lines...) Expand all Loading... |
37 private: | 37 private: |
38 friend class LifeCycleWatcher; | 38 friend class LifeCycleWatcher; |
39 | 39 |
40 explicit LifeCycleObject(Observer* observer) | 40 explicit LifeCycleObject(Observer* observer) |
41 : observer_(observer) { | 41 : observer_(observer) { |
42 observer_->OnLifeCycleConstruct(this); | 42 observer_->OnLifeCycleConstruct(this); |
43 } | 43 } |
44 | 44 |
45 Observer* observer_; | 45 Observer* observer_; |
46 | 46 |
47 DISALLOW_COPY_AND_ASSIGN(LifeCycleObject); | 47 RTC_DISALLOW_COPY_AND_ASSIGN(LifeCycleObject); |
48 }; | 48 }; |
49 | 49 |
50 // The life cycle states we care about for the purposes of testing ScopedVector | 50 // The life cycle states we care about for the purposes of testing ScopedVector |
51 // against objects. | 51 // against objects. |
52 enum LifeCycleState { | 52 enum LifeCycleState { |
53 LC_INITIAL, | 53 LC_INITIAL, |
54 LC_CONSTRUCTED, | 54 LC_CONSTRUCTED, |
55 LC_DESTROYED, | 55 LC_DESTROYED, |
56 }; | 56 }; |
57 | 57 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Returns true iff |object| is the same object that this watcher is tracking. | 101 // Returns true iff |object| is the same object that this watcher is tracking. |
102 bool IsWatching(LifeCycleObject* object) const { | 102 bool IsWatching(LifeCycleObject* object) const { |
103 return object == constructed_life_cycle_object_.get(); | 103 return object == constructed_life_cycle_object_.get(); |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 LifeCycleState life_cycle_state_; | 107 LifeCycleState life_cycle_state_; |
108 rtc::scoped_ptr<LifeCycleObject> constructed_life_cycle_object_; | 108 rtc::scoped_ptr<LifeCycleObject> constructed_life_cycle_object_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(LifeCycleWatcher); | 110 RTC_DISALLOW_COPY_AND_ASSIGN(LifeCycleWatcher); |
111 }; | 111 }; |
112 | 112 |
113 TEST(ScopedVectorTest, LifeCycleWatcher) { | 113 TEST(ScopedVectorTest, LifeCycleWatcher) { |
114 LifeCycleWatcher watcher; | 114 LifeCycleWatcher watcher; |
115 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); | 115 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); |
116 LifeCycleObject* object = watcher.NewLifeCycleObject(); | 116 LifeCycleObject* object = watcher.NewLifeCycleObject(); |
117 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); | 117 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
118 delete object; | 118 delete object; |
119 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); | 119 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
120 } | 120 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 ~DeleteCounter() { | 260 ~DeleteCounter() { |
261 (*deletes_)++; | 261 (*deletes_)++; |
262 } | 262 } |
263 | 263 |
264 void VoidMethod0() {} | 264 void VoidMethod0() {} |
265 | 265 |
266 private: | 266 private: |
267 int* const deletes_; | 267 int* const deletes_; |
268 | 268 |
269 DISALLOW_COPY_AND_ASSIGN(DeleteCounter); | 269 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteCounter); |
270 }; | 270 }; |
271 | 271 |
272 // This class is used in place of Chromium's base::Callback. | 272 // This class is used in place of Chromium's base::Callback. |
273 template <typename T> | 273 template <typename T> |
274 class PassThru { | 274 class PassThru { |
275 public: | 275 public: |
276 explicit PassThru(ScopedVector<T> scoper) : scoper_(scoper.Pass()) {} | 276 explicit PassThru(ScopedVector<T> scoper) : scoper_(scoper.Pass()) {} |
277 | 277 |
278 ScopedVector<T> Run() { | 278 ScopedVector<T> Run() { |
279 return scoper_.Pass(); | 279 return scoper_.Pass(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 319 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
320 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) | 320 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) |
321 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); | 321 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); |
322 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size; | 322 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size; |
323 ++it) | 323 ++it) |
324 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 324 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
325 } | 325 } |
326 | 326 |
327 } // namespace | 327 } // namespace |
328 } // namespace webrtc | 328 } // namespace webrtc |
OLD | NEW |