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

Side by Side Diff: net/base/keygen_handler_unittest.cc

Issue 5242002: Reland 66791 (change was innocent)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « net/base/ev_root_ca_metadata.cc ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/keygen_handler.h" 5 #include "net/base/keygen_handler.h"
6 6
7 #include "build/build_config.h" // Needs to be imported early for USE_NSS 7 #include "build/build_config.h" // Needs to be imported early for USE_NSS
8 8
9 #if defined(USE_NSS) 9 #if defined(USE_NSS)
10 #include <private/pprthred.h> // PR_DetachThread 10 #include <private/pprthred.h> // PR_DetachThread
11 #endif 11 #endif
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "base/base64.h" 15 #include "base/base64.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/nss_util.h" 17 #include "base/nss_util.h"
18 #include "base/task.h" 18 #include "base/task.h"
19 #include "base/thread_restrictions.h"
19 #include "base/waitable_event.h" 20 #include "base/waitable_event.h"
20 #include "base/worker_pool.h" 21 #include "base/worker_pool.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace net { 24 namespace net {
24 25
25 namespace { 26 namespace {
26 27
27 class KeygenHandlerTest : public ::testing::Test { 28 class KeygenHandlerTest : public ::testing::Test {
28 public: 29 public:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 class ConcurrencyTestTask : public Task { 84 class ConcurrencyTestTask : public Task {
84 public: 85 public:
85 ConcurrencyTestTask(base::WaitableEvent* event, 86 ConcurrencyTestTask(base::WaitableEvent* event,
86 const std::string& challenge, std::string* result) 87 const std::string& challenge, std::string* result)
87 : event_(event), 88 : event_(event),
88 challenge_(challenge), 89 challenge_(challenge),
89 result_(result) { 90 result_(result) {
90 } 91 }
91 92
92 virtual void Run() { 93 virtual void Run() {
94 // We allow Singleton use on the worker thread here since we use a
95 // WaitableEvent to synchronize, so it's safe.
96 base::ThreadRestrictions::ScopedAllowSingleton scoped_allow_singleton;
93 KeygenHandler handler(768, "some challenge", 97 KeygenHandler handler(768, "some challenge",
94 GURL("http://www.example.com")); 98 GURL("http://www.example.com"));
95 handler.set_stores_key(false); // Don't leave the key-pair behind. 99 handler.set_stores_key(false); // Don't leave the key-pair behind.
96 *result_ = handler.GenKeyAndSignChallenge(); 100 *result_ = handler.GenKeyAndSignChallenge();
97 event_->Signal(); 101 event_->Signal();
98 #if defined(USE_NSS) 102 #if defined(USE_NSS)
99 // Detach the thread from NSPR. 103 // Detach the thread from NSPR.
100 // Calling NSS functions attaches the thread to NSPR, which stores 104 // Calling NSS functions attaches the thread to NSPR, which stores
101 // the NSPR thread ID in thread-specific data. 105 // the NSPR thread ID in thread-specific data.
102 // The threads in our thread pool terminate after we have called 106 // The threads in our thread pool terminate after we have called
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 events[i] = NULL; 139 events[i] = NULL;
136 140
137 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; 141 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i];
138 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); 142 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge");
139 } 143 }
140 } 144 }
141 145
142 } // namespace 146 } // namespace
143 147
144 } // namespace net 148 } // namespace net
OLDNEW
« no previous file with comments | « net/base/ev_root_ca_metadata.cc ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698