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

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

Issue 10695130: Fix a memory leak in RulesRegistryStorageDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry. h" 9 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry. h"
10 #include "chrome/browser/extensions/api/declarative/rules_registry_storage_deleg ate.h" 10 #include "chrome/browser/extensions/api/declarative/rules_registry_storage_deleg ate.h"
(...skipping 25 matching lines...) Expand all
36 } // namespace 36 } // namespace
37 37
38 RulesRegistryService::RulesRegistryService(Profile* profile) 38 RulesRegistryService::RulesRegistryService(Profile* profile)
39 : profile_(profile) { 39 : profile_(profile) {
40 if (profile) { 40 if (profile) {
41 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 41 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
42 content::Source<Profile>(profile)); 42 content::Source<Profile>(profile));
43 } 43 }
44 } 44 }
45 45
46 RulesRegistryService::~RulesRegistryService() {} 46 RulesRegistryService::~RulesRegistryService() {
47 for (size_t i = 0; i < delegates_.size(); ++i)
48 delegates_[i]->CleanupOnUIThread();
49 }
47 50
48 void RulesRegistryService::RegisterDefaultRulesRegistries() { 51 void RulesRegistryService::RegisterDefaultRulesRegistries() {
49 RulesRegistryStorageDelegate* delegate = new RulesRegistryStorageDelegate(); 52 RulesRegistryStorageDelegate* delegate = new RulesRegistryStorageDelegate();
50 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry( 53 scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry(
51 new WebRequestRulesRegistry(profile_, delegate)); 54 new WebRequestRulesRegistry(profile_, delegate));
52 delegate->Init(profile_, web_request_rules_registry, 55 delegate->InitOnUIThread(profile_, web_request_rules_registry,
53 GetDeclarativeRuleStorageKey( 56 GetDeclarativeRuleStorageKey(
54 declarative_webrequest_constants::kOnRequest)); 57 declarative_webrequest_constants::kOnRequest));
58 delegates_.push_back(delegate);
55 59
56 RegisterRulesRegistry(declarative_webrequest_constants::kOnRequest, 60 RegisterRulesRegistry(declarative_webrequest_constants::kOnRequest,
57 web_request_rules_registry); 61 web_request_rules_registry);
58 content::BrowserThread::PostTask( 62 content::BrowserThread::PostTask(
59 content::BrowserThread::IO, FROM_HERE, 63 content::BrowserThread::IO, FROM_HERE,
60 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, 64 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO,
61 web_request_rules_registry)); 65 web_request_rules_registry));
62 } 66 }
63 67
64 void RulesRegistryService::Shutdown() { 68 void RulesRegistryService::Shutdown() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 OnExtensionUnloaded(extension->id()); 120 OnExtensionUnloaded(extension->id());
117 break; 121 break;
118 } 122 }
119 default: 123 default:
120 NOTREACHED(); 124 NOTREACHED();
121 break; 125 break;
122 } 126 }
123 } 127 }
124 128
125 } // namespace extensions 129 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698