Index: content/browser/media/dtls_identity_store.h |
diff --git a/content/browser/media/dtls_identity_store.h b/content/browser/media/dtls_identity_store.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5ec4052f45bf8ae0117935bbe344960c25b30b1f |
--- /dev/null |
+++ b/content/browser/media/dtls_identity_store.h |
@@ -0,0 +1,88 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_MEDIA_DTLS_IDENTITY_STORE_H_ |
+#define CONTENT_BROWSER_MEDIA_DTLS_IDENTITY_STORE_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/threading/non_thread_safe.h" |
+ |
+class GURL; |
+ |
+namespace base { |
+class TaskRunner; |
+} // namespace base |
+ |
+namespace content { |
+ |
+class DTLSIdentityRequest; |
+ |
+class DTLSIdentityStore { |
jam
2013/06/14 23:33:13
nit: comment this class
jiayl
2013/06/17 17:54:49
Done.
|
+ public: |
+ typedef base::Callback<void(int error, |
+ const std::string& certificate, |
+ const std::string& private_key)> |
+ CompletionCallback; |
+ |
+ class RequestHandle { |
jam
2013/06/14 23:33:13
do you really need to expose this in the header? w
jiayl
2013/06/17 17:54:49
Done. Now the caller get a Callback returned to ca
|
+ public: |
+ RequestHandle(); |
+ virtual ~RequestHandle(); |
+ |
+ // Cancel the request. Does nothing if the request finished or was already |
+ // cancelled. |
+ void Cancel(); |
+ |
+ private: |
+ friend DTLSIdentityStore; |
+ |
+ void RequestStarted(DTLSIdentityStore* store, |
+ DTLSIdentityRequest* request, |
+ const CompletionCallback& callback); |
+ |
+ void OnRequestComplete(int error, |
+ const std::string& certificate, |
+ const std::string& private_key); |
+ |
+ DTLSIdentityStore* store_; |
+ DTLSIdentityRequest* request_; |
+ CompletionCallback callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RequestHandle); |
+ }; |
+ |
+ DTLSIdentityStore(); |
+ virtual ~DTLSIdentityStore(); |
+ |
+ // Retrieve the DTLS identity for the given origin, or generate a new one |
+ // if not existent. Asynchronous. |
+ // |origin| is the origin of the PeerConnection requesting the identity; |
+ // |identity_name| is used to identify an identity within an origin; |
+ // |common_name| is the common name used to generate the certificate; |
+ // |callback| is the callback to return the result. |
+ void RequestIdentity(const GURL& origin, |
+ const std::string& identity_name, |
+ const std::string& common_name, |
+ const CompletionCallback& callback, |
+ RequestHandle* out_request); |
+ |
+ protected: |
+ explicit DTLSIdentityStore( |
+ const scoped_refptr<base::TaskRunner>& task_runner); |
+ |
+ private: |
+ friend class base::RefCounted<DTLSIdentityStore>; |
jam
2013/06/14 23:33:13
nit: not needed
jiayl
2013/06/17 17:54:49
Done.
|
+ |
+ void CancelRequest(DTLSIdentityRequest* request); |
+ |
+ // The TaskRunner for doing work on a worker thread. |
+ scoped_refptr<base::TaskRunner> task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DTLSIdentityStore); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEDIA_DTLS_IDENTITY_STORE_H_ |