Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / content / renderer / media / mock_data_channel_impl.cc
blob4d7991b2e3d47182db6b5b13d567ec3d7d1d9c7b
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"
9 namespace content {
11 MockDataChannel::MockDataChannel(const std::string& label,
12 const webrtc::DataChannelInit* config)
13 : label_(label),
14 reliable_(config->reliable),
15 state_(webrtc::DataChannelInterface::kConnecting),
16 config_(*config),
17 observer_(nullptr) {
20 MockDataChannel::~MockDataChannel() {
23 void MockDataChannel::RegisterObserver(webrtc::DataChannelObserver* observer) {
24 observer_ = observer;
27 void MockDataChannel::UnregisterObserver() {
28 observer_ = nullptr;
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 {
50 NOTIMPLEMENTED();
51 return 0;
54 MockDataChannel::DataState MockDataChannel::state() const { return state_; }
56 // For testing.
57 void MockDataChannel::changeState(DataState state) {
58 state_ = state;
59 if (observer_)
60 observer_->OnStateChange();
63 uint64 MockDataChannel::buffered_amount() const {
64 NOTIMPLEMENTED();
65 return 0;
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