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"
7 #include "base/logging.h"
11 MockDataChannel::MockDataChannel(const std::string
& label
,
12 const webrtc::DataChannelInit
* config
)
14 reliable_(config
->reliable
),
15 state_(webrtc::DataChannelInterface::kConnecting
),
20 MockDataChannel::~MockDataChannel() {
23 void MockDataChannel::RegisterObserver(webrtc::DataChannelObserver
* observer
) {
27 void MockDataChannel::UnregisterObserver() {
31 std::string
MockDataChannel::label() const { return label_
; }
33 bool MockDataChannel::reliable() const { return reliable_
; }
35 bool MockDataChannel::ordered() const { return config_
.ordered
; }
37 unsigned short MockDataChannel::maxRetransmitTime() const {
38 return config_
.maxRetransmitTime
;
41 unsigned short MockDataChannel::maxRetransmits() const {
42 return config_
.maxRetransmits
;
45 std::string
MockDataChannel::protocol() const { return config_
.protocol
; }
47 bool MockDataChannel::negotiated() const { return config_
.negotiated
; }
49 int MockDataChannel::id() const {
54 MockDataChannel::DataState
MockDataChannel::state() const { return state_
; }
57 void MockDataChannel::changeState(DataState state
) {
60 observer_
->OnStateChange();
63 uint64
MockDataChannel::buffered_amount() const {
68 void MockDataChannel::Close() {
69 changeState(webrtc::DataChannelInterface::kClosing
);
72 bool MockDataChannel::Send(const webrtc::DataBuffer
& buffer
) {
73 return state_
== webrtc::DataChannelInterface::kOpen
;
76 } // namespace content