Index: content/browser/media/webrtc/webrtc_eventlog_callback_handler.h |
diff --git a/content/browser/media/webrtc/webrtc_eventlog_callback_handler.h b/content/browser/media/webrtc/webrtc_eventlog_callback_handler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..89ef454f968950aee4d77f4f2479575e5281615b |
--- /dev/null |
+++ b/content/browser/media/webrtc/webrtc_eventlog_callback_handler.h |
@@ -0,0 +1,58 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |
+#define CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |
+ |
+#include <vector> |
+ |
+#include "base/callback.h" |
+#include "base/files/file_path.h" |
+#include "base/optional.h" |
+ |
+namespace content { |
+ |
+// This is a singleton class that is used to register callbacks that are used |
+// for the WebRTC event log. The callbacks are used to signal when the eventlog |
+// should be started and stopped, and other callbacks are used to signal when |
+// PeerConnections are added or removed. |
+class WebRTCEventLogCallbackHandler { |
+ public: |
+ WebRTCEventLogCallbackHandler(); |
+ ~WebRTCEventLogCallbackHandler(); |
+ |
+ // Register functions to handle starting and stopping the WebRTC event log |
+ // functionality from the chrome://webrtc-internals page. Only one handler can |
+ // be registered per render process. |
+ using EventLogStartFunc = base::Callback<void(const base::FilePath&)>; |
+ using EventLogStopFunc = base::Callback<void()>; |
+ void RegisterEventLogHandler(const EventLogStartFunc& start_logging_callback, |
+ const EventLogStopFunc& stop_logging_callback); |
+ |
+ // Register callback functions to receive calls when PeerConnections are |
+ // added or removed. Multiple callbacks can be registered for each render |
+ // process. |
+ using PeerConnectionAddedFunc = base::Callback<void(int)>; |
+ using PeerConnectionRemovedFunc = base::Callback<void(int)>; |
+ void RegisterPeerConnectionCallbacks( |
+ const PeerConnectionAddedFunc& pc_added_callback, |
+ const PeerConnectionRemovedFunc& pc_removed_callback); |
+ |
+ void StartEventLog(const base::FilePath& file_path); |
+ void StopEventLog(); |
+ |
+ void PeerConnectionAdded(int connection_id); |
+ void PeerConnectionRemoved(int connection_id); |
+ |
+ private: |
+ base::Optional<EventLogStartFunc> eventlog_start_fn_; |
+ base::Optional<EventLogStopFunc> eventlog_stop_fn_; |
+ |
+ std::vector<PeerConnectionAddedFunc> peerconnection_added_fn_; |
+ std::vector<PeerConnectionRemovedFunc> peerconnection_removed_fn_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEDIA_WEBRTC_WEBRTC_EVENTLOG_CALLBACK_HANDLER_H_ |