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

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_service.cc

Issue 9422003: Migrate Declarative API bindings to new JSON objects generated by JSON compiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leaks Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/declarative/rules_registry_service.cc
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service.cc b/chrome/browser/extensions/api/declarative/rules_registry_service.cc
index a5c150980fc24cb9d1d71a8ae1a75805ea2e2dc8..40d5c123b16df4c56ef2331046470cc650cb5089 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry_service.cc
+++ b/chrome/browser/extensions/api/declarative/rules_registry_service.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/extensions/api/declarative/initializing_rules_registry.h"
#include "chrome/common/chrome_notification_types.h"
@@ -14,33 +15,49 @@
namespace extensions {
RulesRegistryService::RulesRegistryService(Profile* profile) {
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
- content::Source<Profile>(profile));
+ if (profile) {
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
+ content::Source<Profile>(profile));
+ }
}
RulesRegistryService::~RulesRegistryService() {}
void RulesRegistryService::RegisterRulesRegistry(
const std::string& event_name,
- scoped_ptr<RulesRegistry> rule_registry) {
+ scoped_refptr<RulesRegistry> rule_registry) {
DCHECK(rule_registries_.find(event_name) == rule_registries_.end());
rule_registries_[event_name] =
- make_linked_ptr(new InitializingRulesRegistry(rule_registry.Pass()));
+ make_scoped_refptr(new InitializingRulesRegistry(rule_registry));
}
-RulesRegistry* RulesRegistryService::GetRulesRegistry(
+scoped_refptr<RulesRegistry> RulesRegistryService::GetRulesRegistry(
const std::string& event_name) const {
RulesRegistryMap::const_iterator i = rule_registries_.find(event_name);
if (i == rule_registries_.end())
- return NULL;
- return i->second.get();
+ return scoped_refptr<RulesRegistry>();
+ return i->second;
+}
+
+void RulesRegistryService::SimulateExtensionUnloaded(
+ const std::string& extension_id) {
+ OnExtensionUnloaded(extension_id);
}
void RulesRegistryService::OnExtensionUnloaded(
const std::string& extension_id) {
RulesRegistryMap::iterator i;
- for (i = rule_registries_.begin(); i != rule_registries_.end(); ++i)
- i->second->OnExtensionUnloaded(extension_id);
+ for (i = rule_registries_.begin(); i != rule_registries_.end(); ++i) {
+ scoped_refptr<RulesRegistry> registry = i->second;
+ if (content::BrowserThread::CurrentlyOn(registry->GetOwnerThread())) {
+ registry->OnExtensionUnloaded(extension_id);
+ } else {
+ content::BrowserThread::PostTask(
+ registry->GetOwnerThread(), FROM_HERE,
+ base::Bind(&RulesRegistry::OnExtensionUnloaded, registry,
+ extension_id));
+ }
+ }
}
void RulesRegistryService::Observe(
@@ -54,8 +71,9 @@ void RulesRegistryService::Observe(
OnExtensionUnloaded(extension->id());
break;
}
- default:
- NOTREACHED();
+ default:
+ NOTREACHED();
+ break;
}
}

Powered by Google App Engine
This is Rietveld 408576698