Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / content / renderer / media / mock_data_channel_impl.cc
blob8a0a3a80c950b21988c832ddb68fa6e5fad37e25
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 namespace content {
9 MockDataChannel::MockDataChannel(const std::string& label,
10 const webrtc::DataChannelInit* config)
11 : label_(label),
12 reliable_(config->reliable),
13 state_(webrtc::DataChannelInterface::kConnecting),
14 config_(*config),
15 observer_(nullptr) {
18 MockDataChannel::~MockDataChannel() {
21 void MockDataChannel::RegisterObserver(webrtc::DataChannelObserver* observer) {
22 observer_ = observer;
25 void MockDataChannel::UnregisterObserver() {
26 observer_ = nullptr;
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 {
48 NOTIMPLEMENTED();
49 return 0;
52 MockDataChannel::DataState MockDataChannel::state() const { return state_; }
54 // For testing.
55 void MockDataChannel::changeState(DataState state) {
56 state_ = state;
57 if (observer_)
58 observer_->OnStateChange();
61 uint64 MockDataChannel::buffered_amount() const {
62 NOTIMPLEMENTED();
63 return 0;
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