| 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/system/channel.h" | 5 #include "mojo/system/channel.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "build/build_config.h" // TODO(vtl): Remove this. | |
| 15 #include "mojo/system/message_pipe_endpoint.h" | 14 #include "mojo/system/message_pipe_endpoint.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace system { | 17 namespace system { |
| 19 | 18 |
| 20 COMPILE_ASSERT(Channel::kBootstrapEndpointId != | 19 COMPILE_ASSERT(Channel::kBootstrapEndpointId != |
| 21 MessageInTransit::kInvalidEndpointId, | 20 MessageInTransit::kInvalidEndpointId, |
| 22 kBootstrapEndpointId_is_invalid); | 21 kBootstrapEndpointId_is_invalid); |
| 23 | 22 |
| 24 STATIC_CONST_MEMBER_DEFINITION const MessageInTransit::EndpointId | 23 STATIC_CONST_MEMBER_DEFINITION const MessageInTransit::EndpointId |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 default: | 282 default: |
| 284 HandleRemoteError(base::StringPrintf( | 283 HandleRemoteError(base::StringPrintf( |
| 285 "Received message of invalid type %u", | 284 "Received message of invalid type %u", |
| 286 static_cast<unsigned>(message_view.type()))); | 285 static_cast<unsigned>(message_view.type()))); |
| 287 break; | 286 break; |
| 288 } | 287 } |
| 289 } | 288 } |
| 290 | 289 |
| 291 void Channel::OnFatalError(FatalError fatal_error) { | 290 void Channel::OnFatalError(FatalError fatal_error) { |
| 292 LOG(ERROR) << "RawChannel fatal error (type " << fatal_error << ")"; | 291 LOG(ERROR) << "RawChannel fatal error (type " << fatal_error << ")"; |
| 293 // TODO(vtl): We have some nested-deletion bugs on Windows, so this crashes. | |
| 294 #if defined(OS_WIN) | |
| 295 LOG(ERROR) << "Not shutting down due Windows-only bug"; | |
| 296 #else | |
| 297 Shutdown(); | 292 Shutdown(); |
| 298 #endif | |
| 299 } | 293 } |
| 300 | 294 |
| 301 bool Channel::ValidateReadMessage(const MessageInTransit::View& message_view) { | 295 bool Channel::ValidateReadMessage(const MessageInTransit::View& message_view) { |
| 302 const char* error_message = NULL; | 296 const char* error_message = NULL; |
| 303 if (!message_view.IsValid(&error_message)) { | 297 if (!message_view.IsValid(&error_message)) { |
| 304 DCHECK(error_message); | 298 DCHECK(error_message); |
| 305 HandleRemoteError(error_message); | 299 HandleRemoteError(error_message); |
| 306 return false; | 300 return false; |
| 307 } | 301 } |
| 308 | 302 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 // TODO(vtl): Is this how we really want to handle this? | 473 // TODO(vtl): Is this how we really want to handle this? |
| 480 // Sometimes we'll want to propagate the error back to the message pipe | 474 // Sometimes we'll want to propagate the error back to the message pipe |
| 481 // (endpoint), and notify it that the remote is (effectively) closed. | 475 // (endpoint), and notify it that the remote is (effectively) closed. |
| 482 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 476 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
| 483 // their remotes are dead. | 477 // their remotes are dead. |
| 484 LOG(WARNING) << error_message; | 478 LOG(WARNING) << error_message; |
| 485 } | 479 } |
| 486 | 480 |
| 487 } // namespace system | 481 } // namespace system |
| 488 } // namespace mojo | 482 } // namespace mojo |
| OLD | NEW |