| OLD | NEW |
| 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 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 PR_DetachThread(); | 105 PR_DetachThread(); |
| 106 #endif | 106 #endif |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 base::WaitableEvent* event_; | 110 base::WaitableEvent* event_; |
| 111 std::string challenge_; | 111 std::string challenge_; |
| 112 std::string* result_; | 112 std::string* result_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // See crbug.com/48006 | |
| 116 #if defined(OS_MACOSX) | |
| 117 #define MAYBE_ConcurrencyTest FLAKY_ConcurrencyTest | |
| 118 #else | |
| 119 #define MAYBE_ConcurrencyTest ConcurrencyTest | |
| 120 #endif | |
| 121 | |
| 122 // We asynchronously generate the keys so as not to hang up the IO thread. This | 115 // We asynchronously generate the keys so as not to hang up the IO thread. This |
| 123 // test tries to catch concurrency problems in the keygen implementation. | 116 // test tries to catch concurrency problems in the keygen implementation. |
| 124 TEST_F(KeygenHandlerTest, MAYBE_ConcurrencyTest) { | 117 TEST_F(KeygenHandlerTest, ConcurrencyTest) { |
| 125 const int NUM_HANDLERS = 5; | 118 const int NUM_HANDLERS = 5; |
| 126 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; | 119 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; |
| 127 std::string results[NUM_HANDLERS]; | 120 std::string results[NUM_HANDLERS]; |
| 128 for (int i = 0; i < NUM_HANDLERS; i++) { | 121 for (int i = 0; i < NUM_HANDLERS; i++) { |
| 129 events[i] = new base::WaitableEvent(false, false); | 122 events[i] = new base::WaitableEvent(false, false); |
| 130 WorkerPool::PostTask(FROM_HERE, | 123 WorkerPool::PostTask(FROM_HERE, |
| 131 new ConcurrencyTestTask(events[i], "some challenge", | 124 new ConcurrencyTestTask(events[i], "some challenge", |
| 132 &results[i]), | 125 &results[i]), |
| 133 true); | 126 true); |
| 134 } | 127 } |
| 135 | 128 |
| 136 for (int i = 0; i < NUM_HANDLERS; i++) { | 129 for (int i = 0; i < NUM_HANDLERS; i++) { |
| 137 // Make sure the job completed | 130 // Make sure the job completed |
| 138 bool signaled = events[i]->Wait(); | 131 bool signaled = events[i]->Wait(); |
| 139 EXPECT_TRUE(signaled); | 132 EXPECT_TRUE(signaled); |
| 140 delete events[i]; | 133 delete events[i]; |
| 141 events[i] = NULL; | 134 events[i] = NULL; |
| 142 | 135 |
| 143 LOG(INFO) << "KeygenHandler " << i << " produced: " << results[i]; | 136 LOG(INFO) << "KeygenHandler " << i << " produced: " << results[i]; |
| 144 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); | 137 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); |
| 145 } | 138 } |
| 146 } | 139 } |
| 147 | 140 |
| 148 } // namespace | 141 } // namespace |
| 149 | 142 |
| 150 } // namespace net | 143 } // namespace net |
| OLD | NEW |