Commit d955d78d authored by gab's avatar gab Committed by Commit bot

Migrate WaitableEvent to enum-based constructor in chrome/

Change automated with clang-tidy (details @ https://crbug.com/612843#c13)

BUG=612843

Review-Url: https://codereview.chromium.org/2021393004
Cr-Commit-Position: refs/heads/master@{#397920}
parent d3fafe01
......@@ -404,8 +404,9 @@ class RundownTaskCounter :
};
RundownTaskCounter::RundownTaskCounter()
: count_(1), waitable_event_(true, false) {
}
: count_(1),
waitable_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
void RundownTaskCounter::Post(base::SequencedTaskRunner* task_runner) {
// As the count starts off at one, it should never get to zero unless
......
......@@ -714,7 +714,9 @@ class HTML5FileWriter {
}
// Invoke the fileapi to copy it into the sandboxed filesystem.
bool result = false;
base::WaitableEvent done_event(true, false);
base::WaitableEvent done_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&CreateFileForTestingOnIOThread,
......
......@@ -22,15 +22,15 @@ using extensions::ResultCatcher;
namespace {
const std::string kHostname = "127.0.0.1";
const char kHostname[] = "127.0.0.1";
const int kPort = 8888;
class SocketApiTest : public ExtensionApiTest {
public:
SocketApiTest() : resolver_event_(true, false),
resolver_creator_(
new extensions::MockHostResolverCreator()) {
}
SocketApiTest()
: resolver_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
resolver_creator_(new extensions::MockHostResolverCreator()) {}
void SetUpOnMainThread() override {
extensions::HostResolverWrapper::GetInstance()->SetHostResolverForTesting(
......@@ -116,8 +116,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) {
ExtensionTestMessageListener listener("info_please", true);
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
listener.Reply(
base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort));
listener.Reply(base::StringPrintf("tcp_server:%s:%d", kHostname, kPort));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
......@@ -142,8 +141,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketMulticast) {
ExtensionTestMessageListener listener("info_please", true);
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
listener.Reply(
base::StringPrintf("multicast:%s:%d", kHostname.c_str(), kPort));
listener.Reply(base::StringPrintf("multicast:%s:%d", kHostname, kPort));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
......@@ -78,8 +78,8 @@ class AudioWaitingExtensionTest : public ExtensionApiTest {
class WebrtcAudioPrivateTest : public AudioWaitingExtensionTest {
public:
WebrtcAudioPrivateTest()
: enumeration_event_(false, false) {
}
: enumeration_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
void SetUpOnMainThread() override {
AudioWaitingExtensionTest::SetUpOnMainThread();
......
......@@ -1022,8 +1022,9 @@ class ExternallyConnectableMessagingWithTlsChannelIdTest :
public ExternallyConnectableMessagingTest {
public:
ExternallyConnectableMessagingWithTlsChannelIdTest()
: tls_channel_id_created_(false, false) {
}
: tls_channel_id_created_(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
std::string CreateTlsChannelId() {
scoped_refptr<net::URLRequestContextGetter> request_context_getter(
......
......@@ -752,7 +752,9 @@ void Predictor::SaveStateForNextStartupAndTrim() {
if (!CanPreresolveAndPreconnect())
return;
base::WaitableEvent completion(true, false);
base::WaitableEvent completion(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
ListPrefUpdate update_startup_list(user_prefs_,
prefs::kDnsPrefetchingStartupList);
......
......@@ -281,7 +281,10 @@ const GnomeKeyringPasswordSchema kGnomeSchema = {
// be used in parallel.
class GKRMethod : public GnomeKeyringLoader {
public:
GKRMethod() : event_(false, false), result_(GNOME_KEYRING_RESULT_CANCELLED) {}
GKRMethod()
: event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
result_(GNOME_KEYRING_RESULT_CANCELLED) {}
// Action methods. These call gnome_keyring_* functions. Call from UI thread.
// See GetProfileSpecificAppString() for more information on the app string.
......
......@@ -344,7 +344,8 @@ bool NativeBackendKWallet::InitWithBus(scoped_refptr<dbus::Bus> optional_bus) {
// succeeds, but later, we'll want to do most work on the DB thread. So we
// have to do the initialization on the DB thread here too, and wait for it.
bool success = false;
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
// NativeBackendKWallet isn't reference counted, but we wait for InitWithBus
// to finish, so we can safely use base::Unretained here.
BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
......
......@@ -282,7 +282,8 @@ class NativeBackendKWalletTest : public NativeBackendKWalletTestBase {
// Let the DB thread run to completion of all current tasks.
void RunDBThread() {
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
base::Bind(ThreadDone, &event));
event.Wait();
......
......@@ -45,12 +45,13 @@ namespace {
class ChromeStarter : public base::RefCountedThreadSafe<ChromeStarter> {
public:
ChromeStarter(base::TimeDelta timeout, const base::FilePath& user_data_dir)
: ready_event_(false /* manual */, false /* signaled */),
done_event_(false /* manual */, false /* signaled */),
: ready_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
done_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
process_terminated_(false),
timeout_(timeout),
user_data_dir_(user_data_dir) {
}
user_data_dir_(user_data_dir) {}
// We must reset some data members since we reuse the same ChromeStarter
// object and start/stop it a few times. We must start fresh! :-)
......@@ -139,7 +140,8 @@ class ProcessSingletonTest : public InProcessBrowserTest {
ProcessSingletonTest()
// We use a manual reset so that all threads wake up at once when signaled
// and thus we must manually reset it for each attempt.
: threads_waker_(true /* manual */, false /* signaled */) {
: threads_waker_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED) {
EXPECT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
}
......
......@@ -69,8 +69,10 @@ class ProcessSingletonPosixTest : public testing::Test {
ProcessSingletonPosixTest()
: kill_callbacks_(0),
io_thread_(BrowserThread::IO),
wait_event_(true, false),
signal_event_(true, false),
wait_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
signal_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
process_singleton_on_thread_(NULL) {
io_thread_.StartIOThread();
}
......
......@@ -130,7 +130,8 @@ void CheckChromeVersion(Profile *profile, bool is_new) {
void FlushTaskRunner(base::SequencedTaskRunner* runner) {
ASSERT_TRUE(runner);
base::WaitableEvent unblock(false, false);
base::WaitableEvent unblock(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
runner->PostTask(FROM_HERE,
base::Bind(&base::WaitableEvent::Signal, base::Unretained(&unblock)));
......
......@@ -223,7 +223,9 @@ void BlockFileThreadOnDirectoryCreate(base::WaitableEvent* done_creating) {
void CreateProfileDirectory(base::SequencedTaskRunner* sequenced_task_runner,
const base::FilePath& path,
bool create_readme) {
base::WaitableEvent* done_creating = new base::WaitableEvent(false, false);
base::WaitableEvent* done_creating =
new base::WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
sequenced_task_runner->PostTask(
FROM_HERE, base::Bind(&CreateDirectoryAndSignal, path, done_creating,
create_readme));
......
......@@ -1035,7 +1035,8 @@ void PostBackToThread(base::MessageLoop* message_loop,
TEST_F(SessionServiceTest, GetSessionsAndDestroy) {
base::CancelableTaskTracker cancelable_task_tracker;
base::RunLoop run_loop;
base::WaitableEvent event(true, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
helper_.RunTaskOnBackendThread(FROM_HERE,
base::Bind(&base::WaitableEvent::Wait,
base::Unretained(&event)));
......
......@@ -275,7 +275,8 @@ IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT) {
// Attach an event to the SpellcheckService object so we can receive its
// status updates.
base::WaitableEvent event(true, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
SpellcheckService::AttachStatusEvent(&event);
BrowserContext* context = GetContext();
......
......@@ -27,7 +27,8 @@ using ::testing::StrictMock;
using content::BrowserThread;
SSLClientCertificateSelectorTestBase::SSLClientCertificateSelectorTestBase()
: io_loop_finished_event_(false, false) {
: io_loop_finished_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {
}
SSLClientCertificateSelectorTestBase::~SSLClientCertificateSelectorTestBase() {
......
......@@ -71,7 +71,8 @@ void RunOnDBThreadAndSignal(base::Closure task,
}
void RunOnDBThreadAndBlock(base::Closure task) {
WaitableEvent done_event(false, false);
WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
BrowserThread::PostTask(BrowserThread::DB,
FROM_HERE,
Bind(&RunOnDBThreadAndSignal, task, &done_event));
......@@ -79,7 +80,8 @@ void RunOnDBThreadAndBlock(base::Closure task) {
}
void RemoveKeyDontBlockForSync(int profile, const AutofillKey& key) {
WaitableEvent done_event(false, false);
WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
MockWebDataServiceObserver mock_observer;
EXPECT_CALL(mock_observer, AutofillEntriesChanged(_))
......@@ -200,7 +202,8 @@ void AddKeys(int profile, const std::set<AutofillKey>& keys) {
form_fields.push_back(field);
}
WaitableEvent done_event(false, false);
WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
MockWebDataServiceObserver mock_observer;
EXPECT_CALL(mock_observer, AutofillEntriesChanged(_))
.WillOnce(SignalEvent(&done_event));
......
......@@ -317,7 +317,8 @@ void WaitForHistoryToProcessPendingTasks() {
Profile* profile = profiles_which_need_to_wait[i];
history::HistoryService* history_service =
HistoryServiceFactory::GetForProfileWithoutCreating(profile);
base::WaitableEvent done(false, false);
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
base::CancelableTaskTracker task_tracker;
history_service->ScheduleDBTask(
std::unique_ptr<history::HistoryDBTask>(new HistoryEmptyTask(&done)),
......
......@@ -47,7 +47,8 @@ void GetAllSettingsOnFileThread(base::DictionaryValue* out,
std::unique_ptr<base::DictionaryValue> GetAllSettings(Profile* profile,
const std::string& id) {
base::WaitableEvent signal(false, false);
base::WaitableEvent signal(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
extensions::StorageFrontend::Get(profile)->RunWithStorage(
ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(id),
......@@ -99,7 +100,8 @@ void SetExtensionSettings(
Profile* profile,
const std::string& id,
const base::DictionaryValue& settings) {
base::WaitableEvent signal(false, false);
base::WaitableEvent signal(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
extensions::StorageFrontend::Get(profile)->RunWithStorage(
ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(id),
extensions::settings_namespace::SYNC,
......
......@@ -75,7 +75,9 @@ namespace passwords_helper {
void AddLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
store->AddLogin(form);
store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait();
......@@ -83,7 +85,9 @@ void AddLogin(PasswordStore* store, const PasswordForm& form) {
void UpdateLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
store->UpdateLogin(form);
store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait();
......@@ -101,7 +105,9 @@ ScopedVector<PasswordForm> GetLogins(PasswordStore* store) {
void RemoveLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
store->RemoveLogin(form);
store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait();
......
......@@ -39,7 +39,8 @@ void SignalEvent(base::WaitableEvent* e) {
}
bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) {
base::WaitableEvent e(true, false);
base::WaitableEvent e(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
loop->task_runner()->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e));
// Timeout stolen from StatusChangeChecker::GetTimeoutDuration().
return e.TimedWait(base::TimeDelta::FromSeconds(45));
......
......@@ -147,7 +147,9 @@ void WaitForHistoryDBThread(int index) {
history::HistoryService* service =
HistoryServiceFactory::GetForProfileWithoutCreating(
test()->GetProfile(index));
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>(
new FlushHistoryDBQueueTask(&wait_event)),
&tracker);
......@@ -176,7 +178,9 @@ history::URLRows GetTypedUrlsFromHistoryService(
history::HistoryService* service) {
base::CancelableTaskTracker tracker;
history::URLRows rows;
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>(
new GetTypedUrlsTask(&rows, &wait_event)),
&tracker);
......@@ -188,7 +192,9 @@ bool GetUrlFromHistoryService(history::HistoryService* service,
const GURL& url,
history::URLRow* row) {
base::CancelableTaskTracker tracker;
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
bool found = false;
service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>(
new GetUrlTask(url, row, &found, &wait_event)),
......@@ -201,7 +207,9 @@ history::VisitVector GetVisitsFromHistoryService(
history::HistoryService* service,
history::URLID id) {
base::CancelableTaskTracker tracker;
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
history::VisitVector visits;
service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>(
new GetVisitsTask(id, &visits, &wait_event)),
......@@ -213,7 +221,9 @@ history::VisitVector GetVisitsFromHistoryService(
void RemoveVisitsFromHistoryService(history::HistoryService* service,
const history::VisitVector& visits) {
base::CancelableTaskTracker tracker;
base::WaitableEvent wait_event(true, false);
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>(
new RemoveVisitsTask(visits, &wait_event)),
&tracker);
......
......@@ -36,7 +36,8 @@ ChromeNSSCryptoModuleDelegate::ChromeNSSCryptoModuleDelegate(
crypto::ScopedPK11Slot slot)
: reason_(reason),
server_(server),
event_(false, false),
event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
cancelled_(false),
slot_(std::move(slot)) {}
......
......@@ -43,10 +43,11 @@ using content::BrowserThread;
class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
public:
SSLClientCertificateSelectorTest()
: io_loop_finished_event_(false, false),
: io_loop_finished_event_(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
url_request_(NULL),
selector_(NULL) {
}
selector_(NULL) {}
void SetUpInProcessBrowserTestFixture() override {
base::FilePath certs_dir = net::GetTestCertsDirectory();
......
......@@ -182,7 +182,9 @@ bool ServiceProcessState::SignalReady(base::SingleThreadTaskRunner* task_runner,
DPLOG(ERROR) << "pipe";
return false;
}
base::WaitableEvent signal_ready(true, false);
base::WaitableEvent signal_ready(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
bool success = false;
task_runner->PostTask(FROM_HERE,
......
......@@ -116,8 +116,8 @@ class ServiceIPCServerTest : public ::testing::Test {
ServiceIPCServerTest::ServiceIPCServerTest()
: channel_handle_(IPC::Channel::GenerateUniqueRandomChannelID()),
io_thread_("ServiceIPCServerTest IO"),
shutdown_event_(true /* manual_reset */, false /* initially_signaled */) {
}
shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
void ServiceIPCServerTest::SetUp() {
base::Thread::Options options;
......
......@@ -120,7 +120,8 @@ void PrepareRestartOnCrashEnviroment(
} // namespace
ServiceProcess::ServiceProcess()
: shutdown_event_(true /* manual_reset */, false /* initially_signaled */),
: shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
main_message_loop_(NULL),
enabled_services_(0),
update_available_(false) {
......
......@@ -165,7 +165,8 @@ class MojoTestState : public content::TestState {
void Init(base::CommandLine* command_line,
base::TestLauncher::LaunchOptions* test_launch_options) {
base::WaitableEvent signal(true, false);
base::WaitableEvent signal(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
background_shell_->ExecuteOnShellThread(base::Bind(
&MojoTestState::BindOnBackgroundThread, base::Unretained(this), &signal,
command_line, test_launch_options));
......@@ -180,7 +181,8 @@ class MojoTestState : public content::TestState {
// is only called on the background thread, and we wait for
// ChildProcessLaunchedOnBackgroundThread() to be run before continuing so
// that |handle| is still valid.
base::WaitableEvent signal(true, false);
base::WaitableEvent signal(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
background_shell_->ExecuteOnShellThread(
base::Bind(&MojoTestState::ChildProcessLaunchedOnBackgroundThread,
base::Unretained(this), handle, pid, &signal));
......
......@@ -404,8 +404,8 @@ void GetCookies(const GURL& url,
scoped_refptr<net::URLRequestContextGetter> context_getter =
contents->GetRenderProcessHost()->GetStoragePartition()->
GetURLRequestContext();
base::WaitableEvent event(true /* manual reset */,
false /* not initially signaled */);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
CHECK(content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&GetCookiesOnIOThread, url, context_getter, &event, value)));
......
......@@ -27,7 +27,9 @@ namespace {
// callback is run, even if the function that creates the buffer times out.
class ResponseBuffer : public base::RefCountedThreadSafe<ResponseBuffer> {
public:
ResponseBuffer() : ready_(true, false) {}
ResponseBuffer()
: ready_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
void OnResponse(int result, const std::string& response) {
response_ = response;
......
......@@ -24,7 +24,11 @@ class SyncUrlFetcher : public net::URLFetcherDelegate {
SyncUrlFetcher(const GURL& url,
URLRequestContextGetter* getter,
std::string* response)
: url_(url), getter_(getter), response_(response), event_(false, false) {}
: url_(url),
getter_(getter),
response_(response),
event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
~SyncUrlFetcher() override {}
......
......@@ -36,7 +36,8 @@ class FetchUrlTest : public testing::Test,
base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
CHECK(io_thread_.StartWithOptions(options));
context_getter_ = new URLRequestContextGetter(io_thread_.task_runner());
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&FetchUrlTest::InitOnIO, base::Unretained(this), &event));
......@@ -44,7 +45,8 @@ class FetchUrlTest : public testing::Test,
}
~FetchUrlTest() override {
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&FetchUrlTest::DestroyServerOnIO,
base::Unretained(this), &event));
......
......@@ -128,7 +128,9 @@ class PortServerTest : public testing::Test {
void RunServer(const std::string& path,
const std::string& response,
std::string* request) {
base::WaitableEvent listen_event(false, false);
base::WaitableEvent listen_event(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&RunServerOnThread, path, response, &listen_event, request));
......
......@@ -53,7 +53,8 @@ bool SyncWebSocketImpl::Core::IsConnected() {
bool SyncWebSocketImpl::Core::Connect(const GURL& url) {
bool success = false;
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
context_getter_->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&SyncWebSocketImpl::Core::ConnectOnIO,
......@@ -64,7 +65,8 @@ bool SyncWebSocketImpl::Core::Connect(const GURL& url) {
bool SyncWebSocketImpl::Core::Send(const std::string& message) {
bool success = false;
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
context_getter_->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&SyncWebSocketImpl::Core::SendOnIO,
......
......@@ -76,7 +76,9 @@ TEST_F(SyncWebSocketImplTest, SendReceiveTimeout) {
// The server might reply too quickly so that the response will be received
// before we call ReceiveNextMessage; we must prevent it.
base::WaitableEvent server_reply_allowed(false, false);
base::WaitableEvent server_reply_allowed(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
server_.SetMessageCallback(base::Bind(
&base::WaitableEvent::Wait, base::Unretained(&server_reply_allowed)));
......
......@@ -23,10 +23,10 @@ const int kBufferSize = 100 * 1024 * 1024; // 100 MB
TestHttpServer::TestHttpServer()
: thread_("ServerThread"),
all_closed_event_(false, true),
all_closed_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::SIGNALED),
request_action_(kAccept),
message_action_(kEchoMessage) {
}
message_action_(kEchoMessage) {}
TestHttpServer::~TestHttpServer() {
}
......@@ -38,7 +38,8 @@ bool TestHttpServer::Start() {
if (!thread_started)
return false;
bool success;
base::WaitableEvent event(false, false);
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&TestHttpServer::StartOnServerThread,
base::Unretained(this), &success, &event));
......@@ -49,7 +50,8 @@ bool TestHttpServer::Start() {
void TestHttpServer::Stop() {
if (!thread_.IsRunning())