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

Side by Side Diff: chrome/browser/prefs/preferences_connection_manager.cc

Issue 2695803004: Make browser process a singleton service (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/chrome_interface_factory.cc ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prefs/preferences_connection_manager.h" 5 #include "chrome/browser/prefs/preferences_connection_manager.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/prefs/preferences_service.h" 9 #include "chrome/browser/prefs/preferences_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 binding->set_connection_error_handler( 83 binding->set_connection_error_handler(
84 base::Bind(&PreferencesConnectionManager::OnConnectionError, 84 base::Bind(&PreferencesConnectionManager::OnConnectionError,
85 base::Unretained(this), binding)); 85 base::Unretained(this), binding));
86 manager_bindings_.push_back(std::move(binding)); 86 manager_bindings_.push_back(std::move(binding));
87 } 87 }
88 88
89 void PreferencesConnectionManager::Create( 89 void PreferencesConnectionManager::Create(
90 const service_manager::Identity& remote_identity, 90 const service_manager::Identity& remote_identity,
91 prefs::mojom::PreferencesServiceFactoryRequest request) { 91 prefs::mojom::PreferencesServiceFactoryRequest request) {
92 factory_bindings_.AddBinding(this, std::move(request)); 92 factory_bindings_.AddBinding(this, std::move(request));
93
94 if (!profile_shutdown_notification_) {
95 profile_shutdown_notification_ =
96 ShutdownNotifierFactory::GetInstance()
97 ->Get(ProfileManager::GetActiveUserProfile())
98 ->Subscribe(
99 base::Bind(&PreferencesConnectionManager::OnProfileDestroyed,
100 base::Unretained(this)));
101 }
93 } 102 }
94 103
95 void PreferencesConnectionManager::OnStart() { 104 void PreferencesConnectionManager::OnStart() {
96 // Certain tests have no profiles to connect to, and static initializers 105 // Certain tests have no profiles to connect to, and static initializers
97 // which block the creation of test profiles. 106 // which block the creation of test profiles.
98 if (!g_browser_process->profile_manager()->GetNumberOfProfiles()) 107 if (!g_browser_process->profile_manager()->GetNumberOfProfiles())
99 return; 108 return;
100
101 profile_shutdown_notification_ =
102 ShutdownNotifierFactory::GetInstance()
103 ->Get(ProfileManager::GetActiveUserProfile())
104 ->Subscribe(
105 base::Bind(&PreferencesConnectionManager::OnProfileDestroyed,
106 base::Unretained(this)));
107 } 109 }
108 110
109 bool PreferencesConnectionManager::OnConnect( 111 bool PreferencesConnectionManager::OnConnect(
110 const service_manager::ServiceInfo& remote_info, 112 const service_manager::ServiceInfo& remote_info,
111 service_manager::InterfaceRegistry* registry) { 113 service_manager::InterfaceRegistry* registry) {
112 registry->AddInterface<prefs::mojom::PreferencesServiceFactory>(this); 114 registry->AddInterface<prefs::mojom::PreferencesServiceFactory>(this);
113 return true; 115 return true;
114 } 116 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_interface_factory.cc ('k') | chrome/browser/ui/ash/ash_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698