Index: chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc b/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
index 41e51a191375ad319258cf57c5fe32b625d9982a..f256a9cf03008a3e34c18d5ba6d316cfea0a0343 100644 |
--- a/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
+++ b/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
@@ -141,6 +141,7 @@ void RulesRegistryStorageDelegate::InitOnUIThread( |
void RulesRegistryStorageDelegate::CleanupOnUIThread() { |
// The registrar must be deleted on the UI thread. |
inner_->registrar_.reset(); |
+ inner_->profile_ = NULL; // no longer safe to use. |
} |
bool RulesRegistryStorageDelegate::IsReady() { |
@@ -229,6 +230,9 @@ void RulesRegistryStorageDelegate::Inner::Observe( |
void RulesRegistryStorageDelegate::Inner::ReadFromStorage( |
const std::string& extension_id) { |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ if (!profile_) |
+ return; |
+ |
extensions::StateStore* store = ExtensionSystem::Get(profile_)->state_store(); |
if (store) { |
waiting_for_extensions_.insert(extension_id); |
@@ -252,6 +256,9 @@ void RulesRegistryStorageDelegate::Inner::ReadFromStorageCallback( |
void RulesRegistryStorageDelegate::Inner::WriteToStorage( |
const std::string& extension_id, scoped_ptr<base::Value> value) { |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ if (!profile_) |
+ return; |
+ |
StateStore* store = ExtensionSystem::Get(profile_)->state_store(); |
if (store) |
store->SetExtensionValue(extension_id, storage_key_, value.Pass()); |