Return an error when datachannel closes due to network error
This is the start of generating compliant errors, including diagnostics,
when datachannels close because of errors.
Bug: chromium:1030631
Change-Id: I39aa41728efb25bca6193a782db4cbdaad8e0dc1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161304
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30034}
diff --git a/api/data_channel_interface.h b/api/data_channel_interface.h
index ccf3ad7..e08830f 100644
--- a/api/data_channel_interface.h
+++ b/api/data_channel_interface.h
@@ -20,6 +20,7 @@
#include <string>
#include "absl/types/optional.h"
+#include "api/rtc_error.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/ref_count.h"
@@ -154,6 +155,10 @@
// determined, and until then this will return -1.
virtual int id() const = 0;
virtual DataState state() const = 0;
+ // When state is kClosed, and the DataChannel was not closed using
+ // the closing procedure, returns the error information about the closing.
+ // The default implementation returns "no error".
+ virtual RTCError error() const { return RTCError(); }
virtual uint32_t messages_sent() const = 0;
virtual uint64_t bytes_sent() const = 0;
virtual uint32_t messages_received() const = 0;