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}
diff --git a/talk/app/webrtc/dtlsidentitystore.h b/talk/app/webrtc/dtlsidentitystore.h
index b2a7974..b655a7d 100644
--- a/talk/app/webrtc/dtlsidentitystore.h
+++ b/talk/app/webrtc/dtlsidentitystore.h
@@ -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
diff --git a/talk/app/webrtc/peerconnectioninterface.h b/talk/app/webrtc/peerconnectioninterface.h
index ce32b50..946b125 100644
--- a/talk/app/webrtc/peerconnectioninterface.h
+++ b/talk/app/webrtc/peerconnectioninterface.h
@@ -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 @@
   ~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 @@
 
   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(
diff --git a/webrtc/base/sslidentity.h b/webrtc/base/sslidentity.h
index 320fe53..ca1aa11 100644
--- a/webrtc/base/sslidentity.h
+++ b/webrtc/base/sslidentity.h
@@ -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;