Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: webrtc/p2p/client/basicportallocator.h

Issue 1241943002: Fix an NPE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Updated the comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/client/basicportallocator.h
diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h
index 96468d32ccafab6eb574909c9a34cfffa9897bc6..1b52cb963095f1ee34c6bfbbddf4b7c972e98ac6 100644
--- a/webrtc/p2p/client/basicportallocator.h
+++ b/webrtc/p2p/client/basicportallocator.h
@@ -236,6 +236,93 @@ struct PortConfiguration : public rtc::MessageData {
RelayType turn_type, ProtocolType type) const;
};
+class UDPPort;
+class TurnPort;
+
+// Performs the allocation of ports, in a sequenced (timed) manner, for a given
+// network and IP address.
+class AllocationSequence : public rtc::MessageHandler,
+ public sigslot::has_slots<> {
+ public:
+ enum State {
+ kInit, // Initial state.
+ kRunning, // Started allocating ports.
+ kStopped, // Stopped from running.
+ kCompleted, // All ports are allocated.
+
+ // kInit --> kRunning --> {kCompleted|kStopped}
+ };
+ AllocationSequence(BasicPortAllocatorSession* session,
+ rtc::Network* network,
+ PortConfiguration* config,
+ uint32 flags);
+ ~AllocationSequence();
+ bool Init();
+ void Clear();
+
+ State state() const { return state_; }
+
+ // Disables the phases for a new sequence that this one already covers for an
+ // equivalent network setup.
+ void DisableEquivalentPhases(rtc::Network* network,
+ PortConfiguration* config,
+ uint32* flags);
+
+ // Starts and stops the sequence. When started, it will continue allocating
+ // new ports on its own timed schedule.
+ void Start();
+ void Stop();
+
+ // MessageHandler
+ void OnMessage(rtc::Message* msg);
+
+ void EnableProtocol(ProtocolType proto);
+ bool ProtocolEnabled(ProtocolType proto) const;
+
+ // Signal from AllocationSequence, when it's done with allocating ports.
+ // This signal is useful, when port allocation fails which doesn't result
+ // in any candidates. Using this signal BasicPortAllocatorSession can send
+ // its candidate discovery conclusion signal. Without this signal,
+ // BasicPortAllocatorSession doesn't have any event to trigger signal. This
+ // can also be achieved by starting timer in BPAS.
+ sigslot::signal1<AllocationSequence*> SignalPortAllocationComplete;
+
+ protected:
+ // For testing.
+ void CreateTurnPort(const RelayServerConfig& config);
+
+ private:
+ typedef std::vector<ProtocolType> ProtocolList;
+
+ bool IsFlagSet(uint32 flag) { return ((flags_ & flag) != 0); }
+ void CreateUDPPorts();
+ void CreateTCPPorts();
+ void CreateStunPorts();
+ void CreateRelayPorts();
+ void CreateGturnPort(const RelayServerConfig& config);
+
+ void OnReadPacket(rtc::AsyncPacketSocket* socket,
+ const char* data,
+ size_t size,
+ const rtc::SocketAddress& remote_addr,
+ const rtc::PacketTime& packet_time);
+
+ void OnPortDestroyed(PortInterface* port);
+
+ BasicPortAllocatorSession* session_;
+ rtc::Network* network_;
+ rtc::IPAddress ip_;
+ PortConfiguration* config_;
+ State state_;
+ uint32 flags_;
+ ProtocolList protocols_;
+ rtc::scoped_ptr<rtc::AsyncPacketSocket> udp_socket_;
+ // There will be only one udp port per AllocationSequence.
+ UDPPort* udp_port_;
+ std::vector<TurnPort*> turn_ports_;
+ int phase_;
+};
+
} // namespace cricket
#endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
« no previous file with comments | « no previous file | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698