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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/dtls_identity_service_host.cc
diff --git a/content/browser/renderer_host/media/dtls_identity_service_host.cc b/content/browser/renderer_host/media/dtls_identity_service_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dbe6c452e10e6e826a45cf6997afd7c594eab2f1
--- /dev/null
+++ b/content/browser/renderer_host/media/dtls_identity_service_host.cc
@@ -0,0 +1,70 @@
+// 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.
+
+#include "content/browser/renderer_host/media/dtls_identity_service_host.h"
+
+#include "base/bind.h"
+#include "content/common/media/dtls_identity_messages.h"
+#include "content/public/browser/render_process_host.h"
+
+namespace content {
+
+DTLSIdentityServiceHost::DTLSIdentityServiceHost(int render_process_id)
+ : render_process_id_(render_process_id) {}
+
+DTLSIdentityServiceHost::~DTLSIdentityServiceHost() {}
+
+bool DTLSIdentityServiceHost::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(DTLSIdentityServiceHost, message, *message_was_ok)
+ 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.
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP_EX()
+ return handled;
+}
+
+void DTLSIdentityServiceHost::OnGetOrGenerateIdentity(
+ const GURL& origin,
+ const std::string& identity_name,
+ const std::string& common_name) {
+ 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.
+ << "origin = " << origin.spec() << ", "
+ << "identity_name = " << identity_name << ", "
+ << "common_name = " << common_name << ".";
+
+ DTLSIdentityStore::GetInstance()->GetOrGenerateIdentity(
+ origin,
+ identity_name,
+ common_name,
+ base::Bind(&DTLSIdentityServiceHost::OnCompleteIO, this));
+}
+
+void DTLSIdentityServiceHost::OnCompleteIO(
+ const std::string& certificate,
+ const std::string& private_key) const {
+ 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.
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&DTLSIdentityServiceHost::OnCompleteUI,
+ this,
+ certificate,
+ private_key));
+}
+
+void DTLSIdentityServiceHost::OnCompleteUI(
+ const std::string& certificate,
+ const std::string& private_key) const {
+ LOG(INFO) << "Identity request completed for render process id "
+ << render_process_id_;
+
+ RenderProcessHost* render_process_host =
+ RenderProcessHost::FromID(render_process_id_);
+ if (render_process_host == NULL)
+ return;
+ render_process_host->Send(
+ new DTLSIdentityMsg_IdentityReady(certificate, private_key));
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698