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

Unified Diff: chrome/browser/prefs/preferences_connection_manager.h

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Update mojom to support separate subscriptions Created 4 years, 1 month 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
Index: chrome/browser/prefs/preferences_connection_manager.h
diff --git a/chrome/browser/prefs/preferences_connection_manager.h b/chrome/browser/prefs/preferences_connection_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b797da96b57d3d9a71ba01b0bdc2c184bbd8a26
--- /dev/null
+++ b/chrome/browser/prefs/preferences_connection_manager.h
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_
+#define CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "services/preferences/public/interfaces/preferences.mojom.h"
+
+namespace chrome {
+
+// Handles all incoming prefs::mojom::PreferenceManagerRequest, providing a
+// separate PreferencesManager per connection request.
+//
+// Additionally monitors system shutdown to clean up connections to PrefService.
+//
+// TODO(jonross): Observe profile switching and update PreferenceManager
+// connections.
+class PreferencesConnectionManager {
+ public:
+ PreferencesConnectionManager();
+ ~PreferencesConnectionManager();
+
+ // Creates a new PreferencesManager and binds it to |request|.
+ void ProcessRequest(prefs::mojom::PreferencesManagerRequest request);
+
+ private:
+ // KeyedServiceShutdownNotifier::Subscription callback. Used to cleanup when
+ // the active PrefService is being destroyed.
+ void OnProfileDestroyed();
+
+ // Bindings that automatically cleanup during connection errors.
+ std::vector<mojo::StrongBindingPtr<prefs::mojom::PreferencesManager>>
+ bindings_;
+
+ // Observes shutdown, when PrefService is being destroyed.
+ std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
+ profile_shutdown_notification_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreferencesConnectionManager);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698