| OLD | NEW |
| 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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 ASSERT_NE(loaded_profiles.size(), 0UL); | 360 ASSERT_NE(loaded_profiles.size(), 0UL); |
| 361 Profile* profile = loaded_profiles[0]; | 361 Profile* profile = loaded_profiles[0]; |
| 362 | 362 |
| 363 // This retry loop reduces flakiness due to the fact that this ultimately | 363 // This retry loop reduces flakiness due to the fact that this ultimately |
| 364 // tests whether or not a code path hits a timed wait. | 364 // tests whether or not a code path hits a timed wait. |
| 365 bool succeeded = false; | 365 bool succeeded = false; |
| 366 for (size_t retries = 0; !succeeded && retries < 3; ++retries) { | 366 for (size_t retries = 0; !succeeded && retries < 3; ++retries) { |
| 367 // Flush the profile data to disk for all loaded profiles. | 367 // Flush the profile data to disk for all loaded profiles. |
| 368 profile->SetExitType(Profile::EXIT_CRASHED); | 368 profile->SetExitType(Profile::EXIT_CRASHED); |
| 369 FlushTaskRunner(profile->GetIOTaskRunner()); | 369 FlushTaskRunner(profile->GetIOTaskRunner().get()); |
| 370 | 370 |
| 371 // Make sure that the prefs file was written with the expected key/value. | 371 // Make sure that the prefs file was written with the expected key/value. |
| 372 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); | 372 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); |
| 373 | 373 |
| 374 // The blocking wait in EndSession has a timeout. | 374 // The blocking wait in EndSession has a timeout. |
| 375 base::Time start = base::Time::Now(); | 375 base::Time start = base::Time::Now(); |
| 376 | 376 |
| 377 // This must not return until the profile data has been written to disk. | 377 // This must not return until the profile data has been written to disk. |
| 378 // If this test flakes, then logoff on Windows has broken again. | 378 // If this test flakes, then logoff on Windows has broken again. |
| 379 g_browser_process->EndSession(); | 379 g_browser_process->EndSession(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 ASSERT_NE(loaded_profiles.size(), 0UL); | 414 ASSERT_NE(loaded_profiles.size(), 0UL); |
| 415 Profile* profile = loaded_profiles[0]; | 415 Profile* profile = loaded_profiles[0]; |
| 416 | 416 |
| 417 bool mis_wrote = false; | 417 bool mis_wrote = false; |
| 418 // This retry loop reduces flakiness due to the fact that this ultimately | 418 // This retry loop reduces flakiness due to the fact that this ultimately |
| 419 // tests whether or not a code path hits a timed wait. | 419 // tests whether or not a code path hits a timed wait. |
| 420 for (size_t retries = 0; retries < 3; ++retries) { | 420 for (size_t retries = 0; retries < 3; ++retries) { |
| 421 // Flush the profile data to disk for all loaded profiles. | 421 // Flush the profile data to disk for all loaded profiles. |
| 422 profile->SetExitType(Profile::EXIT_CRASHED); | 422 profile->SetExitType(Profile::EXIT_CRASHED); |
| 423 FlushTaskRunner(profile->GetIOTaskRunner()); | 423 FlushTaskRunner(profile->GetIOTaskRunner().get()); |
| 424 | 424 |
| 425 // Make sure that the prefs file was written with the expected key/value. | 425 // Make sure that the prefs file was written with the expected key/value. |
| 426 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); | 426 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); |
| 427 | 427 |
| 428 base::WaitableEvent is_blocked(false, false); | 428 base::WaitableEvent is_blocked(false, false); |
| 429 base::WaitableEvent* unblock = new base::WaitableEvent(false, false); | 429 base::WaitableEvent* unblock = new base::WaitableEvent(false, false); |
| 430 | 430 |
| 431 // Block the profile's IO thread. | 431 // Block the profile's IO thread. |
| 432 profile->GetIOTaskRunner()->PostTask(FROM_HERE, | 432 profile->GetIOTaskRunner()->PostTask(FROM_HERE, |
| 433 base::Bind(&BlockThread, &is_blocked, base::Owned(unblock))); | 433 base::Bind(&BlockThread, &is_blocked, base::Owned(unblock))); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 454 } | 454 } |
| 455 | 455 |
| 456 // Release the IO thread thread. | 456 // Release the IO thread thread. |
| 457 unblock->Signal(); | 457 unblock->Signal(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 ASSERT_TRUE(mis_wrote); | 460 ASSERT_TRUE(mis_wrote); |
| 461 } | 461 } |
| 462 | 462 |
| 463 #endif // defined(USE_X11) || defined(OS_WIN) | 463 #endif // defined(USE_X11) || defined(OS_WIN) |
| OLD | NEW |