Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3134)

Unified Diff: chrome/browser/browser_process_impl.cc

Issue 2746023002: Pref service: enable for user prefs in chrome behind a flag. (Closed)
Patch Set: no, the other pref service Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chrome_content_browser_manifest_overlay.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_process_impl.cc
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 2225836b8006538d5392ce53d3b6242524be807b..34edc3caa532928701879a7588c463a7aa92ac8d 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"
@@ -193,7 +194,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;
@@ -409,9 +411,11 @@ class RundownTaskCounter :
// of times before calling TimedWait.
void Post(base::SequencedTaskRunner* task_runner);
- // Waits until the count is zero or |max_time| has passed.
- // This can only be called once per instance.
- bool TimedWait(const base::TimeDelta& max_time);
+ // Waits until the count is zero or |end_time| is reached.
+ // This can only be called once per instance. Returns true if a count of zero
+ // is reached or false if the |end_time| is reached. It is valid to pass an
+ // |end_time| in the past.
+ bool TimedWaitUntil(const base::TimeTicks& end_time);
private:
friend class base::RefCountedThreadSafe<RundownTaskCounter>;
@@ -452,11 +456,11 @@ void RundownTaskCounter::Decrement() {
waitable_event_.Signal();
}
-bool RundownTaskCounter::TimedWait(const base::TimeDelta& max_time) {
+bool RundownTaskCounter::TimedWaitUntil(const base::TimeTicks& end_time) {
// Decrement the excess count from the constructor.
Decrement();
- return waitable_event_.TimedWait(max_time);
+ return waitable_event_.TimedWaitUntil(end_time);
}
} // namespace
@@ -466,12 +470,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());
+ }
}
}
@@ -512,8 +526,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));
+ const base::TimeTicks end_time = base::TimeTicks::Now() + kEndSessionTimeout;
+ const bool timed_out = !rundown_counter->TimedWaitUntil(end_time);
+ if (timed_out || !pref_service_enabled)
+ return;
+
+ scoped_refptr<RundownTaskCounter> profile_write_rundown_counter(
+ new RundownTaskCounter());
+ for (auto& profile_writer_runner : profile_writer_runners)
+ profile_write_rundown_counter->Post(profile_writer_runner.get());
+ profile_write_rundown_counter->TimedWaitUntil(end_time);
#else
NOTIMPLEMENTED();
#endif
« no previous file with comments | « no previous file | chrome/browser/chrome_content_browser_manifest_overlay.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698