| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // requests are queued and have to wait for the outstanding request to complete. | 21 // requests are queued and have to wait for the outstanding request to complete. |
| 22 class CONTENT_EXPORT WebRTCIdentityService : public RenderProcessObserver { | 22 class CONTENT_EXPORT WebRTCIdentityService : public RenderProcessObserver { |
| 23 public: | 23 public: |
| 24 typedef base::Callback< | 24 typedef base::Callback< |
| 25 void(const std::string& certificate, const std::string& private_key)> | 25 void(const std::string& certificate, const std::string& private_key)> |
| 26 SuccessCallback; | 26 SuccessCallback; |
| 27 | 27 |
| 28 typedef base::Callback<void(int error)> FailureCallback; | 28 typedef base::Callback<void(int error)> FailureCallback; |
| 29 | 29 |
| 30 WebRTCIdentityService(); | 30 WebRTCIdentityService(); |
| 31 virtual ~WebRTCIdentityService(); | 31 ~WebRTCIdentityService() override; |
| 32 | 32 |
| 33 // Sends an identity request. | 33 // Sends an identity request. |
| 34 // | 34 // |
| 35 // |origin| is the origin of the caller; | 35 // |origin| is the origin of the caller; |
| 36 // |identity_name| and |common_name| have the same meaning as in | 36 // |identity_name| and |common_name| have the same meaning as in |
| 37 // webrtc::DTLSIdentityServiceInterface::RequestIdentity; | 37 // webrtc::DTLSIdentityServiceInterface::RequestIdentity; |
| 38 // |success_callback| is the callback if the identity is successfully | 38 // |success_callback| is the callback if the identity is successfully |
| 39 // returned; | 39 // returned; |
| 40 // |failure_callback| is the callback if the identity request fails. | 40 // |failure_callback| is the callback if the identity request fails. |
| 41 // | 41 // |
| 42 // The request id is returned. It's unique within the renderer and can be used | 42 // The request id is returned. It's unique within the renderer and can be used |
| 43 // to cancel the request. | 43 // to cancel the request. |
| 44 int RequestIdentity(const GURL& origin, | 44 int RequestIdentity(const GURL& origin, |
| 45 const std::string& identity_name, | 45 const std::string& identity_name, |
| 46 const std::string& common_name, | 46 const std::string& common_name, |
| 47 const SuccessCallback& success_callback, | 47 const SuccessCallback& success_callback, |
| 48 const FailureCallback& failure_callback); | 48 const FailureCallback& failure_callback); |
| 49 | 49 |
| 50 // Cancels a previous request and the callbacks will not be called. | 50 // Cancels a previous request and the callbacks will not be called. |
| 51 // If the |request_id| is not associated with the | 51 // If the |request_id| is not associated with the |
| 52 // outstanding request or any queued request, this method does nothing. | 52 // outstanding request or any queued request, this method does nothing. |
| 53 // | 53 // |
| 54 // |request_id| is the request id returned from RequestIdentity. | 54 // |request_id| is the request id returned from RequestIdentity. |
| 55 void CancelRequest(int request_id); | 55 void CancelRequest(int request_id); |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 // For unittest to override. | 58 // For unittest to override. |
| 59 virtual bool Send(IPC::Message* message); | 59 virtual bool Send(IPC::Message* message); |
| 60 // RenderProcessObserver implementation. Protected for testing. | 60 // RenderProcessObserver implementation. Protected for testing. |
| 61 virtual bool OnControlMessageReceived(const IPC::Message& message) override; | 61 bool OnControlMessageReceived(const IPC::Message& message) override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 struct RequestInfo { | 64 struct RequestInfo { |
| 65 RequestInfo(int request_id, | 65 RequestInfo(int request_id, |
| 66 const GURL& origin, | 66 const GURL& origin, |
| 67 const std::string& identity_name, | 67 const std::string& identity_name, |
| 68 const std::string& common_name, | 68 const std::string& common_name, |
| 69 const SuccessCallback& success_callback, | 69 const SuccessCallback& success_callback, |
| 70 const FailureCallback& failure_callback); | 70 const FailureCallback& failure_callback); |
| 71 ~RequestInfo(); | 71 ~RequestInfo(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 std::deque<RequestInfo> pending_requests_; | 90 std::deque<RequestInfo> pending_requests_; |
| 91 int next_request_id_; | 91 int next_request_id_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityService); | 93 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityService); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace content | 96 } // namespace content |
| 97 | 97 |
| 98 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ | 98 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_IDENTITY_SERVICE_H_ |
| OLD | NEW |