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

Side by Side Diff: chrome/browser/net/keygen_handler_generic.cc

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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 // This is the generic wrapper used for keygen on non-NSS platforms.
6
7 #include "chrome/browser/net/keygen_handler.h"
8
9 #include "base/bind.h"
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "base/threading/worker_pool.h"
13 #include "net/base/keygen_handler.h"
14
15 namespace {
16
17 void KeygenOnWorkerThread(
18 int key_size_in_bits,
19 const std::string& challenge,
20 const GURL& url,
21 bool stores_key,
22 std::string* result) {
23 net::KeygenHandler handler(key_size_in_bits, challenge, url);
24 handler.set_stores_key(stores_key);
25 *result = handler.GenKeyAndSignChallenge();
26 }
27
28 } // namespace
29
30 namespace chrome {
31
32 void Keygen(content::ResourceContext* context,
33 int key_size_in_bits,
34 const std::string& challenge,
35 const GURL& url,
36 bool stores_key,
37 const base::Callback<void(const std::string*)>& callback) {
38
39 VLOG(1) << "Dispatching keygen task to worker pool.";
40 std::string* result(new std::string());
41 // Dispatch to worker pool, so we do not block the IO thread.
42 if (!base::WorkerPool::PostTaskAndReply(
43 FROM_HERE,
44 base::Bind(&KeygenOnWorkerThread,
45 key_size_in_bits,
46 challenge,
47 url,
48 stores_key,
49 result),
50 base::Bind(callback, base::Owned(result)),
51 true)) {
52 NOTREACHED() << "Failed to dispatch keygen task to worker pool";
53 callback.Run(NULL);
54 return;
55 }
56 }
57
58 } // namespace chrome
59
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698