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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_service.cc

Issue 590573002: Remove ContentRulesRegistry dependence from RulesRegistryService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
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 "chrome/browser/extensions/api/declarative/rules_registry_service.h" 5 #include "chrome/browser/extensions/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"
11 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
12 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 11 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
13 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/notification_details.h" 13 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
19 #include "extensions/browser/api/declarative/rules_cache_delegate.h" 18 #include "extensions/browser/api/declarative/rules_cache_delegate.h"
20 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 19 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
21 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h" 20 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h"
21 #include "extensions/browser/api/extensions_api_client.h"
22 #include "extensions/browser/extension_registry.h" 22 #include "extensions/browser/extension_registry.h"
23 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 namespace { 27 namespace {
28 28
29 // Registers |web_request_rules_registry| on the IO thread. 29 // Registers |web_request_rules_registry| on the IO thread.
30 void RegisterToExtensionWebRequestEventRouterOnIO( 30 void RegisterToExtensionWebRequestEventRouterOnIO(
31 content::BrowserContext* browser_context, 31 content::BrowserContext* browser_context,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 content::BrowserThread::PostTask( 84 content::BrowserThread::PostTask(
85 content::BrowserThread::IO, FROM_HERE, 85 content::BrowserThread::IO, FROM_HERE,
86 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, 86 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO,
87 browser_context_, webview_key, web_request_rules_registry)); 87 browser_context_, webview_key, web_request_rules_registry));
88 88
89 // Only create a ContentRulesRegistry for regular pages and not webviews. 89 // Only create a ContentRulesRegistry for regular pages and not webviews.
90 if (!IsWebView(webview_key)) { 90 if (!IsWebView(webview_key)) {
91 RulesCacheDelegate* content_rules_cache_delegate = 91 RulesCacheDelegate* content_rules_cache_delegate =
92 new RulesCacheDelegate(false /*log_storage_init_delay*/); 92 new RulesCacheDelegate(false /*log_storage_init_delay*/);
93 cache_delegates_.push_back(content_rules_cache_delegate); 93 cache_delegates_.push_back(content_rules_cache_delegate);
94 scoped_refptr<ContentRulesRegistry> content_rules_registry( 94 scoped_refptr<RulesRegistry> content_rules_registry =
95 new ContentRulesRegistry(browser_context_, 95 ExtensionsAPIClient::Get()->GetContentRulesRegistry(
96 content_rules_cache_delegate)); 96 browser_context_, content_rules_cache_delegate);
97 RegisterRulesRegistry(content_rules_registry); 97 RegisterRulesRegistry(content_rules_registry);
98 content_rules_registry_ = content_rules_registry.get(); 98 content_rules_registry_ =
99 ExtensionsAPIClient::Get()->ConvertToContentRulesRegistryPtr(
100 content_rules_registry.get());
99 } 101 }
100 } 102 }
101 103
102 void RulesRegistryService::Shutdown() { 104 void RulesRegistryService::Shutdown() {
103 // Release the references to all registries. This would happen soon during 105 // Release the references to all registries. This would happen soon during
104 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to 106 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to
105 // be the last to reference the WebRequestRulesRegistry objects, so that 107 // be the last to reference the WebRequestRulesRegistry objects, so that
106 // the posted task below causes their destruction on the IO thread, not on UI 108 // the posted task below causes their destruction on the IO thread, not on UI
107 // where the destruction of |*this| takes place. 109 // where the destruction of |*this| takes place.
108 // TODO(vabr): Remove once http://crbug.com/218451#c6 gets addressed. 110 // TODO(vabr): Remove once http://crbug.com/218451#c6 gets addressed.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 const content::NotificationSource& source, 226 const content::NotificationSource& source,
225 const content::NotificationDetails& details) { 227 const content::NotificationDetails& details) {
226 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type); 228 DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type);
227 229
228 content::RenderProcessHost* process = 230 content::RenderProcessHost* process =
229 content::Source<content::RenderProcessHost>(source).ptr(); 231 content::Source<content::RenderProcessHost>(source).ptr();
230 RemoveWebViewRulesRegistries(process->GetID()); 232 RemoveWebViewRulesRegistries(process->GetID());
231 } 233 }
232 234
233 } // namespace extensions 235 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698