Chromium Code Reviews| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 81 |
| 82 size_t num_live = 0; | 82 size_t num_live = 0; |
| 83 size_t num_zombies = 0; | 83 size_t num_zombies = 0; |
| 84 for (IdToEndpointInfoMap::iterator it = to_destroy.begin(); | 84 for (IdToEndpointInfoMap::iterator it = to_destroy.begin(); |
| 85 it != to_destroy.end(); | 85 it != to_destroy.end(); |
| 86 ++it) { | 86 ++it) { |
| 87 if (it->second.state == EndpointInfo::STATE_NORMAL) { | 87 if (it->second.state == EndpointInfo::STATE_NORMAL) { |
| 88 it->second.message_pipe->OnRemove(it->second.port); | 88 it->second.message_pipe->OnRemove(it->second.port); |
| 89 num_live++; | 89 num_live++; |
| 90 } else { | 90 } else { |
| 91 DCHECK(!it->second.message_pipe); | 91 DCHECK(!it->second.message_pipe.get()); |
|
viettrungluu
2014/08/25 19:57:05
Eh? This is a truth (i.e., (non)null) check. Which
dcheng
2014/08/25 19:58:29
I can't add a boolean test to scoped_refptr until
| |
| 92 num_zombies++; | 92 num_zombies++; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 DVLOG_IF(2, num_live || num_zombies) << "Shut down Channel with " << num_live | 95 DVLOG_IF(2, num_live || num_zombies) << "Shut down Channel with " << num_live |
| 96 << " live endpoints and " << num_zombies | 96 << " live endpoints and " << num_zombies |
| 97 << " zombies"; | 97 << " zombies"; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void Channel::WillShutdownSoon() { | 100 void Channel::WillShutdownSoon() { |
| 101 base::AutoLock locker(lock_); | 101 base::AutoLock locker(lock_); |
| 102 is_shutting_down_ = true; | 102 is_shutting_down_ = true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 MessageInTransit::EndpointId Channel::AttachMessagePipeEndpoint( | 105 MessageInTransit::EndpointId Channel::AttachMessagePipeEndpoint( |
| 106 scoped_refptr<MessagePipe> message_pipe, | 106 scoped_refptr<MessagePipe> message_pipe, |
| 107 unsigned port) { | 107 unsigned port) { |
| 108 DCHECK(message_pipe); | 108 DCHECK(message_pipe.get()); |
|
viettrungluu
2014/08/25 19:57:04
"
| |
| 109 DCHECK(port == 0 || port == 1); | 109 DCHECK(port == 0 || port == 1); |
| 110 | 110 |
| 111 MessageInTransit::EndpointId local_id; | 111 MessageInTransit::EndpointId local_id; |
| 112 { | 112 { |
| 113 base::AutoLock locker(lock_); | 113 base::AutoLock locker(lock_); |
| 114 | 114 |
| 115 DLOG_IF(WARNING, is_shutting_down_) | 115 DLOG_IF(WARNING, is_shutting_down_) |
| 116 << "AttachMessagePipeEndpoint() while shutting down"; | 116 << "AttachMessagePipeEndpoint() while shutting down"; |
| 117 | 117 |
| 118 while (next_local_id_ == MessageInTransit::kInvalidEndpointId || | 118 while (next_local_id_ == MessageInTransit::kInvalidEndpointId || |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 // TODO(vtl): Is this how we really want to handle this? | 524 // TODO(vtl): Is this how we really want to handle this? |
| 525 // Sometimes we'll want to propagate the error back to the message pipe | 525 // Sometimes we'll want to propagate the error back to the message pipe |
| 526 // (endpoint), and notify it that the remote is (effectively) closed. | 526 // (endpoint), and notify it that the remote is (effectively) closed. |
| 527 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 527 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
| 528 // their remotes are dead. | 528 // their remotes are dead. |
| 529 LOG(WARNING) << error_message; | 529 LOG(WARNING) << error_message; |
| 530 } | 530 } |
| 531 | 531 |
| 532 } // namespace system | 532 } // namespace system |
| 533 } // namespace mojo | 533 } // namespace mojo |
| OLD | NEW |