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

Unified Diff: chrome/browser/extensions/api/settings_private/settings_private_event_router.cc

Issue 2742663002: MD Settings: defer sending pref updates until all synchronous operations finish (Closed)
Patch Set: damn 's' 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 | « chrome/browser/extensions/api/settings_private/settings_private_event_router.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/settings_private/settings_private_event_router.cc
diff --git a/chrome/browser/extensions/api/settings_private/settings_private_event_router.cc b/chrome/browser/extensions/api/settings_private/settings_private_event_router.cc
index f42e2ef98f92d0e5a7ff9316f84b53124b5edd27..d5d266359779a7f090323bfe3bcadbc5b72e499c 100644
--- a/chrome/browser/extensions/api/settings_private/settings_private_event_router.cc
+++ b/chrome/browser/extensions/api/settings_private/settings_private_event_router.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -20,7 +21,7 @@ namespace extensions {
SettingsPrivateEventRouter::SettingsPrivateEventRouter(
content::BrowserContext* context)
- : context_(context), listening_(false) {
+ : context_(context), listening_(false), weak_ptr_factory_(this) {
// Register with the event router so we know when renderers are listening to
// our events. We first check and see if there *is* an event router, because
// some unit tests try to create all context services, but don't initialize
@@ -123,6 +124,15 @@ void SettingsPrivateEventRouter::StartOrStopListeningForPrefsChanges() {
void SettingsPrivateEventRouter::OnPreferenceChanged(
const std::string& pref_name) {
+ // This posts an asynchronous task to ensure that all pref stores are updated,
+ // as |prefs_util_->GetPref()| relies on this information to determine if a
+ // preference is controlled by e.g. extensions.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&SettingsPrivateEventRouter::SendPrefChange,
+ weak_ptr_factory_.GetWeakPtr(), pref_name));
+}
+
+void SettingsPrivateEventRouter::SendPrefChange(const std::string& pref_name) {
EventRouter* event_router = EventRouter::Get(context_);
if (!event_router->HasEventListener(
api::settings_private::OnPrefsChanged::kEventName)) {
« no previous file with comments | « chrome/browser/extensions/api/settings_private/settings_private_event_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698