DtlsIdentityStoreInterface added.

New PeerConnectionFactoryInterface::CreatePeerConnection taking both service and store added (old CreatePC signature still exists).

This is CL is part of an effort to land https://codereview.webrtc.org/1176383004 without breaking Chromium.
See bug for more information.

BUG=webrtc:4899
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1268363002 .

Cr-Commit-Position: refs/heads/master@{#9680}
This commit is contained in:
Henrik Boström 2015-08-05 16:55:22 +02:00
parent 0c0226408d
commit 5b4ce3391d
3 changed files with 66 additions and 18 deletions

View File

@ -31,17 +31,64 @@
#include <queue>
#include <string>
#include "talk/app/webrtc/peerconnectioninterface.h"
#include "webrtc/base/messagehandler.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/refcount.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/sslidentity.h"
#include "webrtc/base/thread.h"
namespace webrtc {
class DTLSIdentityRequestObserver;
class SSLIdentity;
class Thread;
// Used to receive callbacks of DTLS identity requests.
class DTLSIdentityRequestObserver : public rtc::RefCountInterface {
public:
virtual void OnFailure(int error) = 0;
// TODO(jiayl): Unify the OnSuccess method once Chrome code is updated.
virtual void OnSuccess(const std::string& der_cert,
const std::string& der_private_key) = 0;
// |identity| is a scoped_ptr because rtc::SSLIdentity is not copyable and the
// client has to get the ownership of the object to make use of it.
virtual void OnSuccessWithIdentityObj(
rtc::scoped_ptr<rtc::SSLIdentity> identity) = 0;
protected:
virtual ~DTLSIdentityRequestObserver() {}
};
// TODO(hbos): To replace DTLSIdentityRequestObserver.
// Used to receive callbacks of DTLS identity requests.
class DtlsIdentityRequestObserver : public rtc::RefCountInterface {
public:
virtual void OnFailure(int error) = 0;
// TODO(hbos): Unify the OnSuccess method once Chrome code is updated.
virtual void OnSuccess(const std::string& der_cert,
const std::string& der_private_key) = 0;
// |identity| is a scoped_ptr because rtc::SSLIdentity is not copyable and the
// client has to get the ownership of the object to make use of it.
virtual void OnSuccess(rtc::scoped_ptr<rtc::SSLIdentity> identity) = 0;
protected:
virtual ~DtlsIdentityRequestObserver() {}
};
// TODO(hbos): To be implemented.
// This interface defines an in-memory DTLS identity store, which generates DTLS
// identities.
// APIs calls must be made on the signaling thread and the callbacks are also
// called on the signaling thread.
class DtlsIdentityStoreInterface {
public:
virtual ~DtlsIdentityStoreInterface() { }
virtual void RequestIdentity(
rtc::KeyType key_type,
const rtc::scoped_refptr<DtlsIdentityRequestObserver>& observer) = 0;
};
// This class implements an in-memory DTLS identity store, which generates the
// DTLS identity on the worker thread.
// APIs calls must be made on the signaling thread and the callbacks are also

View File

@ -72,6 +72,7 @@
#include <vector>
#include "talk/app/webrtc/datachannelinterface.h"
#include "talk/app/webrtc/dtlsidentitystore.h"
#include "talk/app/webrtc/dtmfsenderinterface.h"
#include "talk/app/webrtc/jsep.h"
#include "talk/app/webrtc/mediastreaminterface.h"
@ -466,22 +467,6 @@ class PortAllocatorFactoryInterface : public rtc::RefCountInterface {
~PortAllocatorFactoryInterface() {}
};
// Used to receive callbacks of DTLS identity requests.
class DTLSIdentityRequestObserver : public rtc::RefCountInterface {
public:
virtual void OnFailure(int error) = 0;
// TODO(jiayl): Unify the OnSuccess method once Chrome code is updated.
virtual void OnSuccess(const std::string& der_cert,
const std::string& der_private_key) = 0;
// |identity| is a scoped_ptr because rtc::SSLIdentity is not copyable and the
// client has to get the ownership of the object to make use of it.
virtual void OnSuccessWithIdentityObj(
rtc::scoped_ptr<rtc::SSLIdentity> identity) = 0;
protected:
virtual ~DTLSIdentityRequestObserver() {}
};
class DTLSIdentityServiceInterface {
public:
// Asynchronously request a DTLS identity, including a self-signed certificate
@ -548,6 +533,20 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
virtual void SetOptions(const Options& options) = 0;
// TODO(hbos): Temporary CreatePeerConnection function while we transition
// from DTLSIdentityServiceInterface to DtlsIdentityStoreInterface.
rtc::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
PeerConnectionObserver* observer) {
return CreatePeerConnection(configuration, constraints, allocator_factory,
dtls_identity_service, observer);
}
// This method takes the ownership of |dtls_identity_service|.
virtual rtc::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(

View File

@ -22,6 +22,8 @@
namespace rtc {
enum KeyType { KT_RSA, KT_ECDSA, KT_LAST, KT_DEFAULT = KT_RSA };
// Forward declaration due to circular dependency with SSLCertificate.
class SSLCertChain;