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

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

Issue 2030663002: Migrate WaitableEvent to enum-based constructor in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « net/base/address_tracker_linux_unittest.cc ('k') | net/disk_cache/blockfile/backend_impl.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <openssl/bytestring.h> 7 #include <openssl/bytestring.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 196
197 // We asynchronously generate the keys so as not to hang up the IO thread. This 197 // We asynchronously generate the keys so as not to hang up the IO thread. This
198 // test tries to catch concurrency problems in the keygen implementation. 198 // test tries to catch concurrency problems in the keygen implementation.
199 TEST_F(KeygenHandlerTest, ConcurrencyTest) { 199 TEST_F(KeygenHandlerTest, ConcurrencyTest) {
200 const int NUM_HANDLERS = 5; 200 const int NUM_HANDLERS = 5;
201 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; 201 base::WaitableEvent* events[NUM_HANDLERS] = { NULL };
202 std::string results[NUM_HANDLERS]; 202 std::string results[NUM_HANDLERS];
203 for (int i = 0; i < NUM_HANDLERS; i++) { 203 for (int i = 0; i < NUM_HANDLERS; i++) {
204 std::unique_ptr<KeygenHandler> handler(CreateKeygenHandler()); 204 std::unique_ptr<KeygenHandler> handler(CreateKeygenHandler());
205 events[i] = new base::WaitableEvent(false, false); 205 events[i] = new base::WaitableEvent(
206 base::WaitableEvent::ResetPolicy::AUTOMATIC,
207 base::WaitableEvent::InitialState::NOT_SIGNALED);
206 base::WorkerPool::PostTask(FROM_HERE, 208 base::WorkerPool::PostTask(FROM_HERE,
207 base::Bind(ConcurrencyTestCallback, 209 base::Bind(ConcurrencyTestCallback,
208 "some challenge", 210 "some challenge",
209 events[i], 211 events[i],
210 base::Passed(&handler), 212 base::Passed(&handler),
211 &results[i]), 213 &results[i]),
212 true); 214 true);
213 } 215 }
214 216
215 for (int i = 0; i < NUM_HANDLERS; i++) { 217 for (int i = 0; i < NUM_HANDLERS; i++) {
216 // Make sure the job completed 218 // Make sure the job completed
217 events[i]->Wait(); 219 events[i]->Wait();
218 delete events[i]; 220 delete events[i];
219 events[i] = NULL; 221 events[i] = NULL;
220 222
221 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; 223 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i];
222 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); 224 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge");
223 } 225 }
224 } 226 }
225 227
226 } // namespace 228 } // namespace
227 229
228 } // namespace net 230 } // namespace net
OLDNEW
« no previous file with comments | « net/base/address_tracker_linux_unittest.cc ('k') | net/disk_cache/blockfile/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698