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

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

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Update PreferencesManager to account for base::Value API change Created 4 years 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/prefs/DEPS ('k') | chrome/browser/prefs/preferences_connection_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0f9e8dfe89750eab17ed529ed787a4744d5effdb
--- /dev/null
+++ b/chrome/browser/prefs/preferences_connection_manager.h
@@ -0,0 +1,62 @@
+// 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/compiler_specific.h"
+#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"
+#include "services/service_manager/public/cpp/interface_factory.h"
+#include "services/service_manager/public/cpp/service.h"
+
+// 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 NON_EXPORTED_BASE(
+ service_manager::InterfaceFactory<prefs::mojom::PreferencesManager>),
+ public NON_EXPORTED_BASE(service_manager::Service) {
+ public:
+ PreferencesConnectionManager();
+ ~PreferencesConnectionManager() override;
+
+ private:
+ // mojo::StrongBinding callback:
+ void OnConnectionError(
+ mojo::StrongBindingPtr<prefs::mojom::PreferencesManager> binding);
+
+ // KeyedServiceShutdownNotifier::Subscription callback. Used to cleanup when
+ // the active PrefService is being destroyed.
+ void OnProfileDestroyed();
+
+ // service_manager::InterfaceFactory<PreferencesManager>:
+ void Create(const service_manager::Identity& remote_identity,
+ prefs::mojom::PreferencesManagerRequest request) override;
+
+ // service_manager::Service:
+ void OnStart() override;
+ bool OnConnect(const service_manager::ServiceInfo& remote_info,
+ service_manager::InterfaceRegistry* registry) override;
+
+ // 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);
+};
+
+#endif // CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_
« no previous file with comments | « chrome/browser/prefs/DEPS ('k') | chrome/browser/prefs/preferences_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698