| 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/edk/system/channel.h" | 5 #include "mojo/edk/system/channel.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // The channel should have been shut down first. | 229 // The channel should have been shut down first. |
| 230 DCHECK(!is_running_); | 230 DCHECK(!is_running_); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void Channel::OnReadMessage( | 233 void Channel::OnReadMessage( |
| 234 const MessageInTransit::View& message_view, | 234 const MessageInTransit::View& message_view, |
| 235 embedder::ScopedPlatformHandleVectorPtr platform_handles) { | 235 embedder::ScopedPlatformHandleVectorPtr platform_handles) { |
| 236 DCHECK(creation_thread_checker_.CalledOnValidThread()); | 236 DCHECK(creation_thread_checker_.CalledOnValidThread()); |
| 237 | 237 |
| 238 switch (message_view.type()) { | 238 switch (message_view.type()) { |
| 239 case MessageInTransit::kTypeMessagePipeEndpoint: | 239 case MessageInTransit::kTypeEndpoint: |
| 240 case MessageInTransit::kTypeMessagePipe: | 240 OnReadMessageForEndpoint(message_view, platform_handles.Pass()); |
| 241 OnReadMessageForDownstream(message_view, platform_handles.Pass()); | |
| 242 break; | 241 break; |
| 243 case MessageInTransit::kTypeChannel: | 242 case MessageInTransit::kTypeChannel: |
| 244 OnReadMessageForChannel(message_view, platform_handles.Pass()); | 243 OnReadMessageForChannel(message_view, platform_handles.Pass()); |
| 245 break; | 244 break; |
| 246 default: | 245 default: |
| 247 HandleRemoteError( | 246 HandleRemoteError( |
| 248 base::StringPrintf("Received message of invalid type %u", | 247 base::StringPrintf("Received message of invalid type %u", |
| 249 static_cast<unsigned>(message_view.type()))); | 248 static_cast<unsigned>(message_view.type()))); |
| 250 break; | 249 break; |
| 251 } | 250 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 275 break; | 274 break; |
| 276 case ERROR_WRITE: | 275 case ERROR_WRITE: |
| 277 // Write errors are slightly notable: they probably shouldn't happen under | 276 // Write errors are slightly notable: they probably shouldn't happen under |
| 278 // normal operation (but maybe the other side crashed). | 277 // normal operation (but maybe the other side crashed). |
| 279 LOG(WARNING) << "RawChannel write error"; | 278 LOG(WARNING) << "RawChannel write error"; |
| 280 break; | 279 break; |
| 281 } | 280 } |
| 282 Shutdown(); | 281 Shutdown(); |
| 283 } | 282 } |
| 284 | 283 |
| 285 void Channel::OnReadMessageForDownstream( | 284 void Channel::OnReadMessageForEndpoint( |
| 286 const MessageInTransit::View& message_view, | 285 const MessageInTransit::View& message_view, |
| 287 embedder::ScopedPlatformHandleVectorPtr platform_handles) { | 286 embedder::ScopedPlatformHandleVectorPtr platform_handles) { |
| 288 DCHECK(creation_thread_checker_.CalledOnValidThread()); | 287 DCHECK(creation_thread_checker_.CalledOnValidThread()); |
| 289 DCHECK(message_view.type() == MessageInTransit::kTypeMessagePipeEndpoint || | 288 DCHECK(message_view.type() == MessageInTransit::kTypeEndpoint); |
| 290 message_view.type() == MessageInTransit::kTypeMessagePipe); | |
| 291 | 289 |
| 292 ChannelEndpointId local_id = message_view.destination_id(); | 290 ChannelEndpointId local_id = message_view.destination_id(); |
| 293 if (!local_id.is_valid()) { | 291 if (!local_id.is_valid()) { |
| 294 HandleRemoteError("Received message with no destination ID"); | 292 HandleRemoteError("Received message with no destination ID"); |
| 295 return; | 293 return; |
| 296 } | 294 } |
| 297 | 295 |
| 298 scoped_refptr<ChannelEndpoint> endpoint; | 296 scoped_refptr<ChannelEndpoint> endpoint; |
| 299 { | 297 { |
| 300 base::AutoLock locker(lock_); | 298 base::AutoLock locker(lock_); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // TODO(vtl): Is this how we really want to handle this? | 525 // TODO(vtl): Is this how we really want to handle this? |
| 528 // Sometimes we'll want to propagate the error back to the message pipe | 526 // Sometimes we'll want to propagate the error back to the message pipe |
| 529 // (endpoint), and notify it that the remote is (effectively) closed. | 527 // (endpoint), and notify it that the remote is (effectively) closed. |
| 530 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 528 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
| 531 // their remotes are dead. | 529 // their remotes are dead. |
| 532 LOG(WARNING) << error_message; | 530 LOG(WARNING) << error_message; |
| 533 } | 531 } |
| 534 | 532 |
| 535 } // namespace system | 533 } // namespace system |
| 536 } // namespace mojo | 534 } // namespace mojo |
| OLD | NEW |