| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/observer_list.h" | 5 #include "base/observer_list.h" |
| 6 #include "base/observer_list_threadsafe.h" | 6 #include "base/observer_list_threadsafe.h" |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 static const int kThreadRunTime = 2000; // ms to run the multi-threaded test. | 87 static const int kThreadRunTime = 2000; // ms to run the multi-threaded test. |
| 88 | 88 |
| 89 // A thread for use in the ThreadSafeObserver test | 89 // A thread for use in the ThreadSafeObserver test |
| 90 // which will add and remove itself from the notification | 90 // which will add and remove itself from the notification |
| 91 // list repeatedly. | 91 // list repeatedly. |
| 92 class AddRemoveThread : public PlatformThread::Delegate, | 92 class AddRemoveThread : public PlatformThread::Delegate, |
| 93 public Foo { | 93 public Foo { |
| 94 public: | 94 public: |
| 95 AddRemoveThread(ObserverListThreadSafe<Foo>* list, bool notify) | 95 AddRemoveThread(ObserverListThreadSafe<Foo>* list, bool notify) |
| 96 : list_(list), | 96 : list_(list), |
| 97 loop_(NULL), | 97 loop_(nullptr), |
| 98 in_list_(false), | 98 in_list_(false), |
| 99 start_(Time::Now()), | 99 start_(Time::Now()), |
| 100 count_observes_(0), | 100 count_observes_(0), |
| 101 count_addtask_(0), | 101 count_addtask_(0), |
| 102 do_notifies_(notify), | 102 do_notifies_(notify), |
| 103 weak_factory_(this) { | 103 weak_factory_(this) { |
| 104 } | 104 } |
| 105 | 105 |
| 106 ~AddRemoveThread() override {} | 106 ~AddRemoveThread() override {} |
| 107 | 107 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 ListDestructor a(observer_list); | 534 ListDestructor a(observer_list); |
| 535 observer_list->AddObserver(&a); | 535 observer_list->AddObserver(&a); |
| 536 | 536 |
| 537 FOR_EACH_OBSERVER(Foo, *observer_list, Observe(0)); | 537 FOR_EACH_OBSERVER(Foo, *observer_list, Observe(0)); |
| 538 // If this test fails, there'll be Valgrind errors when this function goes out | 538 // If this test fails, there'll be Valgrind errors when this function goes out |
| 539 // of scope. | 539 // of scope. |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace | 542 } // namespace |
| 543 } // namespace base | 543 } // namespace base |
| OLD | NEW |