Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / p2p / base / transportchannel.cc
1 /*
2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #include <sstream>
12 #include "webrtc/p2p/base/transportchannel.h"
13
14 namespace cricket {
15
16 std::string TransportChannel::ToString() const {
17   const char READABLE_ABBREV[2] = { '_', 'R' };
18   const char WRITABLE_ABBREV[2] = { '_', 'W' };
19   std::stringstream ss;
20   ss << "Channel[" << content_name_
21      << "|" << component_
22      << "|" << READABLE_ABBREV[readable_] << WRITABLE_ABBREV[writable_] << "]";
23   return ss.str();
24 }
25
26 void TransportChannel::set_readable(bool readable) {
27   if (readable_ != readable) {
28     readable_ = readable;
29     SignalReadableState(this);
30   }
31 }
32
33 void TransportChannel::set_writable(bool writable) {
34   if (writable_ != writable) {
35     writable_ = writable;
36     if (writable_) {
37       SignalReadyToSend(this);
38     }
39     SignalWritableState(this);
40   }
41 }
42
43 }  // namespace cricket