OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |