OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 private: | 50 private: |
51 WebRTCDataChannelHandlerClient* m_dataChannelClient; | 51 WebRTCDataChannelHandlerClient* m_dataChannelClient; |
52 WebRTCDataChannelHandlerClient::ReadyState m_state; | 52 WebRTCDataChannelHandlerClient::ReadyState m_state; |
53 }; | 53 }; |
54 | 54 |
55 ///////////////////// | 55 ///////////////////// |
56 | 56 |
57 MockWebRTCDataChannelHandler::MockWebRTCDataChannelHandler(WebString label, cons
t WebRTCDataChannelInit& init, WebTestDelegate* delegate) | 57 MockWebRTCDataChannelHandler::MockWebRTCDataChannelHandler(WebString label, cons
t WebRTCDataChannelInit& init, WebTestDelegate* delegate) |
58 : m_client(0) | 58 : m_client(0) |
59 , m_label(label) | 59 , m_label(label) |
| 60 , m_init(init) |
60 , m_delegate(delegate) | 61 , m_delegate(delegate) |
61 { | 62 { |
62 m_reliable = (init.ordered && init.maxRetransmits == -1 && init.maxRetransmi
tTime == -1); | 63 m_reliable = (init.ordered && init.maxRetransmits == -1 && init.maxRetransmi
tTime == -1); |
63 } | 64 } |
64 | 65 |
65 void MockWebRTCDataChannelHandler::setClient(WebRTCDataChannelHandlerClient* cli
ent) | 66 void MockWebRTCDataChannelHandler::setClient(WebRTCDataChannelHandlerClient* cli
ent) |
66 { | 67 { |
67 m_client = client; | 68 m_client = client; |
68 if (m_client) | 69 if (m_client) |
69 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRT
CDataChannelHandlerClient::ReadyStateOpen)); | 70 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRT
CDataChannelHandlerClient::ReadyStateOpen)); |
70 } | 71 } |
71 | 72 |
| 73 bool MockWebRTCDataChannelHandler::ordered() const |
| 74 { |
| 75 return m_init.ordered; |
| 76 } |
| 77 |
| 78 unsigned short MockWebRTCDataChannelHandler::maxRetransmitTime() const |
| 79 { |
| 80 return m_init.maxRetransmitTime; |
| 81 } |
| 82 |
| 83 unsigned short MockWebRTCDataChannelHandler::maxRetransmits() const |
| 84 { |
| 85 return m_init.maxRetransmits; |
| 86 } |
| 87 |
| 88 WebString MockWebRTCDataChannelHandler::protocol() const |
| 89 { |
| 90 return m_init.protocol; |
| 91 } |
| 92 |
| 93 bool MockWebRTCDataChannelHandler::negotiated() const |
| 94 { |
| 95 return m_init.negotiated; |
| 96 } |
| 97 |
| 98 unsigned short MockWebRTCDataChannelHandler::id() const |
| 99 { |
| 100 return m_init.id; |
| 101 } |
| 102 |
72 unsigned long MockWebRTCDataChannelHandler::bufferedAmount() | 103 unsigned long MockWebRTCDataChannelHandler::bufferedAmount() |
73 { | 104 { |
74 return 0; | 105 return 0; |
75 } | 106 } |
76 | 107 |
77 bool MockWebRTCDataChannelHandler::sendStringData(const WebString& data) | 108 bool MockWebRTCDataChannelHandler::sendStringData(const WebString& data) |
78 { | 109 { |
79 assert(m_client); | 110 assert(m_client); |
80 m_client->didReceiveStringData(data); | 111 m_client->didReceiveStringData(data); |
81 return true; | 112 return true; |
82 } | 113 } |
83 | 114 |
84 bool MockWebRTCDataChannelHandler::sendRawData(const char* data, size_t size) | 115 bool MockWebRTCDataChannelHandler::sendRawData(const char* data, size_t size) |
85 { | 116 { |
86 assert(m_client); | 117 assert(m_client); |
87 m_client->didReceiveRawData(data, size); | 118 m_client->didReceiveRawData(data, size); |
88 return true; | 119 return true; |
89 } | 120 } |
90 | 121 |
91 void MockWebRTCDataChannelHandler::close() | 122 void MockWebRTCDataChannelHandler::close() |
92 { | 123 { |
93 assert(m_client); | 124 assert(m_client); |
94 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRTCDat
aChannelHandlerClient::ReadyStateClosed)); | 125 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRTCDat
aChannelHandlerClient::ReadyStateClosed)); |
95 } | 126 } |
96 | 127 |
97 } | 128 } |
OLD | NEW |