| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |  | 
| 2 // Use of this source code is governed by a BSD-style license that can be |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ |  | 
| 6 #define CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ |  | 
| 7 |  | 
| 8 #include <vector> |  | 
| 9 |  | 
| 10 #include "base/compiler_specific.h" |  | 
| 11 #include "base/macros.h" |  | 
| 12 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h" |  | 
| 13 #include "mojo/public/cpp/bindings/binding_set.h" |  | 
| 14 #include "mojo/public/cpp/bindings/strong_binding_set.h" |  | 
| 15 #include "services/preferences/public/interfaces/preferences.mojom.h" |  | 
| 16 #include "services/service_manager/public/cpp/interface_factory.h" |  | 
| 17 #include "services/service_manager/public/cpp/service.h" |  | 
| 18 |  | 
| 19 // Handles all incoming prefs::mojom::PreferenceManagerRequest, providing a |  | 
| 20 // separate PreferencesService per connection request. |  | 
| 21 // |  | 
| 22 // Additionally monitors system shutdown to clean up connections to PrefService. |  | 
| 23 // |  | 
| 24 // TODO(jonross): Observe profile switching and update PreferenceManager |  | 
| 25 // connections. |  | 
| 26 class PreferencesConnectionManager |  | 
| 27     : public NON_EXPORTED_BASE(prefs::mojom::PreferencesServiceFactory), |  | 
| 28       public NON_EXPORTED_BASE(service_manager::InterfaceFactory< |  | 
| 29                                prefs::mojom::PreferencesServiceFactory>), |  | 
| 30       public NON_EXPORTED_BASE(service_manager::Service) { |  | 
| 31  public: |  | 
| 32   PreferencesConnectionManager(); |  | 
| 33   ~PreferencesConnectionManager() override; |  | 
| 34 |  | 
| 35  private: |  | 
| 36   // KeyedServiceShutdownNotifier::Subscription callback. Used to cleanup when |  | 
| 37   // the active PrefService is being destroyed. |  | 
| 38   void OnProfileDestroyed(); |  | 
| 39 |  | 
| 40   // prefs::mojom::PreferencesServiceFactory: |  | 
| 41   void Create(prefs::mojom::PreferencesServiceClientPtr client, |  | 
| 42               prefs::mojom::PreferencesServiceRequest service) override; |  | 
| 43 |  | 
| 44   // service_manager::InterfaceFactory<PreferencesServiceFactory>: |  | 
| 45   void Create(const service_manager::Identity& remote_identity, |  | 
| 46               prefs::mojom::PreferencesServiceFactoryRequest request) override; |  | 
| 47 |  | 
| 48   // service_manager::Service: |  | 
| 49   bool OnConnect(const service_manager::ServiceInfo& remote_info, |  | 
| 50                  service_manager::InterfaceRegistry* registry) override; |  | 
| 51 |  | 
| 52   mojo::BindingSet<prefs::mojom::PreferencesServiceFactory> factory_bindings_; |  | 
| 53 |  | 
| 54   // Bindings that automatically cleanup during connection errors. |  | 
| 55   mojo::StrongBindingSet<prefs::mojom::PreferencesService> manager_bindings_; |  | 
| 56 |  | 
| 57   // Observes shutdown, when PrefService is being destroyed. |  | 
| 58   std::unique_ptr<KeyedServiceShutdownNotifier::Subscription> |  | 
| 59       profile_shutdown_notification_; |  | 
| 60 |  | 
| 61   DISALLOW_COPY_AND_ASSIGN(PreferencesConnectionManager); |  | 
| 62 }; |  | 
| 63 |  | 
| 64 #endif  // CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ |  | 
| OLD | NEW | 
|---|