Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 for (RequestMap::iterator it = pending_request_map_.begin(); | |
| 21 it != pending_request_map_.end(); | |
| 22 ++it) { | |
| 23 it->second.Cancel(); | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 bool DTLSIdentityServiceHost::OnMessageReceived(const IPC::Message& message, | |
| 28 bool* message_was_ok) { | |
| 29 bool handled = true; | |
| 30 IPC_BEGIN_MESSAGE_MAP_EX(DTLSIdentityServiceHost, message, *message_was_ok) | |
| 31 IPC_MESSAGE_HANDLER(DTLSIdentityMsg_RequestIdentity, OnRequestIdentity) | |
| 32 IPC_MESSAGE_HANDLER(DTLSIdentityMsg_CancelRequest, OnCancelRequest) | |
| 33 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 34 IPC_END_MESSAGE_MAP_EX() | |
| 35 return handled; | |
| 36 } | |
| 37 | |
| 38 void DTLSIdentityServiceHost::OnRequestIdentity( | |
| 39 int request_id, | |
| 40 const GURL& origin, | |
| 41 const std::string& identity_name, | |
| 42 const std::string& common_name) { | |
| 43 DCHECK(pending_request_map_.find(request_id) == pending_request_map_.end()); | |
|
Ryan Sleevi
2013/06/13 22:36:47
DCHECK_EQ
jiayl
2013/06/14 00:37:01
It cannot compile, seemingly due to the use of tem
| |
| 44 | |
| 45 pending_request_map_[request_id] = DTLSIdentityStore::RequestHandle(); | |
| 46 dtls_identity_store_->RequestIdentity( | |
| 47 origin, | |
| 48 identity_name, | |
| 49 common_name, | |
| 50 base::Bind(&DTLSIdentityServiceHost::OnComplete, | |
| 51 base::Unretained(this), request_id), | |
| 52 &pending_request_map_[request_id]); | |
| 53 } | |
| 54 | |
| 55 void DTLSIdentityServiceHost::OnCancelRequest(int request_id) { | |
| 56 DCHECK(pending_request_map_.find(request_id) != pending_request_map_.end()); | |
|
Ryan Sleevi
2013/06/13 22:36:47
DCHECK_EQ
jiayl
2013/06/14 00:37:01
cannot compile
| |
| 57 pending_request_map_[request_id].Cancel(); | |
| 58 } | |
| 59 | |
| 60 void DTLSIdentityServiceHost::OnComplete(int request_id, | |
| 61 int error, | |
| 62 const std::string& certificate, | |
| 63 const std::string& private_key) { | |
| 64 DCHECK(pending_request_map_.find(request_id) != pending_request_map_.end()); | |
|
Ryan Sleevi
2013/06/13 22:36:47
DCHECK_EQ
jiayl
2013/06/14 00:37:01
cannot compile
| |
| 65 pending_request_map_.erase(request_id); | |
| 66 if (error == net::OK) { | |
| 67 Send(new DTLSIdentityHostMsg_IdentityReady(request_id, | |
| 68 certificate, | |
| 69 private_key)); | |
| 70 } else { | |
| 71 Send(new DTLSIdentityHostMsg_RequestFailed(request_id, error)); | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 } // namespace content | |
| OLD | NEW |