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

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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment