OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "base/optional.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // This is a singleton class that is used to register callbacks that are used |
| 17 // for the WebRTC event log. The callbacks are used to signal when the eventlog |
| 18 // should be started and stopped, and other callbacks are used to signal when |
| 19 // PeerConnections are added or removed. |
| 20 class WebRTCEventLogCallbackHandler { |
| 21 public: |
| 22 WebRTCEventLogCallbackHandler(); |
| 23 ~WebRTCEventLogCallbackHandler(); |
| 24 |
| 25 // Register functions to handle starting and stopping the WebRTC event log |
| 26 // functionality from the chrome://webrtc-internals page. Only one handler can |
| 27 // be registered per render process. |
| 28 using EventLogStartFunc = base::Callback<void(const base::FilePath&)>; |
| 29 using EventLogStopFunc = base::Callback<void()>; |
| 30 void RegisterEventLogHandler(const EventLogStartFunc& start_logging_callback, |
| 31 const EventLogStopFunc& stop_logging_callback); |
| 32 |
| 33 // Register callback functions to receive calls when PeerConnections are |
| 34 // added or removed. Multiple callbacks can be registered for each render |
| 35 // process. |
| 36 using PeerConnectionAddedFunc = base::Callback<void(int)>; |
| 37 using PeerConnectionRemovedFunc = base::Callback<void(int)>; |
| 38 void RegisterPeerConnectionCallbacks( |
| 39 const PeerConnectionAddedFunc& pc_added_callback, |
| 40 const PeerConnectionRemovedFunc& pc_removed_callback); |
| 41 |
| 42 void StartEventLog(const base::FilePath& file_path); |
| 43 void StopEventLog(); |
| 44 |
| 45 void PeerConnectionAdded(int connection_id); |
| 46 void PeerConnectionRemoved(int connection_id); |
| 47 |
| 48 private: |
| 49 base::Optional<EventLogStartFunc> eventlog_start_fn_; |
| 50 base::Optional<EventLogStopFunc> eventlog_stop_fn_; |
| 51 |
| 52 std::vector<PeerConnectionAddedFunc> peerconnection_added_fn_; |
| 53 std::vector<PeerConnectionRemovedFunc> peerconnection_removed_fn_; |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |
OLD | NEW |