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

Unified Diff: content/browser/renderer_host/render_message_filter.cc

Issue 1345483002: Create a RenderProcess message class and move keygen to it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 5 years, 3 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
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_message_filter.cc
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 5a1a8475f96e7cbaebd8903518aaa08050ae2fb8..c1f050e582b0f64e833b2fd6cbf1368c8d5f506e 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -32,6 +32,7 @@
#include "content/common/content_constants_internal.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/host_shared_bitmap_manager.h"
+#include "content/common/render_process_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_child_process_host.h"
#include "content/public/browser/browser_context.h"
@@ -50,6 +51,7 @@
#include "media/audio/audio_parameters.h"
#include "media/base/media_log_event.h"
#include "net/base/io_buffer.h"
+#include "net/base/keygen_handler.h"
#include "net/base/mime_util.h"
#include "net/base/request_priority.h"
#include "net/http/http_cache.h"
@@ -71,6 +73,7 @@ namespace {
const uint32 kFilteredMessageClasses[] = {
ChildProcessMsgStart,
+ RenderProcessMsgStart,
ViewMsgStart,
};
@@ -162,6 +165,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
OnAllocateLockedDiscardableSharedMemory)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedDiscardableSharedMemory,
OnDeletedDiscardableSharedMemory)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata,
OnCacheableMetadataAvailable)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig,
@@ -490,6 +494,65 @@ void RenderMessageFilter::OnCacheableMetadataAvailable(
data.size());
}
+void RenderMessageFilter::OnKeygen(uint32 key_size_index,
+ const std::string& challenge_string,
+ const GURL& url,
+ IPC::Message* reply_msg) {
+ // Map displayed strings indicating level of keysecurity in the <keygen>
+ // menu to the key size in bits. (See SSLKeyGeneratorChromium.cpp in WebCore.)
+ int key_size_in_bits;
+ switch (key_size_index) {
+ case 0:
+ key_size_in_bits = 2048;
+ break;
+ case 1:
+ key_size_in_bits = 1024;
+ break;
+ default:
+ DCHECK(false) << "Illegal key_size_index " << key_size_index;
+ RenderProcessHostMsg_Keygen::WriteReplyParams(reply_msg, std::string());
+ Send(reply_msg);
+ return;
+ }
+
+ resource_context_->CreateKeygenHandler(
+ key_size_in_bits,
+ challenge_string,
+ url,
+ base::Bind(
+ &RenderMessageFilter::PostKeygenToWorkerThread, this, reply_msg));
+}
+
+void RenderMessageFilter::PostKeygenToWorkerThread(
+ IPC::Message* reply_msg,
+ scoped_ptr<net::KeygenHandler> keygen_handler) {
+ VLOG(1) << "Dispatching keygen task to worker pool.";
+ // Dispatch to worker pool, so we do not block the IO thread.
+ if (!base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&RenderMessageFilter::OnKeygenOnWorkerThread,
+ this,
+ base::Passed(&keygen_handler),
+ reply_msg),
+ true)) {
+ NOTREACHED() << "Failed to dispatch keygen task to worker pool";
+ RenderProcessHostMsg_Keygen::WriteReplyParams(reply_msg, std::string());
+ Send(reply_msg);
+ }
+}
+
+void RenderMessageFilter::OnKeygenOnWorkerThread(
+ scoped_ptr<net::KeygenHandler> keygen_handler,
+ IPC::Message* reply_msg) {
+ DCHECK(reply_msg);
+
+ // Generate a signed public key and challenge, then send it back.
+ RenderProcessHostMsg_Keygen::WriteReplyParams(
+ reply_msg,
+ keygen_handler->GenKeyAndSignChallenge());
+ Send(reply_msg);
+}
+
void RenderMessageFilter::OnMediaLogEvents(
const std::vector<media::MediaLogEvent>& events) {
// OnMediaLogEvents() is always dispatched to the UI thread for handling.
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698