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

Side by Side Diff: chrome/browser/sync/test/integration/autofill_helper.cc

Issue 2021393004: Migrate WaitableEvent to enum-based constructor in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: Split out custom changes to thread_watcher_unittest.cc 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/sync/test/integration/autofill_helper.h" 5 #include "chrome/browser/sync/test/integration/autofill_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 void RunOnDBThreadAndSignal(base::Closure task, 65 void RunOnDBThreadAndSignal(base::Closure task,
66 base::WaitableEvent* done_event) { 66 base::WaitableEvent* done_event) {
67 if (!task.is_null()) { 67 if (!task.is_null()) {
68 task.Run(); 68 task.Run();
69 } 69 }
70 done_event->Signal(); 70 done_event->Signal();
71 } 71 }
72 72
73 void RunOnDBThreadAndBlock(base::Closure task) { 73 void RunOnDBThreadAndBlock(base::Closure task) {
74 WaitableEvent done_event(false, false); 74 WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
75 base::WaitableEvent::InitialState::NOT_SIGNALED);
75 BrowserThread::PostTask(BrowserThread::DB, 76 BrowserThread::PostTask(BrowserThread::DB,
76 FROM_HERE, 77 FROM_HERE,
77 Bind(&RunOnDBThreadAndSignal, task, &done_event)); 78 Bind(&RunOnDBThreadAndSignal, task, &done_event));
78 done_event.Wait(); 79 done_event.Wait();
79 } 80 }
80 81
81 void RemoveKeyDontBlockForSync(int profile, const AutofillKey& key) { 82 void RemoveKeyDontBlockForSync(int profile, const AutofillKey& key) {
82 WaitableEvent done_event(false, false); 83 WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
84 base::WaitableEvent::InitialState::NOT_SIGNALED);
83 85
84 MockWebDataServiceObserver mock_observer; 86 MockWebDataServiceObserver mock_observer;
85 EXPECT_CALL(mock_observer, AutofillEntriesChanged(_)) 87 EXPECT_CALL(mock_observer, AutofillEntriesChanged(_))
86 .WillOnce(SignalEvent(&done_event)); 88 .WillOnce(SignalEvent(&done_event));
87 89
88 scoped_refptr<AutofillWebDataService> wds = 90 scoped_refptr<AutofillWebDataService> wds =
89 autofill_helper::GetWebDataService(profile); 91 autofill_helper::GetWebDataService(profile);
90 92
91 void(AutofillWebDataService::*add_observer_func)( 93 void(AutofillWebDataService::*add_observer_func)(
92 AutofillWebDataServiceObserverOnDBThread*) = 94 AutofillWebDataServiceObserverOnDBThread*) =
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 std::vector<FormFieldData> form_fields; 195 std::vector<FormFieldData> form_fields;
194 for (std::set<AutofillKey>::const_iterator i = keys.begin(); 196 for (std::set<AutofillKey>::const_iterator i = keys.begin();
195 i != keys.end(); 197 i != keys.end();
196 ++i) { 198 ++i) {
197 FormFieldData field; 199 FormFieldData field;
198 field.name = i->name(); 200 field.name = i->name();
199 field.value = i->value(); 201 field.value = i->value();
200 form_fields.push_back(field); 202 form_fields.push_back(field);
201 } 203 }
202 204
203 WaitableEvent done_event(false, false); 205 WaitableEvent done_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
206 base::WaitableEvent::InitialState::NOT_SIGNALED);
204 MockWebDataServiceObserver mock_observer; 207 MockWebDataServiceObserver mock_observer;
205 EXPECT_CALL(mock_observer, AutofillEntriesChanged(_)) 208 EXPECT_CALL(mock_observer, AutofillEntriesChanged(_))
206 .WillOnce(SignalEvent(&done_event)); 209 .WillOnce(SignalEvent(&done_event));
207 210
208 scoped_refptr<AutofillWebDataService> wds = GetWebDataService(profile); 211 scoped_refptr<AutofillWebDataService> wds = GetWebDataService(profile);
209 212
210 void(AutofillWebDataService::*add_observer_func)( 213 void(AutofillWebDataService::*add_observer_func)(
211 AutofillWebDataServiceObserverOnDBThread*) = 214 AutofillWebDataServiceObserverOnDBThread*) =
212 &AutofillWebDataService::AddObserver; 215 &AutofillWebDataService::AddObserver;
213 RunOnDBThreadAndBlock(Bind(add_observer_func, wds, &mock_observer)); 216 RunOnDBThreadAndBlock(Bind(add_observer_func, wds, &mock_observer));
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 509
507 } // namespace 510 } // namespace
508 511
509 bool AwaitProfilesMatch(int a, int b) { 512 bool AwaitProfilesMatch(int a, int b) {
510 ProfilesMatchStatusChecker checker(a, b); 513 ProfilesMatchStatusChecker checker(a, b);
511 checker.Wait(); 514 checker.Wait();
512 return !checker.TimedOut(); 515 return !checker.TimedOut();
513 } 516 }
514 517
515 } // namespace autofill_helper 518 } // namespace autofill_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698