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 #include "content/renderer/media/mock_data_channel_impl.h"
9 MockDataChannel::MockDataChannel(const std::string
& label
,
10 const webrtc::DataChannelInit
* config
)
12 reliable_(config
->reliable
),
13 state_(webrtc::DataChannelInterface::kConnecting
),
18 MockDataChannel::~MockDataChannel() {
21 void MockDataChannel::RegisterObserver(webrtc::DataChannelObserver
* observer
) {
25 void MockDataChannel::UnregisterObserver() {
29 std::string
MockDataChannel::label() const { return label_
; }
31 bool MockDataChannel::reliable() const { return reliable_
; }
33 bool MockDataChannel::ordered() const { return config_
.ordered
; }
35 unsigned short MockDataChannel::maxRetransmitTime() const {
36 return config_
.maxRetransmitTime
;
39 unsigned short MockDataChannel::maxRetransmits() const {
40 return config_
.maxRetransmits
;
43 std::string
MockDataChannel::protocol() const { return config_
.protocol
; }
45 bool MockDataChannel::negotiated() const { return config_
.negotiated
; }
47 int MockDataChannel::id() const {
52 MockDataChannel::DataState
MockDataChannel::state() const { return state_
; }
55 void MockDataChannel::changeState(DataState state
) {
58 observer_
->OnStateChange();
61 uint64
MockDataChannel::buffered_amount() const {
66 void MockDataChannel::Close() {
67 changeState(webrtc::DataChannelInterface::kClosing
);
70 bool MockDataChannel::Send(const webrtc::DataBuffer
& buffer
) {
71 return state_
== webrtc::DataChannelInterface::kOpen
;
74 } // namespace content