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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 << "AttachMessagePipeEndpoint() while shutting down"; | 105 << "AttachMessagePipeEndpoint() while shutting down"; |
106 | 106 |
107 while (next_local_id_ == MessageInTransit::kInvalidEndpointId || | 107 while (next_local_id_ == MessageInTransit::kInvalidEndpointId || |
108 local_id_to_endpoint_map_.find(next_local_id_) != | 108 local_id_to_endpoint_map_.find(next_local_id_) != |
109 local_id_to_endpoint_map_.end()) | 109 local_id_to_endpoint_map_.end()) |
110 next_local_id_++; | 110 next_local_id_++; |
111 | 111 |
112 local_id = next_local_id_; | 112 local_id = next_local_id_; |
113 next_local_id_++; | 113 next_local_id_++; |
114 local_id_to_endpoint_map_[local_id] = | 114 local_id_to_endpoint_map_[local_id] = |
115 new ChannelEndpoint(message_pipe, port); | 115 new ChannelEndpoint(message_pipe.get(), port); |
116 } | 116 } |
117 | 117 |
118 // This might fail if that port got an |OnPeerClose()| before attaching. | 118 // This might fail if that port got an |OnPeerClose()| before attaching. |
119 if (message_pipe->Attach(port, scoped_refptr<Channel>(this), local_id)) | 119 if (message_pipe->Attach(port, scoped_refptr<Channel>(this), local_id)) |
120 return local_id; | 120 return local_id; |
121 | 121 |
122 // Note: If it failed, quite possibly the endpoint info was removed from that | 122 // Note: If it failed, quite possibly the endpoint info was removed from that |
123 // map (there's a race between us adding it to the map above and calling | 123 // map (there's a race between us adding it to the map above and calling |
124 // |Attach()|). And even if an entry exists for |local_id|, we need to check | 124 // |Attach()|). And even if an entry exists for |local_id|, we need to check |
125 // that it's the one we added (and not some other one that was added since). | 125 // that it's the one we added (and not some other one that was added since). |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // TODO(vtl): Is this how we really want to handle this? | 519 // TODO(vtl): Is this how we really want to handle this? |
520 // Sometimes we'll want to propagate the error back to the message pipe | 520 // Sometimes we'll want to propagate the error back to the message pipe |
521 // (endpoint), and notify it that the remote is (effectively) closed. | 521 // (endpoint), and notify it that the remote is (effectively) closed. |
522 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 522 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
523 // their remotes are dead. | 523 // their remotes are dead. |
524 LOG(WARNING) << error_message; | 524 LOG(WARNING) << error_message; |
525 } | 525 } |
526 | 526 |
527 } // namespace system | 527 } // namespace system |
528 } // namespace mojo | 528 } // namespace mojo |
OLD | NEW |