OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/system_info/system_info_api.h" | 5 #include "chrome/browser/extensions/api/system_info/system_info_api.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 void AddEventListener(const std::string& event_name) { | 210 void AddEventListener(const std::string& event_name) { |
211 SystemInfoEventRouter::GetInstance()->AddEventListener(event_name); | 211 SystemInfoEventRouter::GetInstance()->AddEventListener(event_name); |
212 } | 212 } |
213 | 213 |
214 void RemoveEventListener(const std::string& event_name) { | 214 void RemoveEventListener(const std::string& event_name) { |
215 SystemInfoEventRouter::GetInstance()->RemoveEventListener(event_name); | 215 SystemInfoEventRouter::GetInstance()->RemoveEventListener(event_name); |
216 } | 216 } |
217 | 217 |
218 } // namespace | 218 } // namespace |
219 | 219 |
220 static base::LazyInstance<ProfileKeyedAPIFactory<SystemInfoAPI> > | 220 static base::LazyInstance<BrowserContextKeyedAPIFactory<SystemInfoAPI> > |
221 g_factory = LAZY_INSTANCE_INITIALIZER; | 221 g_factory = LAZY_INSTANCE_INITIALIZER; |
222 | 222 |
223 // static | 223 // static |
224 ProfileKeyedAPIFactory<SystemInfoAPI>* SystemInfoAPI::GetFactoryInstance() { | 224 BrowserContextKeyedAPIFactory<SystemInfoAPI>* |
| 225 SystemInfoAPI::GetFactoryInstance() { |
225 return g_factory.Pointer(); | 226 return g_factory.Pointer(); |
226 } | 227 } |
227 | 228 |
228 SystemInfoAPI::SystemInfoAPI(content::BrowserContext* context) | 229 SystemInfoAPI::SystemInfoAPI(content::BrowserContext* context) |
229 : browser_context_(context) { | 230 : browser_context_(context) { |
230 EventRouter* router = ExtensionSystem::Get(browser_context_)->event_router(); | 231 EventRouter* router = ExtensionSystem::Get(browser_context_)->event_router(); |
231 router->RegisterObserver(this, system_storage::OnAttached::kEventName); | 232 router->RegisterObserver(this, system_storage::OnAttached::kEventName); |
232 router->RegisterObserver(this, system_storage::OnDetached::kEventName); | 233 router->RegisterObserver(this, system_storage::OnDetached::kEventName); |
233 router->RegisterObserver(this, system_display::OnDisplayChanged::kEventName); | 234 router->RegisterObserver(this, system_display::OnDisplayChanged::kEventName); |
234 } | 235 } |
(...skipping 18 matching lines...) Expand all Loading... |
253 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { | 254 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { |
254 if (IsSystemStorageEvent(details.event_name)) { | 255 if (IsSystemStorageEvent(details.event_name)) { |
255 StorageMonitor::GetInstance()->EnsureInitialized( | 256 StorageMonitor::GetInstance()->EnsureInitialized( |
256 base::Bind(&RemoveEventListener, details.event_name)); | 257 base::Bind(&RemoveEventListener, details.event_name)); |
257 } else { | 258 } else { |
258 RemoveEventListener(details.event_name); | 259 RemoveEventListener(details.event_name); |
259 } | 260 } |
260 } | 261 } |
261 | 262 |
262 } // namespace extensions | 263 } // namespace extensions |
OLD | NEW |