Chromium Code Reviews| 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" |
|
James Cook
2016/11/18 00:50:34
Forward declare this?
jonross
2016/11/18 20:31:23
I'm using the a nested class from it :(
|
| +#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_ |