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 "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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry. h" | 10 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry. h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 scoped_refptr<ContentRulesRegistry> content_rules_registry( | 57 scoped_refptr<ContentRulesRegistry> content_rules_registry( |
58 new ContentRulesRegistry(profile_, &ui_part)); | 58 new ContentRulesRegistry(profile_, &ui_part)); |
59 ui_parts_of_registries_.push_back(ui_part.release()); | 59 ui_parts_of_registries_.push_back(ui_part.release()); |
60 | 60 |
61 RegisterRulesRegistry(content_rules_registry); | 61 RegisterRulesRegistry(content_rules_registry); |
62 content_rules_registry_ = content_rules_registry.get(); | 62 content_rules_registry_ = content_rules_registry.get(); |
63 #endif // defined(ENABLE_EXTENSIONS) | 63 #endif // defined(ENABLE_EXTENSIONS) |
64 } | 64 } |
65 | 65 |
66 void RulesRegistryService::Shutdown() { | 66 void RulesRegistryService::Shutdown() { |
67 // Release the references to all registries. This would happen soon during | |
68 // destruction of |*this|, but we need the ExtensionWebRequestEventRouter to | |
69 // be the last to reference the WebRequestRulesRegistry objects, so that | |
70 // the posted task below causes their destruction on the IO thread, not on UI | |
71 // where the destruction of |*this| takes place. | |
72 // TODO(vabr): Remove once http://crbug.com/218451#c6 gets addressed. | |
73 rule_registries_.clear(); | |
67 content::BrowserThread::PostTask( | 74 content::BrowserThread::PostTask( |
68 content::BrowserThread::IO, FROM_HERE, | 75 content::BrowserThread::IO, FROM_HERE, |
69 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, | 76 base::Bind(&RegisterToExtensionWebRequestEventRouterOnIO, |
70 profile_, scoped_refptr<WebRequestRulesRegistry>(NULL))); | 77 profile_, scoped_refptr<WebRequestRulesRegistry>(NULL))); |
battre
2013/06/03 10:22:15
Wouldn't the correct way of solving this be:
void
vabr (Chromium)
2013/06/03 10:45:45
Could you please be more specific about why you pr
battre
2013/06/03 11:42:42
On second thought, your solution is equally good.
Jeffrey Yasskin
2013/06/03 16:12:16
The above code is subtly incorrect because it's po
| |
71 } | 78 } |
72 | 79 |
73 void RulesRegistryService::RegisterRulesRegistry( | 80 void RulesRegistryService::RegisterRulesRegistry( |
74 scoped_refptr<RulesRegistry> rule_registry) { | 81 scoped_refptr<RulesRegistry> rule_registry) { |
75 const std::string event_name(rule_registry->event_name()); | 82 const std::string event_name(rule_registry->event_name()); |
76 DCHECK(rule_registries_.find(event_name) == rule_registries_.end()); | 83 DCHECK(rule_registries_.find(event_name) == rule_registries_.end()); |
77 rule_registries_[event_name] = | 84 rule_registries_[event_name] = |
78 make_scoped_refptr(new InitializingRulesRegistry(rule_registry)); | 85 make_scoped_refptr(new InitializingRulesRegistry(rule_registry)); |
79 } | 86 } |
80 | 87 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 OnExtensionUnloaded(extension->id()); | 126 OnExtensionUnloaded(extension->id()); |
120 break; | 127 break; |
121 } | 128 } |
122 default: | 129 default: |
123 NOTREACHED(); | 130 NOTREACHED(); |
124 break; | 131 break; |
125 } | 132 } |
126 } | 133 } |
127 | 134 |
128 } // namespace extensions | 135 } // namespace extensions |
OLD | NEW |