OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/support/test_webmessageportchannel.h" | 5 #include "webkit/support/test_webmessageportchannel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel
Client.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel
Client.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 WebString data_; | 34 WebString data_; |
35 scoped_ptr<WebMessagePortChannelArray> ports_; | 35 scoped_ptr<WebMessagePortChannelArray> ports_; |
36 DISALLOW_COPY_AND_ASSIGN(Message); | 36 DISALLOW_COPY_AND_ASSIGN(Message); |
37 }; | 37 }; |
38 | 38 |
39 TestWebMessagePortChannel::TestWebMessagePortChannel() | 39 TestWebMessagePortChannel::TestWebMessagePortChannel() |
40 : client_(NULL) { | 40 : client_(NULL) { |
41 AddRef(); | 41 AddRef(); |
42 } | 42 } |
43 | 43 |
44 TestWebMessagePortChannel::~TestWebMessagePortChannel() { | |
45 } | |
46 | |
47 void TestWebMessagePortChannel::setClient(WebMessagePortChannelClient* client) { | 44 void TestWebMessagePortChannel::setClient(WebMessagePortChannelClient* client) { |
48 client_ = client; | 45 client_ = client; |
49 } | 46 } |
50 | 47 |
51 void TestWebMessagePortChannel::destroy() { | 48 void TestWebMessagePortChannel::destroy() { |
52 while (!message_queue_.empty()) { | 49 while (!message_queue_.empty()) { |
53 delete message_queue_.front(); | 50 delete message_queue_.front(); |
54 message_queue_.pop(); | 51 message_queue_.pop(); |
55 } | 52 } |
56 Release(); | 53 Release(); |
(...skipping 18 matching lines...) Expand all Loading... |
75 if (message_queue_.empty()) | 72 if (message_queue_.empty()) |
76 return false; | 73 return false; |
77 scoped_ptr<Message> message(message_queue_.front()); | 74 scoped_ptr<Message> message(message_queue_.front()); |
78 message_queue_.pop(); | 75 message_queue_.pop(); |
79 *data = message->data(); | 76 *data = message->data(); |
80 if (WebMessagePortChannelArray* message_ports = message->ports()) | 77 if (WebMessagePortChannelArray* message_ports = message->ports()) |
81 ports.swap(*message_ports); | 78 ports.swap(*message_ports); |
82 return true; | 79 return true; |
83 } | 80 } |
84 | 81 |
| 82 TestWebMessagePortChannel::~TestWebMessagePortChannel() {} |
| 83 |
85 void TestWebMessagePortChannel::queueMessage(Message* message) { | 84 void TestWebMessagePortChannel::queueMessage(Message* message) { |
86 bool was_empty = message_queue_.empty(); | 85 bool was_empty = message_queue_.empty(); |
87 message_queue_.push(message); | 86 message_queue_.push(message); |
88 if (client_ && was_empty) | 87 if (client_ && was_empty) |
89 client_->messageAvailable(); | 88 client_->messageAvailable(); |
90 } | 89 } |
OLD | NEW |