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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_DATA_CHANNEL_HANDLER_H_
6 #define COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_DATA_CHANNEL_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "components/test_runner/web_task.h"
10 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h"
11 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandlerClient.h"
12 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h"
13 #include "third_party/WebKit/public/platform/WebString.h"
15 namespace test_runner
{
17 class WebTestDelegate
;
19 class MockWebRTCDataChannelHandler
: public blink::WebRTCDataChannelHandler
{
21 MockWebRTCDataChannelHandler(blink::WebString label
,
22 const blink::WebRTCDataChannelInit
& init
,
23 WebTestDelegate
* delegate
);
25 // WebRTCDataChannelHandler related methods
26 virtual void setClient(
27 blink::WebRTCDataChannelHandlerClient
* client
) override
;
28 virtual blink::WebString
label() override
;
29 virtual bool isReliable() override
;
30 virtual bool ordered() const override
;
31 virtual unsigned short maxRetransmitTime() const override
;
32 virtual unsigned short maxRetransmits() const override
;
33 virtual blink::WebString
protocol() const override
;
34 virtual bool negotiated() const override
;
35 virtual unsigned short id() const override
;
36 // TODO(bemasc): Mark |state()| as |override| once https://codereview.chromium.org/782843003/
37 // lands in Blink and rolls into Chromium.
38 virtual blink::WebRTCDataChannelHandlerClient::ReadyState
state() const;
39 virtual unsigned long bufferedAmount() override
;
40 virtual bool sendStringData(const blink::WebString
& data
) override
;
41 virtual bool sendRawData(const char* data
, size_t size
) override
;
42 virtual void close() override
;
44 // WebTask related methods
45 WebTaskList
* mutable_task_list() { return &task_list_
; }
48 MockWebRTCDataChannelHandler();
50 blink::WebRTCDataChannelHandlerClient
* client_
;
51 blink::WebString label_
;
52 blink::WebRTCDataChannelInit init_
;
54 WebTaskList task_list_
;
55 WebTestDelegate
* delegate_
;
57 DISALLOW_COPY_AND_ASSIGN(MockWebRTCDataChannelHandler
);
60 } // namespace test_runner
62 #endif // COMPONENTS_TEST_RUNNER_MOCK_WEBRTC_DATA_CHANNEL_HANDLER_H_