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

Side by Side Diff: components/prefs/pref_member_unittest.cc

Issue 2028193002: Migrate WaitableEvent to enum-based constructor in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: rm comment explaining true/false Created 4 years, 6 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
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 "components/prefs/pref_member.h" 5 #include "components/prefs/pref_member.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 28 matching lines...) Expand all
39 void Init(const std::string& pref_name, PrefService* prefs) { 39 void Init(const std::string& pref_name, PrefService* prefs) {
40 pref_.Init(pref_name, prefs); 40 pref_.Init(pref_name, prefs);
41 pref_.MoveToThread(pref_thread_.task_runner()); 41 pref_.MoveToThread(pref_thread_.task_runner());
42 } 42 }
43 43
44 void Destroy() { 44 void Destroy() {
45 pref_.Destroy(); 45 pref_.Destroy();
46 } 46 }
47 47
48 void FetchValue() { 48 void FetchValue() {
49 base::WaitableEvent event(true, false); 49 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
50 base::WaitableEvent::InitialState::NOT_SIGNALED);
50 ASSERT_TRUE(pref_thread_.task_runner()->PostTask( 51 ASSERT_TRUE(pref_thread_.task_runner()->PostTask(
51 FROM_HERE, 52 FROM_HERE,
52 base::Bind(&GetPrefValueHelper::GetPrefValue, this, &event))); 53 base::Bind(&GetPrefValueHelper::GetPrefValue, this, &event)));
53 event.Wait(); 54 event.Wait();
54 } 55 }
55 56
56 // The thread must be stopped on the main thread. GetPrefValueHelper being 57 // The thread must be stopped on the main thread. GetPrefValueHelper being
57 // ref-counted, the destructor can be called from any thread. 58 // ref-counted, the destructor can be called from any thread.
58 void StopThread() { 59 void StopThread() {
59 pref_thread_.Stop(); 60 pref_thread_.Stop();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 helper->FetchValue(); 317 helper->FetchValue();
317 EXPECT_TRUE(helper->value()); 318 EXPECT_TRUE(helper->value());
318 319
319 helper->Destroy(); 320 helper->Destroy();
320 321
321 helper->FetchValue(); 322 helper->FetchValue();
322 EXPECT_TRUE(helper->value()); 323 EXPECT_TRUE(helper->value());
323 324
324 helper->StopThread(); 325 helper->StopThread();
325 } 326 }
OLDNEW
« no previous file with comments | « components/mus/gles2/gpu_state.cc ('k') | components/scheduler/child/webthread_impl_for_worker_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698