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

Side by Side Diff: chrome/browser/extensions/api/system_info/system_info_api.cc

Issue 174513003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 3). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } // namespace 215 } // namespace
216 216
217 static base::LazyInstance<ProfileKeyedAPIFactory<SystemInfoAPI> > 217 static base::LazyInstance<ProfileKeyedAPIFactory<SystemInfoAPI> >
218 g_factory = LAZY_INSTANCE_INITIALIZER; 218 g_factory = LAZY_INSTANCE_INITIALIZER;
219 219
220 // static 220 // static
221 ProfileKeyedAPIFactory<SystemInfoAPI>* SystemInfoAPI::GetFactoryInstance() { 221 ProfileKeyedAPIFactory<SystemInfoAPI>* SystemInfoAPI::GetFactoryInstance() {
222 return g_factory.Pointer(); 222 return g_factory.Pointer();
223 } 223 }
224 224
225 SystemInfoAPI::SystemInfoAPI(Profile* profile) : profile_(profile) { 225 SystemInfoAPI::SystemInfoAPI(content::BrowserContext* context)
226 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); 226 : browser_context_(context) {
227 EventRouter* router = ExtensionSystem::Get(browser_context_)->event_router();
227 router->RegisterObserver(this, system_storage::OnAttached::kEventName); 228 router->RegisterObserver(this, system_storage::OnAttached::kEventName);
228 router->RegisterObserver(this, system_storage::OnDetached::kEventName); 229 router->RegisterObserver(this, system_storage::OnDetached::kEventName);
229 router->RegisterObserver(this, system_display::OnDisplayChanged::kEventName); 230 router->RegisterObserver(this, system_display::OnDisplayChanged::kEventName);
230 } 231 }
231 232
232 SystemInfoAPI::~SystemInfoAPI() { 233 SystemInfoAPI::~SystemInfoAPI() {
233 } 234 }
234 235
235 void SystemInfoAPI::Shutdown() { 236 void SystemInfoAPI::Shutdown() {
236 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 237 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver(
238 this);
237 } 239 }
238 240
239 void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) { 241 void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) {
240 if (IsSystemStorageEvent(details.event_name)) { 242 if (IsSystemStorageEvent(details.event_name)) {
241 StorageMonitor::GetInstance()->EnsureInitialized( 243 StorageMonitor::GetInstance()->EnsureInitialized(
242 base::Bind(&AddEventListener, details.event_name)); 244 base::Bind(&AddEventListener, details.event_name));
243 } else { 245 } else {
244 AddEventListener(details.event_name); 246 AddEventListener(details.event_name);
245 } 247 }
246 } 248 }
247 249
248 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { 250 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) {
249 if (IsSystemStorageEvent(details.event_name)) { 251 if (IsSystemStorageEvent(details.event_name)) {
250 StorageMonitor::GetInstance()->EnsureInitialized( 252 StorageMonitor::GetInstance()->EnsureInitialized(
251 base::Bind(&RemoveEventListener, details.event_name)); 253 base::Bind(&RemoveEventListener, details.event_name));
252 } else { 254 } else {
253 RemoveEventListener(details.event_name); 255 RemoveEventListener(details.event_name);
254 } 256 }
255 } 257 }
256 258
257 } // namespace extensions 259 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698