| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/platform_thread.h" | 11 #include "base/platform_thread.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 loop_ = reinterpret_cast<MessageLoop*>(0xdeadbeef); | 119 loop_ = reinterpret_cast<MessageLoop*>(0xdeadbeef); |
| 120 delete this; | 120 delete this; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // This task just keeps posting to itself in an attempt | 123 // This task just keeps posting to itself in an attempt |
| 124 // to race with the notifier. | 124 // to race with the notifier. |
| 125 void AddTask() { | 125 void AddTask() { |
| 126 count_addtask_++; | 126 count_addtask_++; |
| 127 | 127 |
| 128 if ((Time::Now() - start_).InMilliseconds() > kThreadRunTime) { | 128 if ((Time::Now() - start_).InMilliseconds() > kThreadRunTime) { |
| 129 LOG(INFO) << "DONE!"; | 129 VLOG(1) << "DONE!"; |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (!in_list_) { | 133 if (!in_list_) { |
| 134 list_->AddObserver(this); | 134 list_->AddObserver(this); |
| 135 in_list_ = true; | 135 in_list_ = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 if (do_notifies_) { | 138 if (do_notifies_) { |
| 139 list_->Notify(&Foo::Observe, 10); | 139 list_->Notify(&Foo::Observe, 10); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 observer_list.AddObserver(&a); | 386 observer_list.AddObserver(&a); |
| 387 | 387 |
| 388 FOR_EACH_OBSERVER(Foo, observer_list, Observe(1)); | 388 FOR_EACH_OBSERVER(Foo, observer_list, Observe(1)); |
| 389 EXPECT_TRUE(a.added()); | 389 EXPECT_TRUE(a.added()); |
| 390 EXPECT_EQ(0, a.adder().total) | 390 EXPECT_EQ(0, a.adder().total) |
| 391 << "Adder should not observe, so sum should still be 0."; | 391 << "Adder should not observe, so sum should still be 0."; |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace | 394 } // namespace |
| OLD | NEW |