Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: content/browser/renderer_host/media/dtls_identity_service_host.cc

Issue 15969025: Generates the DTLS identity in browser process and returns it to render process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/media/dtls_identity_service_host.h"
6
7 #include "base/bind.h"
8 #include "content/common/media/dtls_identity_messages.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "net/base/net_errors.h"
11
12 namespace content {
13
14 DTLSIdentityServiceHost::DTLSIdentityServiceHost(
15 DTLSIdentityStore* dtls_identity_store)
16 : dtls_identity_store_(dtls_identity_store) {
17 }
18
19 DTLSIdentityServiceHost::~DTLSIdentityServiceHost() {
20 RequestCancellerMap::iterator it;
21 for (it = pending_request_canceller_map_.begin();
22 it != pending_request_canceller_map_.end();
23 ++it) {
24 it->second.Run();
25 }
26 }
27
28 bool DTLSIdentityServiceHost::OnMessageReceived(const IPC::Message& message,
29 bool* message_was_ok) {
30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP_EX(DTLSIdentityServiceHost, message, *message_was_ok)
32 IPC_MESSAGE_HANDLER(DTLSIdentityMsg_RequestIdentity, OnRequestIdentity)
33 IPC_MESSAGE_HANDLER(DTLSIdentityMsg_CancelRequest, OnCancelRequest)
34 IPC_MESSAGE_UNHANDLED(handled = false)
35 IPC_END_MESSAGE_MAP_EX()
36 return handled;
37 }
38
39 void DTLSIdentityServiceHost::OnRequestIdentity(
40 int request_id,
41 const GURL& origin,
42 const std::string& identity_name,
43 const std::string& common_name) {
44 DCHECK(pending_request_canceller_map_.end() ==
45 pending_request_canceller_map_.find(request_id));
46
47 pending_request_canceller_map_[request_id] = dtls_identity_store_->
48 RequestIdentity(
49 origin,
50 identity_name,
51 common_name,
52 base::Bind(&DTLSIdentityServiceHost::OnComplete,
53 base::Unretained(this), request_id));
54 }
55
56 void DTLSIdentityServiceHost::OnCancelRequest(int request_id) {
57 DCHECK(pending_request_canceller_map_.find(request_id) !=
58 pending_request_canceller_map_.end());
59 pending_request_canceller_map_[request_id].Run();
60 pending_request_canceller_map_.erase(request_id);
61 }
62
63 void DTLSIdentityServiceHost::OnComplete(int request_id,
64 int error,
65 const std::string& certificate,
66 const std::string& private_key) {
67 DCHECK(pending_request_canceller_map_.find(request_id) !=
68 pending_request_canceller_map_.end());
69 pending_request_canceller_map_.erase(request_id);
70 if (error == net::OK) {
71 Send(new DTLSIdentityHostMsg_IdentityReady(request_id,
72 certificate,
73 private_key));
74 } else {
75 Send(new DTLSIdentityHostMsg_RequestFailed(request_id, error));
76 }
77 }
78
79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698