Index: content/browser/media/webrtc/webrtc_eventlog_callback_handler.cc |
diff --git a/content/browser/media/webrtc/webrtc_eventlog_callback_handler.cc b/content/browser/media/webrtc/webrtc_eventlog_callback_handler.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1875130fab30528d4dc9e8f1347b3b4ec65854c9 |
--- /dev/null |
+++ b/content/browser/media/webrtc/webrtc_eventlog_callback_handler.cc |
@@ -0,0 +1,52 @@ |
+// 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. |
+ |
+#include "content/browser/media/webrtc/webrtc_eventlog_callback_handler.h" |
+ |
+namespace content { |
+ |
+WebRTCEventLogCallbackHandler::WebRTCEventLogCallbackHandler() {} |
+ |
+WebRTCEventLogCallbackHandler::~WebRTCEventLogCallbackHandler() {} |
+ |
+void WebRTCEventLogCallbackHandler::RegisterEventLogHandler( |
+ const EventLogStartFunc& start_logging_callback, |
+ const EventLogStopFunc& stop_logging_callback) { |
+ eventlog_start_fn_ = start_logging_callback; |
+ eventlog_stop_fn_ = stop_logging_callback; |
+} |
+ |
+void WebRTCEventLogCallbackHandler::RegisterPeerConnectionCallbacks( |
+ const PeerConnectionAddedFunc& pc_added_callback, |
+ const PeerConnectionRemovedFunc& pc_removed_callback) { |
+ peerconnection_added_fn_.push_back(pc_added_callback); |
+ peerconnection_removed_fn_.push_back(pc_removed_callback); |
+} |
+ |
+void WebRTCEventLogCallbackHandler::PeerConnectionAdded(int connection_id) { |
+ for (auto& pc_added : peerconnection_added_fn_) { |
+ pc_added.Run(connection_id); |
+ } |
+} |
+ |
+void WebRTCEventLogCallbackHandler::PeerConnectionRemoved(int connection_id) { |
+ for (auto& pc_removed : peerconnection_removed_fn_) { |
+ pc_removed.Run(connection_id); |
+ } |
+} |
+ |
+void WebRTCEventLogCallbackHandler::StartEventLog( |
+ const base::FilePath& file_path) { |
+ if (eventlog_start_fn_) { |
+ eventlog_start_fn_.value().Run(file_path); |
+ } |
+} |
+ |
+void WebRTCEventLogCallbackHandler::StopEventLog() { |
+ if (eventlog_stop_fn_) { |
+ eventlog_stop_fn_.value().Run(); |
+ } |
+} |
+ |
+} // namespace content |