Commit a31e5b91 authored by viettrungluu's avatar viettrungluu Committed by Commit bot

Mojo: Add a MessageInTransit::Swap() method and remove the "PassContents" ctor.

R=darin@chromium.org

Review URL: https://codereview.chromium.org/585633004

Cr-Commit-Position: refs/heads/master@{#295730}
parent 1a1d35bb
...@@ -13,11 +13,6 @@ namespace system { ...@@ -13,11 +13,6 @@ namespace system {
MessageInTransitQueue::MessageInTransitQueue() { MessageInTransitQueue::MessageInTransitQueue() {
} }
MessageInTransitQueue::MessageInTransitQueue(PassContents,
MessageInTransitQueue* other) {
queue_.swap(other->queue_);
}
MessageInTransitQueue::~MessageInTransitQueue() { MessageInTransitQueue::~MessageInTransitQueue() {
if (!IsEmpty()) { if (!IsEmpty()) {
LOG(WARNING) << "Destroying nonempty message queue"; LOG(WARNING) << "Destroying nonempty message queue";
...@@ -29,5 +24,9 @@ void MessageInTransitQueue::Clear() { ...@@ -29,5 +24,9 @@ void MessageInTransitQueue::Clear() {
STLDeleteElements(&queue_); STLDeleteElements(&queue_);
} }
void MessageInTransitQueue::Swap(MessageInTransitQueue* other) {
queue_.swap(other->queue_);
}
} // namespace system } // namespace system
} // namespace mojo } // namespace mojo
...@@ -21,12 +21,6 @@ namespace system { ...@@ -21,12 +21,6 @@ namespace system {
class MOJO_SYSTEM_IMPL_EXPORT MessageInTransitQueue { class MOJO_SYSTEM_IMPL_EXPORT MessageInTransitQueue {
public: public:
MessageInTransitQueue(); MessageInTransitQueue();
struct PassContents {};
// Constructor that takes over the contents of another
// |MessageInTransitQueue|, leaving it empty.
MessageInTransitQueue(PassContents, MessageInTransitQueue* other);
~MessageInTransitQueue(); ~MessageInTransitQueue();
bool IsEmpty() const { return queue_.empty(); } bool IsEmpty() const { return queue_.empty(); }
...@@ -50,6 +44,9 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransitQueue { ...@@ -50,6 +44,9 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransitQueue {
void Clear(); void Clear();
// Efficiently swaps contents with |*other|.
void Swap(MessageInTransitQueue* other);
private: private:
// TODO(vtl): When C++11 is available, switch this to a deque of // TODO(vtl): When C++11 is available, switch this to a deque of
// |scoped_ptr|/|unique_ptr|s. // |scoped_ptr|/|unique_ptr|s.
......
...@@ -21,10 +21,8 @@ ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint() ...@@ -21,10 +21,8 @@ ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint()
ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint( ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint(
LocalMessagePipeEndpoint* local_message_pipe_endpoint, LocalMessagePipeEndpoint* local_message_pipe_endpoint,
bool is_peer_open) bool is_peer_open)
: is_running_(false), : is_running_(false), is_peer_open_(is_peer_open) {
is_peer_open_(is_peer_open), paused_message_queue_.Swap(local_message_pipe_endpoint->message_queue());
paused_message_queue_(MessageInTransitQueue::PassContents(),
local_message_pipe_endpoint->message_queue()) {
local_message_pipe_endpoint->Close(); local_message_pipe_endpoint->Close();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment