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 | |
| 11 namespace content { | |
| 12 | |
| 13 DTLSIdentityServiceHost::DTLSIdentityServiceHost(int render_process_id) | |
| 14 : render_process_id_(render_process_id) {} | |
| 15 | |
| 16 DTLSIdentityServiceHost::~DTLSIdentityServiceHost() {} | |
| 17 | |
| 18 bool DTLSIdentityServiceHost::OnMessageReceived(const IPC::Message& message, | |
| 19 bool* message_was_ok) { | |
| 20 bool handled = true; | |
| 21 IPC_BEGIN_MESSAGE_MAP_EX(DTLSIdentityServiceHost, message, *message_was_ok) | |
| 22 IPC_MESSAGE_HANDLER(DTLSIdentityMsg_GetOrGenerate, OnGetOrGenerateIdentity) | |
|
jam
2013/06/06 16:22:32
nit: indent next two lines
jiayl
2013/06/06 17:07:37
Done.
| |
| 23 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 24 IPC_END_MESSAGE_MAP_EX() | |
| 25 return handled; | |
| 26 } | |
| 27 | |
| 28 void DTLSIdentityServiceHost::OnGetOrGenerateIdentity( | |
| 29 const GURL& origin, | |
| 30 const std::string& identity_name, | |
| 31 const std::string& common_name) { | |
| 32 LOG(INFO) << "Sent identity request to DTLSIdentityStore with " | |
|
jam
2013/06/06 16:22:32
same comment re logging as other files
jiayl
2013/06/06 17:07:37
Done.
| |
| 33 << "origin = " << origin.spec() << ", " | |
| 34 << "identity_name = " << identity_name << ", " | |
| 35 << "common_name = " << common_name << "."; | |
| 36 | |
| 37 DTLSIdentityStore::GetInstance()->GetOrGenerateIdentity( | |
| 38 origin, | |
| 39 identity_name, | |
| 40 common_name, | |
| 41 base::Bind(&DTLSIdentityServiceHost::OnCompleteIO, this)); | |
| 42 } | |
| 43 | |
| 44 void DTLSIdentityServiceHost::OnCompleteIO( | |
| 45 const std::string& certificate, | |
| 46 const std::string& private_key) const { | |
| 47 content::BrowserThread::PostTask( | |
|
jam
2013/06/06 16:22:32
you can send the reply directly here (see BrowserM
jiayl
2013/06/06 17:07:37
Done.
| |
| 48 content::BrowserThread::UI, | |
| 49 FROM_HERE, | |
| 50 base::Bind(&DTLSIdentityServiceHost::OnCompleteUI, | |
| 51 this, | |
| 52 certificate, | |
| 53 private_key)); | |
| 54 } | |
| 55 | |
| 56 void DTLSIdentityServiceHost::OnCompleteUI( | |
| 57 const std::string& certificate, | |
| 58 const std::string& private_key) const { | |
| 59 LOG(INFO) << "Identity request completed for render process id " | |
| 60 << render_process_id_; | |
| 61 | |
| 62 RenderProcessHost* render_process_host = | |
| 63 RenderProcessHost::FromID(render_process_id_); | |
| 64 if (render_process_host == NULL) | |
| 65 return; | |
| 66 render_process_host->Send( | |
| 67 new DTLSIdentityMsg_IdentityReady(certificate, private_key)); | |
| 68 } | |
| 69 | |
| 70 } // namespace content | |
| OLD | NEW |