Cleanup and prepare for bundling.
- Add a GetOptions function. Needed for eventual bundle testing to confirm that channel options are preserved. - Simplify unit tests and cleanup unused code. BUG=1574 R=pthatcher@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/39699004 Cr-Commit-Position: refs/heads/master@{#8237} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8237 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -126,6 +126,9 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value) {
|
||||
return channel_->SetOption(opt, value);
|
||||
}
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value) {
|
||||
return channel_->GetOption(opt, value);
|
||||
}
|
||||
virtual int GetError() {
|
||||
return channel_->GetError();
|
||||
}
|
||||
|
||||
@@ -198,6 +198,9 @@ class FakeTransportChannel : public TransportChannelImpl,
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value) {
|
||||
return true;
|
||||
}
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value) {
|
||||
return true;
|
||||
}
|
||||
virtual int GetError() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -817,6 +817,7 @@ void P2PTransportChannel::RememberRemoteCandidate(
|
||||
// Set options on ourselves is simply setting options on all of our available
|
||||
// port objects.
|
||||
int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
|
||||
ASSERT(worker_thread_ == rtc::Thread::Current());
|
||||
OptionMap::iterator it = options_.find(opt);
|
||||
if (it == options_.end()) {
|
||||
options_.insert(std::make_pair(opt, value));
|
||||
@@ -838,6 +839,17 @@ int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool P2PTransportChannel::GetOption(rtc::Socket::Option opt, int* value) {
|
||||
ASSERT(worker_thread_ == rtc::Thread::Current());
|
||||
|
||||
const auto& found = options_.find(opt);
|
||||
if (found == options_.end()) {
|
||||
return false;
|
||||
}
|
||||
*value = found->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send data to the other side, using our best connection.
|
||||
int P2PTransportChannel::SendPacket(const char *data, size_t len,
|
||||
const rtc::PacketOptions& options,
|
||||
|
||||
@@ -79,6 +79,7 @@ class P2PTransportChannel : public TransportChannelImpl,
|
||||
virtual int SendPacket(const char *data, size_t len,
|
||||
const rtc::PacketOptions& options, int flags);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int GetError() { return error_; }
|
||||
virtual bool GetStats(std::vector<ConnectionInfo>* stats);
|
||||
|
||||
|
||||
@@ -72,6 +72,10 @@ int RawTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
|
||||
return port_->SetOption(opt, value);
|
||||
}
|
||||
|
||||
bool RawTransportChannel::GetOption(rtc::Socket::Option opt, int* value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int RawTransportChannel::GetError() {
|
||||
return (port_ != NULL) ? port_->GetError() : 0;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class RawTransportChannel : public TransportChannelImpl,
|
||||
virtual int SendPacket(const char *data, size_t len,
|
||||
const rtc::PacketOptions& options, int flags);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int GetError();
|
||||
|
||||
// Implements TransportChannelImpl.
|
||||
|
||||
@@ -787,8 +787,11 @@ void BaseSession::OnTransportCandidatesAllocationDone(Transport* transport) {
|
||||
bool BaseSession::IsCandidateAllocationDone() const {
|
||||
for (TransportMap::const_iterator iter = transports_.begin();
|
||||
iter != transports_.end(); ++iter) {
|
||||
if (!iter->second->candidates_allocated())
|
||||
if (!iter->second->candidates_allocated()) {
|
||||
LOG(LS_INFO) << "Candidate allocation not done for "
|
||||
<< iter->second->content_name();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -415,6 +415,8 @@ class BaseSession : public sigslot::has_slots<>,
|
||||
virtual void OnMessage(rtc::Message *pmsg);
|
||||
|
||||
protected:
|
||||
bool IsCandidateAllocationDone() const;
|
||||
|
||||
State state_;
|
||||
Error error_;
|
||||
std::string error_desc_;
|
||||
@@ -428,7 +430,6 @@ class BaseSession : public sigslot::has_slots<>,
|
||||
const SessionDescription* sdesc, ContentAction action,
|
||||
std::string* error_desc);
|
||||
|
||||
bool IsCandidateAllocationDone() const;
|
||||
void MaybeCandidateAllocationDone();
|
||||
|
||||
// This method will delete the Transport and TransportChannelImpls and
|
||||
|
||||
@@ -81,6 +81,7 @@ class TransportChannel : public sigslot::has_slots<> {
|
||||
// Sets a socket option on this channel. Note that not all options are
|
||||
// supported by all transport types.
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value) = 0;
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value) = 0;
|
||||
|
||||
// Returns the most recent error that occurred on this channel.
|
||||
virtual int GetError() = 0;
|
||||
|
||||
@@ -104,6 +104,21 @@ int TransportChannelProxy::SetOption(rtc::Socket::Option opt, int value) {
|
||||
return impl_->SetOption(opt, value);
|
||||
}
|
||||
|
||||
bool TransportChannelProxy::GetOption(rtc::Socket::Option opt, int* value) {
|
||||
ASSERT(rtc::Thread::Current() == worker_thread_);
|
||||
if (impl_) {
|
||||
return impl_->GetOption(opt, value);
|
||||
}
|
||||
|
||||
for (const auto& pending : pending_options_) {
|
||||
if (pending.first == opt) {
|
||||
*value = pending.second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int TransportChannelProxy::GetError() {
|
||||
ASSERT(rtc::Thread::Current() == worker_thread_);
|
||||
if (!impl_) {
|
||||
|
||||
@@ -52,6 +52,7 @@ class TransportChannelProxy : public TransportChannel,
|
||||
const rtc::PacketOptions& options,
|
||||
int flags);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual bool GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int GetError();
|
||||
virtual IceRole GetIceRole() const;
|
||||
virtual bool GetStats(ConnectionInfos* infos);
|
||||
|
||||
Reference in New Issue
Block a user