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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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 <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // segfaults on shutdown when the threads' thread-specific data 100 // segfaults on shutdown when the threads' thread-specific data
101 // destructors run. 101 // destructors run.
102 PR_DetachThread(); 102 PR_DetachThread();
103 #endif 103 #endif
104 } 104 }
105 105
106 // We asynchronously generate the keys so as not to hang up the IO thread. This 106 // We asynchronously generate the keys so as not to hang up the IO thread. This
107 // test tries to catch concurrency problems in the keygen implementation. 107 // test tries to catch concurrency problems in the keygen implementation.
108 TEST_F(KeygenHandlerTest, ConcurrencyTest) { 108 TEST_F(KeygenHandlerTest, ConcurrencyTest) {
109 const int NUM_HANDLERS = 5; 109 const int NUM_HANDLERS = 5;
110 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; 110 base::WaitableEvent* events[NUM_HANDLERS] = {NULL};
111 std::string results[NUM_HANDLERS]; 111 std::string results[NUM_HANDLERS];
112 for (int i = 0; i < NUM_HANDLERS; i++) { 112 for (int i = 0; i < NUM_HANDLERS; i++) {
113 events[i] = new base::WaitableEvent(false, false); 113 events[i] = new base::WaitableEvent(false, false);
114 base::WorkerPool::PostTask( 114 base::WorkerPool::PostTask(
115 FROM_HERE, 115 FROM_HERE,
116 base::Bind(ConcurrencyTestCallback, events[i], "some challenge", 116 base::Bind(
117 &results[i]), 117 ConcurrencyTestCallback, events[i], "some challenge", &results[i]),
118 true); 118 true);
119 } 119 }
120 120
121 for (int i = 0; i < NUM_HANDLERS; i++) { 121 for (int i = 0; i < NUM_HANDLERS; i++) {
122 // Make sure the job completed 122 // Make sure the job completed
123 events[i]->Wait(); 123 events[i]->Wait();
124 delete events[i]; 124 delete events[i];
125 events[i] = NULL; 125 events[i] = NULL;
126 126
127 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; 127 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i];
128 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); 128 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge");
129 } 129 }
130 } 130 }
131 131
132 } // namespace 132 } // namespace
133 133
134 } // namespace net 134 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698