| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 template <typename ObserverListType> | 65 template <typename ObserverListType> |
| 66 class AddInObserve : public Foo { | 66 class AddInObserve : public Foo { |
| 67 public: | 67 public: |
| 68 explicit AddInObserve(ObserverListType* observer_list) | 68 explicit AddInObserve(ObserverListType* observer_list) |
| 69 : added(false), | 69 : added(false), |
| 70 observer_list(observer_list), | 70 observer_list(observer_list), |
| 71 adder(1) { | 71 adder(1) { |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void Observe(int x) override { | 74 void Observe(int x) override { |
| 75 if (!added) { | 75 if (!added) { |
| 76 added = true; | 76 added = true; |
| 77 observer_list->AddObserver(&adder); | 77 observer_list->AddObserver(&adder); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool added; | 81 bool added; |
| 82 ObserverListType* observer_list; | 82 ObserverListType* observer_list; |
| 83 Adder adder; | 83 Adder adder; |
| 84 }; | 84 }; |
| (...skipping 449 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 |