Prepare to remove old OnFailure implementations

This removes usage of the old OnFailure methods on CreateSessionDescriptionObserver
and SetSessionDescriptionObserver, so that WebRTC will continue to compile
once all the default implementations are removed.

Bug: chromium:589455
Change-Id: Id67295b3ad0c30d24d79589c2041acdd507a19f3
Reviewed-on: https://webrtc-review.googlesource.com/78480
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23427}
This commit is contained in:
Harald Alvestrand 2018-05-24 10:53:49 +02:00 committed by Commit Bot
parent 26bc6695cd
commit 73771a893f
10 changed files with 49 additions and 41 deletions

View File

@ -53,7 +53,7 @@ class CreateOfferObserver : public webrtc::CreateSessionDescriptionObserver {
rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc);
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
private:
const rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc_;
@ -69,7 +69,7 @@ class SetLocalSessionDescriptionObserver
: public webrtc::SetSessionDescriptionObserver {
public:
void OnSuccess() override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
};
} // namespace
@ -260,8 +260,9 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>());
}
void CreateOfferObserver::OnFailure(const std::string& error) {
RTC_LOG(LS_INFO) << "Failed to create offer: " << error;
void CreateOfferObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Failed to create offer: " << ToString(error.type())
<< ": " << error.message();
}
void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete(
@ -273,8 +274,9 @@ void SetLocalSessionDescriptionObserver::OnSuccess() {
RTC_LOG(LS_INFO) << "Set local description success!";
}
void SetLocalSessionDescriptionObserver::OnFailure(const std::string& error) {
RTC_LOG(LS_INFO) << "Set local description failure: " << error;
void SetLocalSessionDescriptionObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Set local description failure: "
<< ToString(error.type()) << ": " << error.message();
}
static jlong JNI_CallClient_CreateClient(

View File

@ -36,7 +36,7 @@ class CreateOfferObserver : public webrtc::CreateSessionDescriptionObserver {
explicit CreateOfferObserver(rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc);
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
private:
const rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc_;
@ -50,7 +50,7 @@ class SetRemoteSessionDescriptionObserver : public webrtc::SetRemoteDescriptionO
class SetLocalSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver {
public:
void OnSuccess() override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
};
} // namespace
@ -218,8 +218,8 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>());
}
void CreateOfferObserver::OnFailure(const std::string& error) {
RTC_LOG(LS_INFO) << "Failed to create offer: " << error;
void CreateOfferObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Failed to create offer: " << error.message();
}
void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete(webrtc::RTCError error) {
@ -230,8 +230,8 @@ void SetLocalSessionDescriptionObserver::OnSuccess() {
RTC_LOG(LS_INFO) << "Set local description success!";
}
void SetLocalSessionDescriptionObserver::OnFailure(const std::string& error) {
RTC_LOG(LS_INFO) << "Set local description failure: " << error;
void SetLocalSessionDescriptionObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Set local description failure: " << error.message();
}
} // namespace webrtc_examples

View File

@ -45,8 +45,9 @@ class DummySetSessionDescriptionObserver
new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
}
virtual void OnSuccess() { RTC_LOG(INFO) << __FUNCTION__; }
virtual void OnFailure(const std::string& error) {
RTC_LOG(INFO) << __FUNCTION__ << " " << error;
virtual void OnFailure(webrtc::RTCError error) {
RTC_LOG(INFO) << __FUNCTION__ << " " << ToString(error.type()) << ": "
<< error.message();
}
};
@ -545,8 +546,8 @@ void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
SendMessage(writer.write(jmessage));
}
void Conductor::OnFailure(const std::string& error) {
RTC_LOG(LERROR) << error;
void Conductor::OnFailure(webrtc::RTCError error) {
RTC_LOG(LERROR) << ToString(error.type()) << ": " << error.message();
}
void Conductor::SendMessage(const std::string& json_object) {

View File

@ -116,7 +116,7 @@ class Conductor
// CreateSessionDescriptionObserver implementation.
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
protected:
// Send a message to the remote peer.

View File

@ -76,8 +76,9 @@ class DummySetSessionDescriptionObserver
return new rtc::RefCountedObject<DummySetSessionDescriptionObserver>();
}
virtual void OnSuccess() { RTC_LOG(INFO) << __FUNCTION__; }
virtual void OnFailure(const std::string& error) {
RTC_LOG(INFO) << __FUNCTION__ << " " << error;
virtual void OnFailure(webrtc::RTCError error) {
RTC_LOG(INFO) << __FUNCTION__ << " " << ToString(error.type()) << ": "
<< error.message();
}
protected:
@ -240,11 +241,12 @@ void SimplePeerConnection::OnSuccess(
OnLocalSdpReady(desc->type().c_str(), sdp.c_str());
}
void SimplePeerConnection::OnFailure(const std::string& error) {
RTC_LOG(LERROR) << error;
void SimplePeerConnection::OnFailure(webrtc::RTCError error) {
RTC_LOG(LERROR) << ToString(error.type()) << ": " << error.message();
// TODO(hta): include error.type in the message
if (OnFailureMessage)
OnFailureMessage(error.c_str());
OnFailureMessage(error.message());
}
void SimplePeerConnection::OnIceCandidate(

View File

@ -88,7 +88,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver,
// CreateSessionDescriptionObserver implementation.
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(const std::string& error) override;
void OnFailure(webrtc::RTCError error) override;
// DataChannelObserver implementation.
void OnStateChange() override;

View File

@ -67,12 +67,12 @@ enum {
struct CreateSessionDescriptionMsg : public rtc::MessageData {
explicit CreateSessionDescriptionMsg(
webrtc::CreateSessionDescriptionObserver* observer)
: observer(observer) {
}
webrtc::CreateSessionDescriptionObserver* observer,
RTCError error_in)
: observer(observer), error(std::move(error_in)) {}
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserver> observer;
std::string error;
RTCError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> description;
};
} // namespace
@ -297,7 +297,7 @@ void WebRtcSessionDescriptionFactory::OnMessage(rtc::Message* msg) {
case MSG_CREATE_SESSIONDESCRIPTION_FAILED: {
CreateSessionDescriptionMsg* param =
static_cast<CreateSessionDescriptionMsg*>(msg->pdata);
param->observer->OnFailure(param->error);
param->observer->OnFailure(std::move(param->error));
delete param;
break;
}
@ -432,8 +432,8 @@ void WebRtcSessionDescriptionFactory::FailPendingRequests(
void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionFailed(
CreateSessionDescriptionObserver* observer, const std::string& error) {
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
msg->error = error;
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(
observer, RTCError(RTCErrorType::INTERNAL_ERROR, std::string(error)));
signaling_thread_->Post(RTC_FROM_HERE, this,
MSG_CREATE_SESSIONDESCRIPTION_FAILED, msg);
RTC_LOG(LS_ERROR) << "Create SDP failed: " << error;
@ -442,7 +442,8 @@ void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionFailed(
void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionSucceeded(
CreateSessionDescriptionObserver* observer,
std::unique_ptr<SessionDescriptionInterface> description) {
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
CreateSessionDescriptionMsg* msg =
new CreateSessionDescriptionMsg(observer, RTCError::OK());
msg->description = std::move(description);
signaling_thread_->Post(RTC_FROM_HERE, this,
MSG_CREATE_SESSIONDESCRIPTION_SUCCESS, msg);

View File

@ -36,10 +36,10 @@ void CreateSdpObserverJni::OnSuccess(SessionDescriptionInterface* desc) {
delete desc;
}
void CreateSdpObserverJni::OnFailure(const std::string& error) {
void CreateSdpObserverJni::OnFailure(webrtc::RTCError error) {
JNIEnv* env = AttachCurrentThreadIfNeeded();
Java_SdpObserver_onCreateFailure(env, j_observer_global_,
NativeToJavaString(env, error));
NativeToJavaString(env, error.message()));
}
SetSdpObserverJni::SetSdpObserverJni(
@ -54,10 +54,10 @@ void SetSdpObserverJni::OnSuccess() {
Java_SdpObserver_onSetSuccess(env, j_observer_global_);
}
void SetSdpObserverJni::OnFailure(const std::string& error) {
void SetSdpObserverJni::OnFailure(webrtc::RTCError error) {
JNIEnv* env = AttachCurrentThreadIfNeeded();
Java_SdpObserver_onSetFailure(env, j_observer_global_,
NativeToJavaString(env, error));
NativeToJavaString(env, error.message()));
}
} // namespace jni

View File

@ -30,7 +30,7 @@ class CreateSdpObserverJni : public CreateSessionDescriptionObserver {
MediaConstraintsInterface* constraints() { return constraints_.get(); }
void OnSuccess(SessionDescriptionInterface* desc) override;
void OnFailure(const std::string& error) override;
void OnFailure(RTCError error) override;
private:
const ScopedJavaGlobalRef<jobject> j_observer_global_;
@ -46,7 +46,7 @@ class SetSdpObserverJni : public SetSessionDescriptionObserver {
MediaConstraintsInterface* constraints() { return constraints_.get(); }
void OnSuccess() override;
void OnFailure(const std::string& error) override;
void OnFailure(RTCError error) override;
private:
const ScopedJavaGlobalRef<jobject> j_observer_global_;

View File

@ -61,9 +61,10 @@ class CreateSessionDescriptionObserverAdapter
completion_handler_ = nil;
}
void OnFailure(const std::string& error) override {
void OnFailure(RTCError error) override {
RTC_DCHECK(completion_handler_);
NSString* str = [NSString stringForStdString:error];
// TODO(hta): Add handling of error.type()
NSString *str = [NSString stringForStdString:error.message()];
NSError* err =
[NSError errorWithDomain:kRTCPeerConnectionErrorDomain
code:kRTCPeerConnnectionSessionDescriptionError
@ -95,9 +96,10 @@ class SetSessionDescriptionObserverAdapter :
completion_handler_ = nil;
}
void OnFailure(const std::string& error) override {
void OnFailure(RTCError error) override {
RTC_DCHECK(completion_handler_);
NSString* str = [NSString stringForStdString:error];
// TODO(hta): Add handling of error.type()
NSString *str = [NSString stringForStdString:error.message()];
NSError* err =
[NSError errorWithDomain:kRTCPeerConnectionErrorDomain
code:kRTCPeerConnnectionSessionDescriptionError