Chromium Code Reviews| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "base/version.h" | 15 #include "base/version.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 18 #include "chrome/browser/profiles/chrome_version_service.h" | 19 #include "chrome/browser/profiles/chrome_version_service.h" |
| 19 #include "chrome/browser/profiles/profile_impl.h" | 20 #include "chrome/browser/profiles/profile_impl.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/profiles/startup_task_runner_service.h" | 22 #include "chrome/browser/profiles/startup_task_runner_service.h" |
| 22 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 23 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
| 23 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 base::ScopedTempDir temp_dir; | 353 base::ScopedTempDir temp_dir; |
| 353 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 354 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 354 | 355 |
| 355 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 356 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 356 ASSERT_TRUE(profile_manager); | 357 ASSERT_TRUE(profile_manager); |
| 357 std::vector<Profile*> loaded_profiles = profile_manager->GetLoadedProfiles(); | 358 std::vector<Profile*> loaded_profiles = profile_manager->GetLoadedProfiles(); |
| 358 | 359 |
| 359 ASSERT_NE(loaded_profiles.size(), 0UL); | 360 ASSERT_NE(loaded_profiles.size(), 0UL); |
| 360 Profile* profile = loaded_profiles[0]; | 361 Profile* profile = loaded_profiles[0]; |
| 361 | 362 |
| 363 #if defined(OS_CHROMEOS) | |
|
mtomasz
2015/02/18 03:13:06
Why is this change needed?
Ivan Podogov
2015/02/18 09:03:29
Because we force the sign-in profile to load, and
| |
| 364 for (size_t idx = 0; idx != loaded_profiles.size(); ++idx) { | |
|
mtomasz
2015/02/18 03:13:06
for (const auto& ... : ...)
Ivan Podogov
2015/02/24 11:43:16
Done.
| |
| 365 if (!chromeos::ProfileHelper::IsSigninProfile(loaded_profiles[idx])) { | |
| 366 profile = loaded_profiles[idx]; | |
| 367 break; | |
| 368 } | |
| 369 } | |
| 370 #endif | |
| 371 | |
| 362 // This retry loop reduces flakiness due to the fact that this ultimately | 372 // This retry loop reduces flakiness due to the fact that this ultimately |
| 363 // tests whether or not a code path hits a timed wait. | 373 // tests whether or not a code path hits a timed wait. |
| 364 bool succeeded = false; | 374 bool succeeded = false; |
| 365 for (size_t retries = 0; !succeeded && retries < 3; ++retries) { | 375 for (size_t retries = 0; !succeeded && retries < 3; ++retries) { |
| 366 // Flush the profile data to disk for all loaded profiles. | 376 // Flush the profile data to disk for all loaded profiles. |
| 367 profile->SetExitType(Profile::EXIT_CRASHED); | 377 profile->SetExitType(Profile::EXIT_CRASHED); |
| 368 FlushTaskRunner(profile->GetIOTaskRunner().get()); | 378 FlushTaskRunner(profile->GetIOTaskRunner().get()); |
| 369 | 379 |
| 370 // Make sure that the prefs file was written with the expected key/value. | 380 // Make sure that the prefs file was written with the expected key/value. |
| 371 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); | 381 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed"); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 391 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "SessionEnded"); | 401 ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "SessionEnded"); |
| 392 | 402 |
| 393 // Mark the success. | 403 // Mark the success. |
| 394 succeeded = true; | 404 succeeded = true; |
| 395 } | 405 } |
| 396 | 406 |
| 397 ASSERT_TRUE(succeeded) << "profile->EndSession() timed out too often."; | 407 ASSERT_TRUE(succeeded) << "profile->EndSession() timed out too often."; |
| 398 } | 408 } |
| 399 | 409 |
| 400 #endif // defined(USE_X11) || defined(OS_WIN) | 410 #endif // defined(USE_X11) || defined(OS_WIN) |
| OLD | NEW |