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

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

Issue 6079009: Move some misc thread-related stuff from base to base/thread and into the bas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/base/test_completion_callback_unittest.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) 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 <string> 7 #include <string>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/nss_util.h" 12 #include "base/nss_util.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "base/threading/worker_pool.h"
14 #include "base/thread_restrictions.h" 15 #include "base/thread_restrictions.h"
15 #include "base/waitable_event.h" 16 #include "base/waitable_event.h"
16 #include "base/worker_pool.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 #if defined(USE_NSS) 19 #if defined(USE_NSS)
20 #include <private/pprthred.h> // PR_DetachThread 20 #include <private/pprthred.h> // PR_DetachThread
21 #endif 21 #endif
22 22
23 namespace net { 23 namespace net {
24 24
25 namespace { 25 namespace {
26 26
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 }; 117 };
118 118
119 // We asynchronously generate the keys so as not to hang up the IO thread. This 119 // We asynchronously generate the keys so as not to hang up the IO thread. This
120 // test tries to catch concurrency problems in the keygen implementation. 120 // test tries to catch concurrency problems in the keygen implementation.
121 TEST_F(KeygenHandlerTest, ConcurrencyTest) { 121 TEST_F(KeygenHandlerTest, ConcurrencyTest) {
122 const int NUM_HANDLERS = 5; 122 const int NUM_HANDLERS = 5;
123 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; 123 base::WaitableEvent* events[NUM_HANDLERS] = { NULL };
124 std::string results[NUM_HANDLERS]; 124 std::string results[NUM_HANDLERS];
125 for (int i = 0; i < NUM_HANDLERS; i++) { 125 for (int i = 0; i < NUM_HANDLERS; i++) {
126 events[i] = new base::WaitableEvent(false, false); 126 events[i] = new base::WaitableEvent(false, false);
127 WorkerPool::PostTask(FROM_HERE, 127 base::WorkerPool::PostTask(
128 new ConcurrencyTestTask(events[i], "some challenge", 128 FROM_HERE,
129 &results[i]), 129 new ConcurrencyTestTask(events[i], "some challenge", &results[i]),
130 true); 130 true);
131 } 131 }
132 132
133 for (int i = 0; i < NUM_HANDLERS; i++) { 133 for (int i = 0; i < NUM_HANDLERS; i++) {
134 // Make sure the job completed 134 // Make sure the job completed
135 bool signaled = events[i]->Wait(); 135 bool signaled = events[i]->Wait();
136 EXPECT_TRUE(signaled); 136 EXPECT_TRUE(signaled);
137 delete events[i]; 137 delete events[i];
138 events[i] = NULL; 138 events[i] = NULL;
139 139
140 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; 140 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i];
141 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); 141 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge");
142 } 142 }
143 } 143 }
144 144
145 } // namespace 145 } // namespace
146 146
147 } // namespace net 147 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/base/test_completion_callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698