Index: webrtc/p2p/client/basicportallocator.h |
diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h |
index fd189c14e9b32b3ce8e416348cd5c6eaecc0b06e..e8d635de35fccd0a944d4c94d588a59f07bb5a7b 100644 |
--- a/webrtc/p2p/client/basicportallocator.h |
+++ b/webrtc/p2p/client/basicportallocator.h |
@@ -88,6 +88,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
rtc::Thread* network_thread() { return network_thread_; } |
rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
+ void SetCandidateFilter(uint32_t filter) override; |
void StartGettingPorts() override; |
void StopGettingPorts() override; |
void ClearGettingPorts() override; |
@@ -113,36 +114,41 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
private: |
class PortData { |
public: |
- PortData() : port_(NULL), sequence_(NULL), state_(STATE_INIT) {} |
+ PortData() {} |
PortData(Port* port, AllocationSequence* seq) |
- : port_(port), sequence_(seq), state_(STATE_INIT) { |
- } |
+ : port_(port), sequence_(seq) {} |
Port* port() const { return port_; } |
AllocationSequence* sequence() const { return sequence_; } |
- bool ready() const { return state_ == STATE_READY; } |
+ bool ready() const { return ready_; } |
bool complete() const { return state_ == STATE_COMPLETE; } |
bool error() const { return state_ == STATE_ERROR; } |
- void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; } |
+ void set_ready(bool ready) { |
+ if (ready) { |
+ ASSERT(state_ == STATE_INPROGRESS); |
+ } |
+ ready_ = ready; |
+ } |
void set_complete() { |
state_ = STATE_COMPLETE; |
} |
void set_error() { |
- ASSERT(state_ == STATE_INIT || state_ == STATE_READY); |
+ ASSERT(state_ == STATE_INPROGRESS); |
state_ = STATE_ERROR; |
} |
private: |
enum State { |
- STATE_INIT, // No candidates allocated yet. |
- STATE_READY, // At least one candidate is ready for process. |
- STATE_COMPLETE, // All candidates allocated and ready for process. |
- STATE_ERROR // Error in gathering candidates. |
+ STATE_INPROGRESS, // Still gathering candidates. |
+ STATE_COMPLETE, // All candidates allocated and ready for process. |
+ STATE_ERROR // Error in gathering candidates. |
}; |
- Port* port_; |
- AllocationSequence* sequence_; |
- State state_; |
+ Port* port_ = nullptr; |
+ AllocationSequence* sequence_ = nullptr; |
+ State state_ = STATE_INPROGRESS; |
+ // True if a pairable candidate has been gathered. |
+ bool ready_ = false; |
pthatcher1
2016/05/20 01:23:54
I think it would be more clear to call this has_pa
Taylor Brandstetter
2016/05/20 21:03:37
Done.
|
}; |
void OnConfigReady(PortConfiguration* config); |
@@ -169,6 +175,10 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
void GetNetworks(std::vector<rtc::Network*>* networks); |
bool CheckCandidateFilter(const Candidate& c) const; |
+ bool CandidatePairable(const Candidate& c, const Port* port) const; |
+ // Clear the related address according to the flags and candidate filter |
+ // in order to avoid leaking any information. |
+ Candidate SanitizeRelatedAddress(const Candidate& c) const; |
BasicPortAllocator* allocator_; |
rtc::Thread* network_thread_; |
@@ -181,6 +191,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
std::vector<PortConfiguration*> configs_; |
std::vector<AllocationSequence*> sequences_; |
std::vector<PortData> ports_; |
+ uint32_t candidate_filter_ = CF_ALL; |
friend class AllocationSequence; |
}; |