Chromium Code Reviews| 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..c499e0036ce101ab949c2416611d59176d065039 |
| --- /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 { |
| + |
| +namespace { |
| +class DTLSIdentityRequest; |
| +} // namespace |
|
Ryan Sleevi
2013/06/13 22:36:47
C++ LANGUAGE: You cannot forward declare a type in
jiayl
2013/06/14 00:37:01
Done.
|
| + |
| +class DTLSIdentityStore : public base::RefCounted<DTLSIdentityStore> { |
|
Ryan Sleevi
2013/06/13 22:36:47
DESIGN: Please do not use RefCounting for this cla
jiayl
2013/06/14 00:37:01
Done. StoragePartitionImpl owns it.
|
| + public: |
| + DTLSIdentityStore(); |
|
Ryan Sleevi
2013/06/13 22:36:47
STYLE: Per http://google-styleguide.googlecode.com
jiayl
2013/06/14 00:37:01
Done.
|
| + |
| + typedef base::Callback<void(int error, |
| + const std::string& certificate, |
| + const std::string& private_key)> |
| + CompletionCallback; |
| + |
| + class RequestHandle { |
|
Ryan Sleevi
2013/06/13 22:36:47
DESIGN: This would be better served as an opaque h
jiayl
2013/06/14 00:37:01
Do you mean make RequestHandler::Cancel private an
jam
2013/06/14 23:33:13
yeah, that is much better. this whole class (Reque
jiayl
2013/06/17 17:54:49
Done.
|
| + public: |
| + RequestHandle(); |
| + ~RequestHandle(); |
| + |
| + // Cancel the request. Does nothing if the request finished or was already |
| + // cancelled. |
| + void Cancel(); |
| + |
| + private: |
| + friend class 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_; |
| + }; |
|
Ryan Sleevi
2013/06/13 22:36:47
DISALLOW_COPY_AND_ASSIGN
jiayl
2013/06/14 00:37:01
Done.
|
| + |
| + // 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 identity an identity within an origin; |
|
Ryan Sleevi
2013/06/13 22:36:47
s/identity an/identify an/
jiayl
2013/06/14 00:37:01
Done.
|
| + // |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); |
| + virtual ~DTLSIdentityStore(); |
| + |
| + private: |
| + friend class base::RefCounted<DTLSIdentityStore>; |
| + |
| + 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_ |