diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 02:57:29 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 02:57:29 +0000 |
commit | 46fca379cad4e94e3b444a1b689d7298d11e2c74 (patch) | |
tree | 63f9579153e8d8476a1e7c025cf6a8bd15d6882f /mojo/system | |
parent | b4dc36479c72f274edccfb813ecad046d8ebe9ad (diff) | |
download | chromium_src-46fca379cad4e94e3b444a1b689d7298d11e2c74.zip chromium_src-46fca379cad4e94e3b444a1b689d7298d11e2c74.tar.gz chromium_src-46fca379cad4e94e3b444a1b689d7298d11e2c74.tar.bz2 |
Mojo: Remove ProxyMessagePipeEndpoint::EnqueueMessageInternal().
We can now fold it into EnqueueMessage().
R=yzshen@chromium.org
Review URL: https://codereview.chromium.org/177003011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system')
-rw-r--r-- | mojo/system/proxy_message_pipe_endpoint.cc | 41 | ||||
-rw-r--r-- | mojo/system/proxy_message_pipe_endpoint.h | 2 |
2 files changed, 18 insertions, 25 deletions
diff --git a/mojo/system/proxy_message_pipe_endpoint.cc b/mojo/system/proxy_message_pipe_endpoint.cc index 61a2448..f0a5de5 100644 --- a/mojo/system/proxy_message_pipe_endpoint.cc +++ b/mojo/system/proxy_message_pipe_endpoint.cc @@ -46,15 +46,20 @@ void ProxyMessagePipeEndpoint::OnPeerClose() { DCHECK(is_peer_open_); is_peer_open_ = false; - EnqueueMessageInternal(make_scoped_ptr( + EnqueueMessage(make_scoped_ptr( new MessageInTransit(MessageInTransit::OWNED_BUFFER, MessageInTransit::kTypeMessagePipe, MessageInTransit::kSubtypeMessagePipePeerClosed, 0, 0, NULL))); } +// Note: We may have to enqueue messages even when our (local) peer isn't open +// -- it may have been written to and closed immediately, before we were ready. +// This case is handled in |Run()| (which will call us). void ProxyMessagePipeEndpoint::EnqueueMessage( scoped_ptr<MessageInTransit> message) { + DCHECK(is_open_); + if (message->dispatchers() && !message->dispatchers()->empty()) { // Since the dispatchers are attached to the message, they'll be closed on // message destruction. @@ -62,7 +67,17 @@ void ProxyMessagePipeEndpoint::EnqueueMessage( "(sent handles will simply be closed)"; } - EnqueueMessageInternal(message.Pass()); + if (is_running()) { + message->set_source_id(local_id_); + message->set_destination_id(remote_id_); + // If it fails at this point, the message gets dropped. (This is no + // different from any other in-transit errors.) + // Note: |WriteMessage()| will destroy the message even on failure. + if (!channel_->WriteMessage(message.Pass())) + LOG(WARNING) << "Failed to write message to channel"; + } else { + paused_message_queue_.push_back(message.release()); + } } void ProxyMessagePipeEndpoint::Attach(scoped_refptr<Channel> channel, @@ -93,30 +108,10 @@ void ProxyMessagePipeEndpoint::Run(MessageInTransit::EndpointId remote_id) { for (std::deque<MessageInTransit*>::iterator it = paused_message_queue_.begin(); it != paused_message_queue_.end(); ++it) - EnqueueMessageInternal(make_scoped_ptr(*it)); + EnqueueMessage(make_scoped_ptr(*it)); paused_message_queue_.clear(); } -// Note: We may have to enqueue messages even when our (local) peer isn't open -// -- it may have been written to and closed immediately, before we were ready. -// This case is handled in |Run()| (which will call us). -void ProxyMessagePipeEndpoint::EnqueueMessageInternal( - scoped_ptr<MessageInTransit> message) { - DCHECK(is_open_); - - if (is_running()) { - message->set_source_id(local_id_); - message->set_destination_id(remote_id_); - // If it fails at this point, the message gets dropped. (This is no - // different from any other in-transit errors.) - // Note: |WriteMessage()| will destroy the message even on failure. - if (!channel_->WriteMessage(message.Pass())) - LOG(WARNING) << "Failed to write message to channel"; - } else { - paused_message_queue_.push_back(message.release()); - } -} - #ifndef NDEBUG void ProxyMessagePipeEndpoint::AssertConsistentState() const { if (is_attached()) { diff --git a/mojo/system/proxy_message_pipe_endpoint.h b/mojo/system/proxy_message_pipe_endpoint.h index 1e1b2ea..68f1d89 100644 --- a/mojo/system/proxy_message_pipe_endpoint.h +++ b/mojo/system/proxy_message_pipe_endpoint.h @@ -61,8 +61,6 @@ class MOJO_SYSTEM_IMPL_EXPORT ProxyMessagePipeEndpoint return remote_id_ != MessageInTransit::kInvalidEndpointId; } - void EnqueueMessageInternal(scoped_ptr<MessageInTransit> message); - #ifdef NDEBUG void AssertConsistentState() const {} #else |