| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/message_pump/message_pump_mojo.h" | 5 #include "mojo/message_pump/message_pump_mojo.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 run_state_->wait_state->handles[wait_many_result.index]) != | 198 run_state_->wait_state->handles[wait_many_result.index]) != |
| 199 handlers_.end()); | 199 handlers_.end()); |
| 200 WillSignalHandler(); | 200 WillSignalHandler(); |
| 201 handlers_[run_state_->wait_state->handles[wait_many_result.index]] | 201 handlers_[run_state_->wait_state->handles[wait_many_result.index]] |
| 202 .handler->OnHandleReady( | 202 .handler->OnHandleReady( |
| 203 run_state_->wait_state->handles[wait_many_result.index]); | 203 run_state_->wait_state->handles[wait_many_result.index]); |
| 204 DidSignalHandler(); | 204 DidSignalHandler(); |
| 205 } | 205 } |
| 206 } else { | 206 } else { |
| 207 switch (result) { | 207 switch (result) { |
| 208 case MOJO_RESULT_CANCELLED: | |
| 209 case MOJO_RESULT_FAILED_PRECONDITION: | 208 case MOJO_RESULT_FAILED_PRECONDITION: |
| 210 RemoveInvalidHandle(*run_state_->wait_state, result, | 209 RemoveInvalidHandle(*run_state_->wait_state, result, |
| 211 wait_many_result.index); | 210 wait_many_result.index); |
| 212 break; | 211 break; |
| 213 case MOJO_RESULT_DEADLINE_EXCEEDED: | 212 case MOJO_RESULT_DEADLINE_EXCEEDED: |
| 214 did_work = false; | 213 did_work = false; |
| 215 break; | 214 break; |
| 215 case MOJO_RESULT_INVALID_ARGUMENT: |
| 216 case MOJO_RESULT_CANCELLED: |
| 217 case MOJO_RESULT_BUSY: |
| 218 // These results indicate a bug in "our" code (e.g., race conditions). |
| 219 // Fall through. |
| 216 default: | 220 default: |
| 217 base::debug::Alias(&result); | 221 base::debug::Alias(&result); |
| 218 // Unexpected result is likely fatal, crash so we can determine cause. | 222 // Unexpected result is likely fatal, crash so we can determine cause. |
| 219 CHECK(false); | 223 CHECK(false); |
| 220 } | 224 } |
| 221 } | 225 } |
| 222 // To keep memory usage under control, delete the WaitState object at the end | 226 // To keep memory usage under control, delete the WaitState object at the end |
| 223 // if it's vectors are too big by a factor of 2. Pre-C++11 doesn't have a way | 227 // if it's vectors are too big by a factor of 2. Pre-C++11 doesn't have a way |
| 224 // to shrink vectors, so just get rid of them and re-create on the next round. | 228 // to shrink vectors, so just get rid of them and re-create on the next round. |
| 225 if (run_state_->wait_state->handles.capacity() > | 229 if (run_state_->wait_state->handles.capacity() > |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 void MessagePumpMojo::WillSignalHandler() { | 329 void MessagePumpMojo::WillSignalHandler() { |
| 326 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); | 330 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); |
| 327 } | 331 } |
| 328 | 332 |
| 329 void MessagePumpMojo::DidSignalHandler() { | 333 void MessagePumpMojo::DidSignalHandler() { |
| 330 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); | 334 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); |
| 331 } | 335 } |
| 332 | 336 |
| 333 } // namespace common | 337 } // namespace common |
| 334 } // namespace mojo | 338 } // namespace mojo |
| OLD | NEW |