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

Unified Diff: chrome/browser/extensions/api/system_info/system_info_api.cc

Issue 132873008: SystemInfo API: Fix SystemInfoEventRouter initialization code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/system_info/system_info_api.cc
===================================================================
--- chrome/browser/extensions/api/system_info/system_info_api.cc (revision 245000)
+++ chrome/browser/extensions/api/system_info/system_info_api.cc (working copy)
@@ -68,7 +68,7 @@
// Called from any thread to dispatch the systemInfo event to all extension
// processes cross multiple profiles.
void DispatchEvent(const std::string& event_name,
- scoped_ptr<base::ListValue> args);
+ scoped_ptr<base::ListValue> args);
// Called to dispatch the systemInfo.display.onDisplayChanged event.
void OnDisplayChanged();
@@ -89,7 +89,6 @@
SystemInfoEventRouter::SystemInfoEventRouter() {
StorageMonitor::GetInstance()->AddObserver(this);
- StorageMonitor::GetInstance()->EnsureInitialized(base::Closure());
}
SystemInfoEventRouter::~SystemInfoEventRouter() {
@@ -112,8 +111,7 @@
}
}
-void SystemInfoEventRouter::RemoveEventListener(
- const std::string& event_name) {
+void SystemInfoEventRouter::RemoveEventListener(const std::string& event_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
std::multiset<std::string>::iterator it =
@@ -173,6 +171,16 @@
BroadcastEventToRenderers(event_name, args.Pass(), GURL());
}
Haojian Wu 2014/01/16 06:53:27 Some performance concerns: everytime we add an sys
Lei Zhang 2014/01/16 23:24:11 See patch set 2.
+void AddEventListener(const std::string& event_name) {
+ DCHECK(StorageMonitor::GetInstance()->IsInitialized());
+ SystemInfoEventRouter::GetInstance()->AddEventListener(event_name);
+}
+
+void RemoveEventListener(const std::string& event_name) {
+ DCHECK(StorageMonitor::GetInstance()->IsInitialized());
+ SystemInfoEventRouter::GetInstance()->RemoveEventListener(event_name);
+}
+
} // namespace
static base::LazyInstance<ProfileKeyedAPIFactory<SystemInfoAPI> >
@@ -200,11 +208,13 @@
}
void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) {
- SystemInfoEventRouter::GetInstance()->AddEventListener(details.event_name);
+ StorageMonitor::GetInstance()->EnsureInitialized(
+ base::Bind(&AddEventListener, details.event_name));
}
void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) {
- SystemInfoEventRouter::GetInstance()->RemoveEventListener(details.event_name);
+ StorageMonitor::GetInstance()->EnsureInitialized(
+ base::Bind(&RemoveEventListener, details.event_name));
}
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698