Index: chrome/browser/browser_process_impl.cc |
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc |
index 5ec7f984898a06b53aa354c26d737117ecc37c54..76b826212098a2bd79cdf3587202211df227bdcf 100644 |
--- a/chrome/browser/browser_process_impl.cc |
+++ b/chrome/browser/browser_process_impl.cc |
@@ -76,6 +76,7 @@ |
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h" |
#include "chrome/common/channel_info.h" |
#include "chrome/common/chrome_constants.h" |
+#include "chrome/common/chrome_features.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/crash_keys.h" |
@@ -194,7 +195,8 @@ static const int kUpdateCheckIntervalHours = 6; |
// and Windows. We have a timeout here because we're unable to run the UI |
// messageloop and there's some deadlock risk. Our only option is to exit |
// anyway. |
-static const int kEndSessionTimeoutSeconds = 10; |
+static constexpr base::TimeDelta kEndSessionTimeout = |
+ base::TimeDelta::FromSeconds(10); |
#endif |
using content::BrowserThread; |
@@ -467,12 +469,22 @@ void BrowserProcessImpl::EndSession() { |
ProfileManager* pm = profile_manager(); |
std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
scoped_refptr<RundownTaskCounter> rundown_counter(new RundownTaskCounter()); |
+ const bool pref_service_enabled = |
+ base::FeatureList::IsEnabled(features::kPrefService); |
+ std::vector<scoped_refptr<base::SequencedTaskRunner>> profile_writer_runners; |
for (size_t i = 0; i < profiles.size(); ++i) { |
Profile* profile = profiles[i]; |
profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
if (profile->GetPrefs()) { |
profile->GetPrefs()->CommitPendingWrite(); |
- rundown_counter->Post(profile->GetIOTaskRunner().get()); |
+ if (pref_service_enabled) { |
+ rundown_counter->Post(content::BrowserThread::GetTaskRunnerForThread( |
+ content::BrowserThread::IO) |
+ .get()); |
+ profile_writer_runners.push_back(profile->GetIOTaskRunner()); |
+ } else { |
+ rundown_counter->Post(profile->GetIOTaskRunner().get()); |
+ } |
} |
} |
@@ -513,8 +525,16 @@ void BrowserProcessImpl::EndSession() { |
// GPU process synchronously. Because the system may not be allowing |
// processes to launch, this can result in a hang. See |
// http://crbug.com/318527. |
- rundown_counter->TimedWait( |
- base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds)); |
+ base::Time start = base::Time::Now(); |
sky
2017/03/15 15:19:17
Use timeticks?
Sam McNally
2017/03/16 06:58:22
Done.
|
+ if (rundown_counter->TimedWait(kEndSessionTimeout) && pref_service_enabled) { |
sky
2017/03/15 15:19:17
What does a return value of true mean for TimedWai
Sam McNally
2017/03/16 06:58:22
It returns whether everything finished before the
|
+ scoped_refptr<RundownTaskCounter> profile_write_rundown_counter( |
+ new RundownTaskCounter()); |
+ for (auto& profile_writer_runner : profile_writer_runners) { |
sky
2017/03/15 15:19:17
no {}
Sam McNally
2017/03/16 06:58:22
Done.
|
+ profile_write_rundown_counter->Post(profile_writer_runner.get()); |
+ } |
+ profile_write_rundown_counter->TimedWait(kEndSessionTimeout - |
sky
2017/03/15 15:19:17
Does RundownTaskCounter deal with potentially nega
Sam McNally
2017/03/16 06:58:22
I think it should, but I've changed it to take an
|
+ (base::Time::Now() - start)); |
+ } |
#else |
NOTIMPLEMENTED(); |
#endif |