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

Side by Side Diff: chrome/browser/sessions/session_service_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/sessions/session_service.h" 5 #include "chrome/browser/sessions/session_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // 4. Deletes SessionService. 1028 // 4. Deletes SessionService.
1029 // 5. Signals the semaphore that 2 and 3 are waiting on, allowing 1029 // 5. Signals the semaphore that 2 and 3 are waiting on, allowing
1030 // GetLastSession() to continue. 1030 // GetLastSession() to continue.
1031 // 6. runs the message loop, this is quit when the task scheduled in 3 posts 1031 // 6. runs the message loop, this is quit when the task scheduled in 3 posts
1032 // back to the ui thread to quit the run loop. 1032 // back to the ui thread to quit the run loop.
1033 // The call to get the previous session should never be invoked because the 1033 // The call to get the previous session should never be invoked because the
1034 // SessionService was destroyed before SessionService could process the results. 1034 // SessionService was destroyed before SessionService could process the results.
1035 TEST_F(SessionServiceTest, GetSessionsAndDestroy) { 1035 TEST_F(SessionServiceTest, GetSessionsAndDestroy) {
1036 base::CancelableTaskTracker cancelable_task_tracker; 1036 base::CancelableTaskTracker cancelable_task_tracker;
1037 base::RunLoop run_loop; 1037 base::RunLoop run_loop;
1038 base::WaitableEvent event(true, false); 1038 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
1039 base::WaitableEvent::InitialState::NOT_SIGNALED);
1039 helper_.RunTaskOnBackendThread(FROM_HERE, 1040 helper_.RunTaskOnBackendThread(FROM_HERE,
1040 base::Bind(&base::WaitableEvent::Wait, 1041 base::Bind(&base::WaitableEvent::Wait,
1041 base::Unretained(&event))); 1042 base::Unretained(&event)));
1042 service()->GetLastSession(base::Bind(&OnGotPreviousSession), 1043 service()->GetLastSession(base::Bind(&OnGotPreviousSession),
1043 &cancelable_task_tracker); 1044 &cancelable_task_tracker);
1044 helper_.RunTaskOnBackendThread( 1045 helper_.RunTaskOnBackendThread(
1045 FROM_HERE, 1046 FROM_HERE,
1046 base::Bind(&PostBackToThread, 1047 base::Bind(&PostBackToThread,
1047 base::Unretained(base::MessageLoop::current()), 1048 base::Unretained(base::MessageLoop::current()),
1048 base::Unretained(&run_loop))); 1049 base::Unretained(&run_loop)));
1049 delete helper_.ReleaseService(); 1050 delete helper_.ReleaseService();
1050 event.Signal(); 1051 event.Signal();
1051 run_loop.Run(); 1052 run_loop.Run();
1052 } 1053 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698