OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/shell/renderer/test_runner/mock_webrtc_data_channel_handler.h" | 5 #include "content/shell/renderer/test_runner/mock_webrtc_data_channel_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
9 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandlerClient.h" | 9 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandlerClient.h" |
10 | 10 |
11 using namespace blink; | 11 using namespace blink; |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class DataChannelReadyStateTask | 15 class DataChannelReadyStateTask |
16 : public WebMethodTask<MockWebRTCDataChannelHandler> { | 16 : public WebMethodTask<MockWebRTCDataChannelHandler> { |
17 public: | 17 public: |
18 DataChannelReadyStateTask(MockWebRTCDataChannelHandler* object, | 18 DataChannelReadyStateTask(MockWebRTCDataChannelHandler* object, |
(...skipping 20 matching lines...) Expand all Loading... |
39 WebTestDelegate* delegate) | 39 WebTestDelegate* delegate) |
40 : client_(0), label_(label), init_(init), delegate_(delegate) { | 40 : client_(0), label_(label), init_(init), delegate_(delegate) { |
41 reliable_ = (init.ordered && init.maxRetransmits == -1 && | 41 reliable_ = (init.ordered && init.maxRetransmits == -1 && |
42 init.maxRetransmitTime == -1); | 42 init.maxRetransmitTime == -1); |
43 } | 43 } |
44 | 44 |
45 void MockWebRTCDataChannelHandler::setClient( | 45 void MockWebRTCDataChannelHandler::setClient( |
46 WebRTCDataChannelHandlerClient* client) { | 46 WebRTCDataChannelHandlerClient* client) { |
47 client_ = client; | 47 client_ = client; |
48 if (client_) | 48 if (client_) |
49 delegate_->postTask(new DataChannelReadyStateTask( | 49 delegate_->PostTask(new DataChannelReadyStateTask( |
50 this, client_, WebRTCDataChannelHandlerClient::ReadyStateOpen)); | 50 this, client_, WebRTCDataChannelHandlerClient::ReadyStateOpen)); |
51 } | 51 } |
52 | 52 |
53 blink::WebString MockWebRTCDataChannelHandler::label() { | 53 blink::WebString MockWebRTCDataChannelHandler::label() { |
54 return label_; | 54 return label_; |
55 } | 55 } |
56 | 56 |
57 bool MockWebRTCDataChannelHandler::isReliable() { | 57 bool MockWebRTCDataChannelHandler::isReliable() { |
58 return reliable_; | 58 return reliable_; |
59 } | 59 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 bool MockWebRTCDataChannelHandler::sendRawData(const char* data, size_t size) { | 95 bool MockWebRTCDataChannelHandler::sendRawData(const char* data, size_t size) { |
96 DCHECK(client_); | 96 DCHECK(client_); |
97 client_->didReceiveRawData(data, size); | 97 client_->didReceiveRawData(data, size); |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 void MockWebRTCDataChannelHandler::close() { | 101 void MockWebRTCDataChannelHandler::close() { |
102 DCHECK(client_); | 102 DCHECK(client_); |
103 delegate_->postTask(new DataChannelReadyStateTask( | 103 delegate_->PostTask(new DataChannelReadyStateTask( |
104 this, client_, WebRTCDataChannelHandlerClient::ReadyStateClosed)); | 104 this, client_, WebRTCDataChannelHandlerClient::ReadyStateClosed)); |
105 } | 105 } |
106 | 106 |
107 } // namespace content | 107 } // namespace content |
OLD | NEW |