| 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 11 matching lines...) Expand all Loading... |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #include "MockWebRTCDataChannelHandler.h" | 27 #include "MockWebRTCDataChannelHandler.h" |
| 28 | 28 |
| 29 #include "WebTestDelegate.h" | 29 #include "WebTestDelegate.h" |
| 30 #include <assert.h> | 30 #include <assert.h> |
| 31 #include "public/platform/WebRTCDataChannelHandlerClient.h" | 31 #include "public/platform/WebRTCDataChannelHandlerClient.h" |
| 32 #include "public/platform/WebRTCDataChannelInit.h" |
| 32 | 33 |
| 33 using namespace WebKit; | 34 using namespace WebKit; |
| 34 | 35 |
| 35 namespace WebTestRunner { | 36 namespace WebTestRunner { |
| 36 | 37 |
| 37 class DataChannelReadyStateTask : public WebMethodTask<MockWebRTCDataChannelHand
ler> { | 38 class DataChannelReadyStateTask : public WebMethodTask<MockWebRTCDataChannelHand
ler> { |
| 38 public: | 39 public: |
| 39 DataChannelReadyStateTask(MockWebRTCDataChannelHandler* object, WebRTCDataCh
annelHandlerClient* dataChannelClient, WebRTCDataChannelHandlerClient::ReadyStat
e state) | 40 DataChannelReadyStateTask(MockWebRTCDataChannelHandler* object, WebRTCDataCh
annelHandlerClient* dataChannelClient, WebRTCDataChannelHandlerClient::ReadyStat
e state) |
| 40 : WebMethodTask<MockWebRTCDataChannelHandler>(object) | 41 : WebMethodTask<MockWebRTCDataChannelHandler>(object) |
| 41 , m_dataChannelClient(dataChannelClient) | 42 , m_dataChannelClient(dataChannelClient) |
| 42 , m_state(state) | 43 , m_state(state) |
| 43 { | 44 { |
| 44 } | 45 } |
| 45 | 46 |
| 46 virtual void runIfValid() OVERRIDE | 47 virtual void runIfValid() OVERRIDE |
| 47 { | 48 { |
| 48 m_dataChannelClient->didChangeReadyState(m_state); | 49 m_dataChannelClient->didChangeReadyState(m_state); |
| 49 } | 50 } |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 WebRTCDataChannelHandlerClient* m_dataChannelClient; | 53 WebRTCDataChannelHandlerClient* m_dataChannelClient; |
| 53 WebRTCDataChannelHandlerClient::ReadyState m_state; | 54 WebRTCDataChannelHandlerClient::ReadyState m_state; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 ///////////////////// | 57 ///////////////////// |
| 57 | 58 |
| 58 MockWebRTCDataChannelHandler::MockWebRTCDataChannelHandler(WebString label, bool
reliable, WebTestDelegate* delegate) | 59 MockWebRTCDataChannelHandler::MockWebRTCDataChannelHandler(WebString label, cons
t WebRTCDataChannelInit& init, WebTestDelegate* delegate) |
| 59 : m_client(0) | 60 : m_client(0) |
| 60 , m_label(label) | 61 , m_label(label) |
| 61 , m_reliable(reliable) | |
| 62 , m_delegate(delegate) | 62 , m_delegate(delegate) |
| 63 { | 63 { |
| 64 m_reliable = (init.ordered && init.maxRetransmits == -1 && init.maxRetransmi
tTime == -1); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void MockWebRTCDataChannelHandler::setClient(WebRTCDataChannelHandlerClient* cli
ent) | 67 void MockWebRTCDataChannelHandler::setClient(WebRTCDataChannelHandlerClient* cli
ent) |
| 67 { | 68 { |
| 68 m_client = client; | 69 m_client = client; |
| 69 if (m_client) | 70 if (m_client) |
| 70 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRT
CDataChannelHandlerClient::ReadyStateOpen)); | 71 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRT
CDataChannelHandlerClient::ReadyStateOpen)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 unsigned long MockWebRTCDataChannelHandler::bufferedAmount() | 74 unsigned long MockWebRTCDataChannelHandler::bufferedAmount() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void MockWebRTCDataChannelHandler::close() | 93 void MockWebRTCDataChannelHandler::close() |
| 93 { | 94 { |
| 94 assert(m_client); | 95 assert(m_client); |
| 95 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRTCDat
aChannelHandlerClient::ReadyStateClosed)); | 96 m_delegate->postTask(new DataChannelReadyStateTask(this, m_client, WebRTCDat
aChannelHandlerClient::ReadyStateClosed)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } | 99 } |
| OLD | NEW |