| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <iomanip> | 11 #include <iomanip> |
| 12 | 12 |
| 13 #include "webrtc/base/asyncsocket.h" | 13 #include "webrtc/base/asyncsocket.h" |
| 14 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/base/socketfactory.h" | 16 #include "webrtc/base/socketfactory.h" |
| 16 #include "webrtc/base/socketpool.h" | 17 #include "webrtc/base/socketpool.h" |
| 17 #include "webrtc/base/socketstream.h" | 18 #include "webrtc/base/socketstream.h" |
| 18 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
| 19 | 20 |
| 20 namespace rtc { | 21 namespace rtc { |
| 21 | 22 |
| 22 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
| 23 // StreamCache - Caches a set of open streams, defers creation to a separate | 24 // StreamCache - Caches a set of open streams, defers creation to a separate |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } else { | 76 } else { |
| 76 // Monitor open streams | 77 // Monitor open streams |
| 77 stream->SignalEvent.connect(this, &StreamCache::OnStreamEvent); | 78 stream->SignalEvent.connect(this, &StreamCache::OnStreamEvent); |
| 78 LOG_F(LS_VERBOSE) << "Caching stream"; | 79 LOG_F(LS_VERBOSE) << "Caching stream"; |
| 79 cached_.push_front(*it); | 80 cached_.push_front(*it); |
| 80 } | 81 } |
| 81 active_.erase(it); | 82 active_.erase(it); |
| 82 return; | 83 return; |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 ASSERT(false); | 86 RTC_NOTREACHED(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void StreamCache::OnStreamEvent(StreamInterface* stream, int events, int err) { | 89 void StreamCache::OnStreamEvent(StreamInterface* stream, int events, int err) { |
| 89 if ((events & SE_CLOSE) == 0) { | 90 if ((events & SE_CLOSE) == 0) { |
| 90 LOG_F(LS_WARNING) << "(" << events << ", " << err | 91 LOG_F(LS_WARNING) << "(" << events << ", " << err |
| 91 << ") received non-close event"; | 92 << ") received non-close event"; |
| 92 return; | 93 return; |
| 93 } | 94 } |
| 94 for (ConnectedList::iterator it = cached_.begin(); it != cached_.end(); | 95 for (ConnectedList::iterator it = cached_.begin(); it != cached_.end(); |
| 95 ++it) { | 96 ++it) { |
| 96 if (stream == it->second) { | 97 if (stream == it->second) { |
| 97 LOG_F(LS_VERBOSE) << "(" << it->first << ")"; | 98 LOG_F(LS_VERBOSE) << "(" << it->first << ")"; |
| 98 // We don't cache closed streams, so return it. | 99 // We don't cache closed streams, so return it. |
| 99 it->second->SignalEvent.disconnect(this); | 100 it->second->SignalEvent.disconnect(this); |
| 100 LOG_F(LS_VERBOSE) << "Returning closed stream"; | 101 LOG_F(LS_VERBOSE) << "Returning closed stream"; |
| 101 pool_->ReturnConnectedStream(it->second); | 102 pool_->ReturnConnectedStream(it->second); |
| 102 cached_.erase(it); | 103 cached_.erase(it); |
| 103 return; | 104 return; |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 ASSERT(false); | 107 RTC_NOTREACHED(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 ////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////// |
| 110 // NewSocketPool | 111 // NewSocketPool |
| 111 ////////////////////////////////////////////////////////////////////// | 112 ////////////////////////////////////////////////////////////////////// |
| 112 | 113 |
| 113 NewSocketPool::NewSocketPool(SocketFactory* factory) : factory_(factory) { | 114 NewSocketPool::NewSocketPool(SocketFactory* factory) : factory_(factory) { |
| 114 } | 115 } |
| 115 | 116 |
| 116 NewSocketPool::~NewSocketPool() { | 117 NewSocketPool::~NewSocketPool() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 272 |
| 272 void LoggingPoolAdapter::ReturnConnectedStream(StreamInterface* stream) { | 273 void LoggingPoolAdapter::ReturnConnectedStream(StreamInterface* stream) { |
| 273 LoggingAdapter* logging = static_cast<LoggingAdapter*>(stream); | 274 LoggingAdapter* logging = static_cast<LoggingAdapter*>(stream); |
| 274 pool_->ReturnConnectedStream(logging->Detach()); | 275 pool_->ReturnConnectedStream(logging->Detach()); |
| 275 recycle_bin_.push_back(logging); | 276 recycle_bin_.push_back(logging); |
| 276 } | 277 } |
| 277 | 278 |
| 278 /////////////////////////////////////////////////////////////////////////////// | 279 /////////////////////////////////////////////////////////////////////////////// |
| 279 | 280 |
| 280 } // namespace rtc | 281 } // namespace rtc |
| OLD | NEW |