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 3 // found in the LICENSE file. 4 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_MESSAGE_QUEUE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_MESSAGE_QUEUE_H_ 7 8 #include "base/containers/queue.h" 9 #include "base/macros.h" 10 #include "mojo/public/cpp/bindings/message.h" 11 12 namespace mojo { 13 namespace test { 14 15 // A queue for Message objects. 16 class MessageQueue { 17 public: 18 MessageQueue(); 19 ~MessageQueue(); 20 21 bool IsEmpty() const; 22 23 // This method copies the message data and steals ownership of its handles. 24 void Push(Message* message); 25 26 // Removes the next message from the queue, copying its data and transferring 27 // ownership of its handles to the given |message|. 28 void Pop(Message* message); 29 size()30 size_t size() const { return queue_.size(); } 31 32 private: 33 void Pop(); 34 35 base::queue<Message> queue_; 36 37 DISALLOW_COPY_AND_ASSIGN(MessageQueue); 38 }; 39 40 } // namespace test 41 } // namespace mojo 42 43 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_MESSAGE_QUEUE_H_ 44