Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 void Resume() override; | 204 void Resume() override; |
| 205 void ContextDestroyed(ExecutionContext*) override; | 205 void ContextDestroyed(ExecutionContext*) override; |
| 206 | 206 |
| 207 // ScriptWrappable | 207 // ScriptWrappable |
| 208 // We keep the this object alive until either stopped or closed. | 208 // We keep the this object alive until either stopped or closed. |
| 209 bool HasPendingActivity() const final { return !closed_ && !stopped_; } | 209 bool HasPendingActivity() const final { return !closed_ && !stopped_; } |
| 210 | 210 |
| 211 DECLARE_VIRTUAL_TRACE(); | 211 DECLARE_VIRTUAL_TRACE(); |
| 212 | 212 |
| 213 private: | 213 private: |
| 214 friend class RTCPeerConnectionTest; | 214 friend class RTCPeerConnectionTest; |
|
Guido Urdaneta
2017/06/20 11:32:16
Maybe I missed this on another review, but can you
Guido Urdaneta
2017/06/20 11:47:42
Note that you don't have to fix this (if there is
hbos_chromium
2017/06/20 12:05:49
Done: https://codereview.chromium.org/2944323002/
| |
| 215 | 215 |
| 216 typedef Function<bool()> BoolFunction; | 216 typedef Function<bool()> BoolFunction; |
| 217 class EventWrapper : public GarbageCollectedFinalized<EventWrapper> { | 217 class EventWrapper : public GarbageCollectedFinalized<EventWrapper> { |
| 218 public: | 218 public: |
| 219 EventWrapper(Event*, std::unique_ptr<BoolFunction>); | 219 EventWrapper(Event*, std::unique_ptr<BoolFunction>); |
| 220 // Returns true if |m_setupFunction| returns true or it is null. | 220 // Returns true if |m_setupFunction| returns true or it is null. |
| 221 // |m_event| will only be fired if setup() returns true; | 221 // |m_event| will only be fired if setup() returns true; |
| 222 bool Setup(); | 222 bool Setup(); |
| 223 | 223 |
| 224 DECLARE_TRACE(); | 224 DECLARE_TRACE(); |
| 225 | 225 |
| 226 Member<Event> event_; | 226 Member<Event> event_; |
| 227 | 227 |
| 228 private: | 228 private: |
| 229 std::unique_ptr<BoolFunction> setup_function_; | 229 std::unique_ptr<BoolFunction> setup_function_; |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 RTCPeerConnection(ExecutionContext*, | 232 RTCPeerConnection(ExecutionContext*, |
| 233 const WebRTCConfiguration&, | 233 const WebRTCConfiguration&, |
| 234 WebMediaConstraints, | 234 WebMediaConstraints, |
| 235 ExceptionState&); | 235 ExceptionState&); |
| 236 void Dispose(); | 236 void Dispose(); |
| 237 | 237 |
| 238 void ScheduleDispatchEvent(Event*); | 238 void ScheduleDispatchEvent(Event*); |
| 239 void ScheduleDispatchEvent(Event*, std::unique_ptr<BoolFunction>); | 239 void ScheduleDispatchEvent(Event*, std::unique_ptr<BoolFunction>); |
| 240 void DispatchScheduledEvent(); | 240 void DispatchScheduledEvent(); |
| 241 MediaStreamTrack* GetTrack(const WebMediaStreamTrack& web_track) const; | 241 MediaStreamTrack* GetTrack(const WebMediaStreamTrack& web_track) const; |
| 242 // Senders and receivers returned by the handler are in use by the peer | |
| 243 // connection, a sender or receiver that is no longer in use is permanently | |
| 244 // inactive and does not need to be referenced anymore. These methods removes | |
| 245 // such senders/receivers from |rtp_senders_|/|rtp_receivers_|. | |
| 246 void RemoveInactiveSenders(); | |
| 247 void RemoveInactiveReceivers(); | |
| 248 | 242 |
| 249 void ChangeSignalingState(WebRTCPeerConnectionHandlerClient::SignalingState); | 243 void ChangeSignalingState(WebRTCPeerConnectionHandlerClient::SignalingState); |
| 250 void ChangeIceGatheringState( | 244 void ChangeIceGatheringState( |
| 251 WebRTCPeerConnectionHandlerClient::ICEGatheringState); | 245 WebRTCPeerConnectionHandlerClient::ICEGatheringState); |
| 252 // Changes the state immediately; does not fire an event. | 246 // Changes the state immediately; does not fire an event. |
| 253 // Returns true if the state was changed. | 247 // Returns true if the state was changed. |
| 254 bool SetIceConnectionState( | 248 bool SetIceConnectionState( |
| 255 WebRTCPeerConnectionHandlerClient::ICEConnectionState); | 249 WebRTCPeerConnectionHandlerClient::ICEConnectionState); |
| 256 // Changes the state asynchronously and fires an event immediately after | 250 // Changes the state asynchronously and fires an event immediately after |
| 257 // changing the state. | 251 // changing the state. |
| 258 void ChangeIceConnectionState( | 252 void ChangeIceConnectionState( |
| 259 WebRTCPeerConnectionHandlerClient::ICEConnectionState); | 253 WebRTCPeerConnectionHandlerClient::ICEConnectionState); |
| 260 | 254 |
| 261 void CloseInternal(); | 255 void CloseInternal(); |
| 262 | 256 |
| 263 void RecordRapporMetrics(); | 257 void RecordRapporMetrics(); |
| 264 | 258 |
| 265 SignalingState signaling_state_; | 259 SignalingState signaling_state_; |
| 266 ICEGatheringState ice_gathering_state_; | 260 ICEGatheringState ice_gathering_state_; |
| 267 ICEConnectionState ice_connection_state_; | 261 ICEConnectionState ice_connection_state_; |
| 268 | 262 |
| 269 MediaStreamVector local_streams_; | 263 MediaStreamVector local_streams_; |
| 270 MediaStreamVector remote_streams_; | 264 MediaStreamVector remote_streams_; |
| 271 // A map containing any track that is in use by the peer connection. This | 265 // A map containing any track that is in use by the peer connection. This |
| 272 // includes tracks of |local_streams_|, |remote_streams_|, |rtp_senders_| and | 266 // includes tracks of |local_streams_|, |remote_streams_|, |rtp_senders_| and |
| 273 // |rtp_receivers_|. | 267 // |rtp_receivers_|. |
| 274 HeapHashMap<WeakMember<MediaStreamComponent>, WeakMember<MediaStreamTrack>> | 268 HeapHashMap<WeakMember<MediaStreamComponent>, WeakMember<MediaStreamTrack>> |
| 275 tracks_; | 269 tracks_; |
| 276 HeapHashMap<uintptr_t, Member<RTCRtpSender>> rtp_senders_; | 270 HeapHashMap<uintptr_t, WeakMember<RTCRtpSender>> rtp_senders_; |
| 277 HeapHashMap<uintptr_t, Member<RTCRtpReceiver>> rtp_receivers_; | 271 HeapHashMap<uintptr_t, WeakMember<RTCRtpReceiver>> rtp_receivers_; |
| 278 | 272 |
| 279 std::unique_ptr<WebRTCPeerConnectionHandler> peer_handler_; | 273 std::unique_ptr<WebRTCPeerConnectionHandler> peer_handler_; |
| 280 | 274 |
| 281 Member<AsyncMethodRunner<RTCPeerConnection>> dispatch_scheduled_event_runner_; | 275 Member<AsyncMethodRunner<RTCPeerConnection>> dispatch_scheduled_event_runner_; |
| 282 HeapVector<Member<EventWrapper>> scheduled_events_; | 276 HeapVector<Member<EventWrapper>> scheduled_events_; |
| 283 | 277 |
| 284 // This handle notifies scheduler about an active connection associated | 278 // This handle notifies scheduler about an active connection associated |
| 285 // with a frame. Handle should be destroyed when connection is closed. | 279 // with a frame. Handle should be destroyed when connection is closed. |
| 286 std::unique_ptr<WebFrameScheduler::ActiveConnectionHandle> | 280 std::unique_ptr<WebFrameScheduler::ActiveConnectionHandle> |
| 287 connection_handle_for_scheduler_; | 281 connection_handle_for_scheduler_; |
| 288 | 282 |
| 289 bool stopped_; | 283 bool stopped_; |
| 290 bool closed_; | 284 bool closed_; |
| 291 | 285 |
| 292 bool has_data_channels_; // For RAPPOR metrics | 286 bool has_data_channels_; // For RAPPOR metrics |
| 293 }; | 287 }; |
| 294 | 288 |
| 295 } // namespace blink | 289 } // namespace blink |
| 296 | 290 |
| 297 #endif // RTCPeerConnection_h | 291 #endif // RTCPeerConnection_h |
| OLD | NEW |