Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: mojo/edk/system/channel_endpoint.cc

Issue 683583002: Update mojo sdk to rev e083961bf11fd0c94d40be8853761da529b6d444 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "mojo/edk/system/channel_endpoint.h" 5 #include "mojo/edk/system/channel_endpoint.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/channel.h" 8 #include "mojo/edk/system/channel.h"
9 #include "mojo/edk/system/message_pipe.h" 9 #include "mojo/edk/system/message_pipe.h"
10 #include "mojo/edk/system/transport_data.h" 10 #include "mojo/edk/system/transport_data.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DCHECK(local_id_.is_valid()); 58 DCHECK(local_id_.is_valid());
59 // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid 59 // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid
60 // here as well. 60 // here as well.
61 channel_->DetachEndpoint(this, local_id_, remote_id_); 61 channel_->DetachEndpoint(this, local_id_, remote_id_);
62 channel_ = nullptr; 62 channel_ = nullptr;
63 local_id_ = ChannelEndpointId(); 63 local_id_ = ChannelEndpointId();
64 remote_id_ = ChannelEndpointId(); 64 remote_id_ = ChannelEndpointId();
65 } 65 }
66 } 66 }
67 67
68 void ChannelEndpoint::AttachToChannel(Channel* channel,
69 ChannelEndpointId local_id) {
70 DCHECK(channel);
71 DCHECK(local_id.is_valid());
72
73 base::AutoLock locker(lock_);
74 DCHECK(!channel_);
75 DCHECK(!local_id_.is_valid());
76 channel_ = channel;
77 local_id_ = local_id;
78 }
79
80 void ChannelEndpoint::Run(ChannelEndpointId remote_id) {
81 DCHECK(remote_id.is_valid());
82
83 base::AutoLock locker(lock_);
84 if (!channel_)
85 return;
86
87 DCHECK(!remote_id_.is_valid());
88 remote_id_ = remote_id;
89
90 while (!paused_message_queue_.IsEmpty()) {
91 LOG_IF(WARNING, !WriteMessageNoLock(paused_message_queue_.GetMessage()))
92 << "Failed to write enqueue message to channel";
93 }
94 }
95
96 void ChannelEndpoint::AttachAndRun(Channel* channel, 68 void ChannelEndpoint::AttachAndRun(Channel* channel,
97 ChannelEndpointId local_id, 69 ChannelEndpointId local_id,
98 ChannelEndpointId remote_id) { 70 ChannelEndpointId remote_id) {
99 DCHECK(channel); 71 DCHECK(channel);
100 DCHECK(local_id.is_valid()); 72 DCHECK(local_id.is_valid());
101 DCHECK(remote_id.is_valid()); 73 DCHECK(remote_id.is_valid());
102 74
103 base::AutoLock locker(lock_); 75 base::AutoLock locker(lock_);
104 DCHECK(!channel_); 76 DCHECK(!channel_);
105 DCHECK(!local_id_.is_valid()); 77 DCHECK(!local_id_.is_valid());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DCHECK(remote_id_.is_valid()); 168 DCHECK(remote_id_.is_valid());
197 169
198 message->SerializeAndCloseDispatchers(channel_); 170 message->SerializeAndCloseDispatchers(channel_);
199 message->set_source_id(local_id_); 171 message->set_source_id(local_id_);
200 message->set_destination_id(remote_id_); 172 message->set_destination_id(remote_id_);
201 return channel_->WriteMessage(message.Pass()); 173 return channel_->WriteMessage(message.Pass());
202 } 174 }
203 175
204 } // namespace system 176 } // namespace system
205 } // namespace mojo 177 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698