| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 17 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/sessions/session_service.h" | 23 #include "chrome/browser/sessions/session_service.h" |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 // Functions used by GetSessionsAndDestroy. | 997 // Functions used by GetSessionsAndDestroy. |
| 996 namespace { | 998 namespace { |
| 997 | 999 |
| 998 void OnGotPreviousSession(ScopedVector<sessions::SessionWindow> windows, | 1000 void OnGotPreviousSession(ScopedVector<sessions::SessionWindow> windows, |
| 999 SessionID::id_type ignored_active_window) { | 1001 SessionID::id_type ignored_active_window) { |
| 1000 FAIL() << "SessionService was destroyed, this shouldn't be reached."; | 1002 FAIL() << "SessionService was destroyed, this shouldn't be reached."; |
| 1001 } | 1003 } |
| 1002 | 1004 |
| 1003 void PostBackToThread(base::MessageLoop* message_loop, | 1005 void PostBackToThread(base::MessageLoop* message_loop, |
| 1004 base::RunLoop* run_loop) { | 1006 base::RunLoop* run_loop) { |
| 1005 message_loop->PostTask(FROM_HERE, | 1007 message_loop->task_runner()->PostTask( |
| 1006 base::Bind(&base::RunLoop::Quit, | 1008 FROM_HERE, base::Bind(&base::RunLoop::Quit, base::Unretained(run_loop))); |
| 1007 base::Unretained(run_loop))); | |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 } // namespace | 1011 } // namespace |
| 1011 | 1012 |
| 1012 // Verifies that SessionService::GetLastSession() works correctly if the | 1013 // Verifies that SessionService::GetLastSession() works correctly if the |
| 1013 // SessionService is deleted during processing. To verify the problematic case | 1014 // SessionService is deleted during processing. To verify the problematic case |
| 1014 // does the following: | 1015 // does the following: |
| 1015 // 1. Sends a task to the background thread that blocks. | 1016 // 1. Sends a task to the background thread that blocks. |
| 1016 // 2. Asks SessionService for the last session commands. This is blocked by 1. | 1017 // 2. Asks SessionService for the last session commands. This is blocked by 1. |
| 1017 // 3. Posts another task to the background thread, this too is blocked by 1. | 1018 // 3. Posts another task to the background thread, this too is blocked by 1. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1033 &cancelable_task_tracker); | 1034 &cancelable_task_tracker); |
| 1034 helper_.RunTaskOnBackendThread( | 1035 helper_.RunTaskOnBackendThread( |
| 1035 FROM_HERE, | 1036 FROM_HERE, |
| 1036 base::Bind(&PostBackToThread, | 1037 base::Bind(&PostBackToThread, |
| 1037 base::Unretained(base::MessageLoop::current()), | 1038 base::Unretained(base::MessageLoop::current()), |
| 1038 base::Unretained(&run_loop))); | 1039 base::Unretained(&run_loop))); |
| 1039 delete helper_.ReleaseService(); | 1040 delete helper_.ReleaseService(); |
| 1040 event.Signal(); | 1041 event.Signal(); |
| 1041 run_loop.Run(); | 1042 run_loop.Run(); |
| 1042 } | 1043 } |
| OLD | NEW |