| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 handlers_.end()); | 195 handlers_.end()); |
| 196 WillSignalHandler(); | 196 WillSignalHandler(); |
| 197 handlers_[wait_state.handles[wait_many_result.index]] | 197 handlers_[wait_state.handles[wait_many_result.index]] |
| 198 .handler->OnHandleReady(wait_state.handles[wait_many_result.index]); | 198 .handler->OnHandleReady(wait_state.handles[wait_many_result.index]); |
| 199 DidSignalHandler(); | 199 DidSignalHandler(); |
| 200 } | 200 } |
| 201 } else { | 201 } else { |
| 202 switch (result) { | 202 switch (result) { |
| 203 case MOJO_RESULT_CANCELLED: | 203 case MOJO_RESULT_CANCELLED: |
| 204 case MOJO_RESULT_FAILED_PRECONDITION: | 204 case MOJO_RESULT_FAILED_PRECONDITION: |
| 205 case MOJO_RESULT_INVALID_ARGUMENT: |
| 205 RemoveInvalidHandle(wait_state, result, wait_many_result.index); | 206 RemoveInvalidHandle(wait_state, result, wait_many_result.index); |
| 206 break; | 207 break; |
| 207 case MOJO_RESULT_DEADLINE_EXCEEDED: | 208 case MOJO_RESULT_DEADLINE_EXCEEDED: |
| 208 did_work = false; | 209 did_work = false; |
| 209 break; | 210 break; |
| 210 default: | 211 default: |
| 211 base::debug::Alias(&result); | 212 base::debug::Alias(&result); |
| 212 // Unexpected result is likely fatal, crash so we can determine cause. | 213 // Unexpected result is likely fatal, crash so we can determine cause. |
| 213 CHECK(false); | 214 CHECK(false); |
| 214 } | 215 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 242 did_work = true; | 243 did_work = true; |
| 243 } | 244 } |
| 244 } | 245 } |
| 245 return did_work; | 246 return did_work; |
| 246 } | 247 } |
| 247 | 248 |
| 248 void MessagePumpMojo::RemoveInvalidHandle(const WaitState& wait_state, | 249 void MessagePumpMojo::RemoveInvalidHandle(const WaitState& wait_state, |
| 249 MojoResult result, | 250 MojoResult result, |
| 250 uint32_t index) { | 251 uint32_t index) { |
| 251 // TODO(sky): deal with control pipe going bad. | 252 // TODO(sky): deal with control pipe going bad. |
| 252 CHECK(result == MOJO_RESULT_FAILED_PRECONDITION || | 253 CHECK(result == MOJO_RESULT_INVALID_ARGUMENT || |
| 254 result == MOJO_RESULT_FAILED_PRECONDITION || |
| 253 result == MOJO_RESULT_CANCELLED); | 255 result == MOJO_RESULT_CANCELLED); |
| 254 CHECK_NE(index, 0u); // Indicates the control pipe went bad. | 256 CHECK_NE(index, 0u); // Indicates the control pipe went bad. |
| 255 | 257 |
| 256 // Remove the handle first, this way if OnHandleError() tries to remove the | 258 // Remove the handle first, this way if OnHandleError() tries to remove the |
| 257 // handle our iterator isn't invalidated. | 259 // handle our iterator isn't invalidated. |
| 258 Handle handle = wait_state.handles[index]; | 260 Handle handle = wait_state.handles[index]; |
| 259 CHECK(handlers_.find(handle) != handlers_.end()); | 261 CHECK(handlers_.find(handle) != handlers_.end()); |
| 260 MessagePumpMojoHandler* handler = handlers_[handle].handler; | 262 MessagePumpMojoHandler* handler = handlers_[handle].handler; |
| 261 RemoveHandler(handle); | 263 RemoveHandler(handle); |
| 262 WillSignalHandler(); | 264 WillSignalHandler(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 void MessagePumpMojo::WillSignalHandler() { | 311 void MessagePumpMojo::WillSignalHandler() { |
| 310 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); | 312 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); |
| 311 } | 313 } |
| 312 | 314 |
| 313 void MessagePumpMojo::DidSignalHandler() { | 315 void MessagePumpMojo::DidSignalHandler() { |
| 314 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); | 316 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace common | 319 } // namespace common |
| 318 } // namespace mojo | 320 } // namespace mojo |
| OLD | NEW |