OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/api/declarative/rules_registry_service.h" | 5 #include "extensions/browser/api/declarative/rules_registry_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 browser_context_, webview_key, web_request_rules_registry)); | 88 browser_context_, webview_key, web_request_rules_registry)); |
89 | 89 |
90 // Only create a ContentRulesRegistry for regular pages and not webviews. | 90 // Only create a ContentRulesRegistry for regular pages and not webviews. |
91 if (!IsWebView(webview_key)) { | 91 if (!IsWebView(webview_key)) { |
92 RulesCacheDelegate* content_rules_cache_delegate = | 92 RulesCacheDelegate* content_rules_cache_delegate = |
93 new RulesCacheDelegate(false /*log_storage_init_delay*/); | 93 new RulesCacheDelegate(false /*log_storage_init_delay*/); |
94 cache_delegates_.push_back(content_rules_cache_delegate); | 94 cache_delegates_.push_back(content_rules_cache_delegate); |
95 scoped_refptr<ContentRulesRegistry> content_rules_registry = | 95 scoped_refptr<ContentRulesRegistry> content_rules_registry = |
96 ExtensionsAPIClient::Get()->CreateContentRulesRegistry( | 96 ExtensionsAPIClient::Get()->CreateContentRulesRegistry( |
97 browser_context_, content_rules_cache_delegate); | 97 browser_context_, content_rules_cache_delegate); |
98 if (content_rules_registry.get() != nullptr) { | 98 RegisterRulesRegistry(content_rules_registry); |
99 RegisterRulesRegistry(content_rules_registry); | 99 content_rules_registry_ = content_rules_registry.get(); |
100 content_rules_registry_ = content_rules_registry.get(); | |
101 } | |
102 } | 100 } |
103 } | 101 } |
104 | 102 |
105 void RulesRegistryService::Shutdown() { | 103 void RulesRegistryService::Shutdown() { |
106 // Release the references to all registries. This would happen soon during | 104 // Release the references to all registries. This would happen soon during |
107 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to | 105 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to |
108 // be the last to reference the WebRequestRulesRegistry objects, so that | 106 // be the last to reference the WebRequestRulesRegistry objects, so that |
109 // the posted task below causes their destruction on the IO thread, not on UI | 107 // the posted task below causes their destruction on the IO thread, not on UI |
110 // where the destruction of |*this| takes place. | 108 // where the destruction of |*this| takes place. |
111 // TODO(vabr): Remove once http://crbug.com/218451#c6 gets addressed. | 109 // TODO(vabr): Remove once http://crbug.com/218451#c6 gets addressed. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 const content::NotificationSource& source, | 225 const content::NotificationSource& source, |
228 const content::NotificationDetails& details) { | 226 const content::NotificationDetails& details) { |
229 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type); | 227 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type); |
230 | 228 |
231 content::RenderProcessHost* process = | 229 content::RenderProcessHost* process = |
232 content::Source<content::RenderProcessHost>(source).ptr(); | 230 content::Source<content::RenderProcessHost>(source).ptr(); |
233 RemoveWebViewRulesRegistries(process->GetID()); | 231 RemoveWebViewRulesRegistries(process->GetID()); |
234 } | 232 } |
235 | 233 |
236 } // namespace extensions | 234 } // namespace extensions |
OLD | NEW |