Change error handlers for Set*Description to use RTCError

Needed in order to return error codes to Chromium.

Bug: chromium:819629, chromium:589455
Change-Id: Iab22250db62a348eee21c6d8bfc44020a7380586
Reviewed-on: https://webrtc-review.googlesource.com/60522
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22367}
This commit is contained in:
Harald Alvestrand
2018-03-09 15:18:03 +01:00
committed by Commit Bot
parent a5aa68b73f
commit 5081c0cc6d
6 changed files with 78 additions and 29 deletions

View File

@ -27,6 +27,7 @@
#include <vector>
#include "api/optional.h"
#include "api/rtcerror.h"
#include "rtc_base/refcount.h"
namespace cricket {
@ -197,7 +198,19 @@ class CreateSessionDescriptionObserver : public rtc::RefCountInterface {
// TODO(deadbeef): Make this take an std::unique_ptr<> to avoid confusion
// around ownership.
virtual void OnSuccess(SessionDescriptionInterface* desc) = 0;
virtual void OnFailure(const std::string& error) = 0;
// The OnFailure callback takes an RTCError, which consists of an
// error code and a string.
// RTCError is non-copyable, so it must be passed using std::move.
// Earlier versions of the API used a string argument. This version
// is deprecated; in order to let clients remove the old version, it has a
// default implementation. If both versions are unimplemented, the
// result will be a runtime error (stack overflow). This is intentional.
virtual void OnFailure(RTCError error) {
OnFailure(error.message());
}
virtual void OnFailure(const std::string& error) {
OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error)));
}
protected:
~CreateSessionDescriptionObserver() override = default;
@ -207,7 +220,14 @@ class CreateSessionDescriptionObserver : public rtc::RefCountInterface {
class SetSessionDescriptionObserver : public rtc::RefCountInterface {
public:
virtual void OnSuccess() = 0;
virtual void OnFailure(const std::string& error) = 0;
// See description in CreateSessionDescriptionObserver for OnFailure.
virtual void OnFailure(RTCError error) {
std::string message(error.message());
OnFailure(message);
}
virtual void OnFailure(const std::string& error) {
OnFailure(RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error)));
}
protected:
~SetSessionDescriptionObserver() override = default;