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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 WaitState old_state; | 111 WaitState old_state; |
112 { | 112 { |
113 base::AutoLock auto_lock(custom_lock_); | 113 base::AutoLock auto_lock(custom_lock_); |
114 old_state = wait_state_; | 114 old_state = wait_state_; |
115 wait_state_ = new_state; | 115 wait_state_ = new_state; |
116 } | 116 } |
117 state_changed_.Broadcast(); | 117 state_changed_.Broadcast(); |
118 return old_state; | 118 return old_state; |
119 } | 119 } |
120 | 120 |
121 virtual void ActivateThreadWatching() override { | 121 void ActivateThreadWatching() override { |
122 State old_state = UpdateState(ACTIVATED); | 122 State old_state = UpdateState(ACTIVATED); |
123 EXPECT_EQ(old_state, INITIALIZED); | 123 EXPECT_EQ(old_state, INITIALIZED); |
124 ThreadWatcher::ActivateThreadWatching(); | 124 ThreadWatcher::ActivateThreadWatching(); |
125 } | 125 } |
126 | 126 |
127 virtual void DeActivateThreadWatching() override { | 127 void DeActivateThreadWatching() override { |
128 State old_state = UpdateState(DEACTIVATED); | 128 State old_state = UpdateState(DEACTIVATED); |
129 EXPECT_TRUE(old_state == ACTIVATED || old_state == SENT_PING || | 129 EXPECT_TRUE(old_state == ACTIVATED || old_state == SENT_PING || |
130 old_state == RECEIVED_PONG); | 130 old_state == RECEIVED_PONG); |
131 ThreadWatcher::DeActivateThreadWatching(); | 131 ThreadWatcher::DeActivateThreadWatching(); |
132 } | 132 } |
133 | 133 |
134 virtual void PostPingMessage() override { | 134 void PostPingMessage() override { |
135 State old_state = UpdateState(SENT_PING); | 135 State old_state = UpdateState(SENT_PING); |
136 EXPECT_TRUE(old_state == ACTIVATED || old_state == RECEIVED_PONG); | 136 EXPECT_TRUE(old_state == ACTIVATED || old_state == RECEIVED_PONG); |
137 ThreadWatcher::PostPingMessage(); | 137 ThreadWatcher::PostPingMessage(); |
138 } | 138 } |
139 | 139 |
140 virtual void OnPongMessage(uint64 ping_sequence_number) override { | 140 void OnPongMessage(uint64 ping_sequence_number) override { |
141 State old_state = UpdateState(RECEIVED_PONG); | 141 State old_state = UpdateState(RECEIVED_PONG); |
142 EXPECT_TRUE(old_state == SENT_PING || old_state == DEACTIVATED); | 142 EXPECT_TRUE(old_state == SENT_PING || old_state == DEACTIVATED); |
143 ThreadWatcher::OnPongMessage(ping_sequence_number); | 143 ThreadWatcher::OnPongMessage(ping_sequence_number); |
144 } | 144 } |
145 | 145 |
146 virtual void OnCheckResponsiveness(uint64 ping_sequence_number) override { | 146 void OnCheckResponsiveness(uint64 ping_sequence_number) override { |
147 ThreadWatcher::OnCheckResponsiveness(ping_sequence_number); | 147 ThreadWatcher::OnCheckResponsiveness(ping_sequence_number); |
148 { | 148 { |
149 base::AutoLock auto_lock(custom_lock_); | 149 base::AutoLock auto_lock(custom_lock_); |
150 if (responsive_) { | 150 if (responsive_) { |
151 base::subtle::Release_Store(&success_response_, | 151 base::subtle::Release_Store(&success_response_, |
152 base::subtle::Acquire_Load(&success_response_) + 1); | 152 base::subtle::Acquire_Load(&success_response_) + 1); |
153 check_response_state_ = SUCCESSFUL; | 153 check_response_state_ = SUCCESSFUL; |
154 } else { | 154 } else { |
155 base::subtle::Release_Store(&failed_response_, | 155 base::subtle::Release_Store(&failed_response_, |
156 base::subtle::Acquire_Load(&failed_response_) + 1); | 156 base::subtle::Acquire_Load(&failed_response_) + 1); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 FROM_HERE, | 729 FROM_HERE, |
730 message_loop_for_ui.QuitClosure(), | 730 message_loop_for_ui.QuitClosure(), |
731 base::TimeDelta::FromSeconds( | 731 base::TimeDelta::FromSeconds( |
732 ThreadWatcherList::g_initialize_delay_seconds)); | 732 ThreadWatcherList::g_initialize_delay_seconds)); |
733 message_loop_for_ui.Run(); | 733 message_loop_for_ui.Run(); |
734 | 734 |
735 CheckState(false /* has_thread_watcher_list */, | 735 CheckState(false /* has_thread_watcher_list */, |
736 true /* stopped */, | 736 true /* stopped */, |
737 "Stopped"); | 737 "Stopped"); |
738 } | 738 } |
OLD | NEW |