OLD | NEW |
| (Empty) |
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 #include "mojo/public/cpp/bindings/tests/message_queue.h" | |
6 | |
7 #include "mojo/public/cpp/bindings/message.h" | |
8 #include "mojo/public/cpp/environment/logging.h" | |
9 | |
10 namespace mojo { | |
11 namespace test { | |
12 | |
13 MessageQueue::MessageQueue() { | |
14 } | |
15 | |
16 MessageQueue::~MessageQueue() { | |
17 while (!queue_.empty()) | |
18 Pop(); | |
19 } | |
20 | |
21 bool MessageQueue::IsEmpty() const { | |
22 return queue_.empty(); | |
23 } | |
24 | |
25 void MessageQueue::Push(Message* message) { | |
26 queue_.push(new Message()); | |
27 message->MoveTo(queue_.back()); | |
28 } | |
29 | |
30 void MessageQueue::Pop(Message* message) { | |
31 MOJO_DCHECK(!queue_.empty()); | |
32 queue_.front()->MoveTo(message); | |
33 Pop(); | |
34 } | |
35 | |
36 void MessageQueue::Pop() { | |
37 MOJO_DCHECK(!queue_.empty()); | |
38 delete queue_.front(); | |
39 queue_.pop(); | |
40 } | |
41 | |
42 } // namespace test | |
43 } // namespace mojo | |
OLD | NEW |