| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ipc/mojo/ipc_message_pipe_reader.h" | 5 #include "ipc/mojo/ipc_message_pipe_reader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // If can fail with |MOJO_RESULT_ALREADY_EXISTS| otherwise. | 161 // If can fail with |MOJO_RESULT_ALREADY_EXISTS| otherwise. |
| 162 // Also, we don't use MOJO_HANDLE_SIGNAL_WRITABLE here, expecting buffer in | 162 // Also, we don't use MOJO_HANDLE_SIGNAL_WRITABLE here, expecting buffer in |
| 163 // MessagePipe. | 163 // MessagePipe. |
| 164 MojoResult result = | 164 MojoResult result = |
| 165 async_waiter_->Wait(pipe_.get().value(), MOJO_HANDLE_SIGNAL_READABLE); | 165 async_waiter_->Wait(pipe_.get().value(), MOJO_HANDLE_SIGNAL_READABLE); |
| 166 // If the result is |MOJO_RESULT_ALREADY_EXISTS|, there could be messages | 166 // If the result is |MOJO_RESULT_ALREADY_EXISTS|, there could be messages |
| 167 // that have been arrived after the last |ReadAvailableMessages()|. | 167 // that have been arrived after the last |ReadAvailableMessages()|. |
| 168 // We have to consume then and retry in that case. | 168 // We have to consume then and retry in that case. |
| 169 if (result != MOJO_RESULT_ALREADY_EXISTS) { | 169 if (result != MOJO_RESULT_ALREADY_EXISTS) { |
| 170 if (result != MOJO_RESULT_OK) { | 170 if (result != MOJO_RESULT_OK) { |
| 171 DLOG(ERROR) << "Result is " << result; | 171 LOG(ERROR) << "Failed to wait on the pipe. Result is " << result; |
| 172 OnPipeError(result); | 172 OnPipeError(result); |
| 173 Close(); | 173 Close(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 break; | 176 break; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 void MessagePipeReader::PipeIsReady(MojoResult wait_result) { | 181 void MessagePipeReader::PipeIsReady(MojoResult wait_result) { |
| 182 if (wait_result != MOJO_RESULT_OK) { | 182 if (wait_result != MOJO_RESULT_OK) { |
| 183 if (wait_result != MOJO_RESULT_ABORTED) { | 183 if (wait_result != MOJO_RESULT_ABORTED) { |
| 184 // FAILED_PRECONDITION happens every time the peer is dead so | 184 // FAILED_PRECONDITION happens every time the peer is dead so |
| 185 // it isn't worth polluting the log message. | 185 // it isn't worth polluting the log message. |
| 186 DLOG_IF(WARNING, wait_result != MOJO_RESULT_FAILED_PRECONDITION) | 186 LOG_IF(WARNING, wait_result != MOJO_RESULT_FAILED_PRECONDITION) |
| 187 << "Pipe got error from the waiter. Closing: " << wait_result; | 187 << "Pipe got error from the waiter. Closing: " << wait_result; |
| 188 OnPipeError(wait_result); | 188 OnPipeError(wait_result); |
| 189 } | 189 } |
| 190 | 190 |
| 191 Close(); | 191 Close(); |
| 192 return; | 192 return; |
| 193 } | 193 } |
| 194 | 194 |
| 195 ReadMessagesThenWait(); | 195 ReadMessagesThenWait(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void MessagePipeReader::DelayedDeleter::operator()( | 198 void MessagePipeReader::DelayedDeleter::operator()( |
| 199 MessagePipeReader* ptr) const { | 199 MessagePipeReader* ptr) const { |
| 200 ptr->Close(); | 200 ptr->Close(); |
| 201 base::MessageLoopProxy::current()->PostTask( | 201 base::MessageLoopProxy::current()->PostTask( |
| 202 FROM_HERE, base::Bind(&DeleteNow, ptr)); | 202 FROM_HERE, base::Bind(&DeleteNow, ptr)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace internal | 205 } // namespace internal |
| 206 } // namespace IPC | 206 } // namespace IPC |
| OLD | NEW |