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

Side by Side Diff: extensions/browser/api/declarative/rules_registry.h

Issue 744663002: Fix WeakPtrFactory member ordering in extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated changes Created 6 years, 1 month 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
« no previous file with comments | « no previous file | extensions/browser/api/declarative/rules_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ 5 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__
6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ 6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 // The key that identifies the context in which these rules apply. 235 // The key that identifies the context in which these rules apply.
236 WebViewKey webview_key_; 236 WebViewKey webview_key_;
237 237
238 RulesDictionary rules_; 238 RulesDictionary rules_;
239 239
240 // Signaled when we have finished reading from storage for all extensions that 240 // Signaled when we have finished reading from storage for all extensions that
241 // are loaded on startup. 241 // are loaded on startup.
242 OneShotEvent ready_; 242 OneShotEvent ready_;
243 243
244 // The factory needs to be declared before |cache_delegate_|, so that it can
245 // produce a pointer as a construction argument for |cache_delegate_|.
246 base::WeakPtrFactory<RulesRegistry> weak_ptr_factory_;
247
248 // |cache_delegate_| is owned by the registry service. If |cache_delegate_| is
249 // NULL, then the storage functionality is disabled (this is used in tests).
250 // This registry cannot own |cache_delegate_| because during the time after
251 // rules registry service shuts down on UI thread, and the registry is
252 // destroyed on its thread, the use of the |cache_delegate_| would not be
253 // safe. The registry only ever associates with one RulesCacheDelegate
254 // instance.
255 base::WeakPtr<RulesCacheDelegate> cache_delegate_;
256
257 ProcessStateMap process_changed_rules_requested_; 244 ProcessStateMap process_changed_rules_requested_;
258 245
259 // Returns whether any existing rule is registered with identifier |rule_id| 246 // Returns whether any existing rule is registered with identifier |rule_id|
260 // for extension |extension_id|. 247 // for extension |extension_id|.
261 bool IsUniqueId(const std::string& extension_id, 248 bool IsUniqueId(const std::string& extension_id,
262 const std::string& rule_id) const; 249 const std::string& rule_id) const;
263 250
264 // Creates an ID that is unique within the scope of|extension_id|. 251 // Creates an ID that is unique within the scope of|extension_id|.
265 std::string GenerateUniqueId(const std::string& extension_id); 252 std::string GenerateUniqueId(const std::string& extension_id);
266 253
(...skipping 14 matching lines...) Expand all
281 268
282 // Same as RemoveUsedRuleIdentifiers but operates on all rules of 269 // Same as RemoveUsedRuleIdentifiers but operates on all rules of
283 // |extension_id|. 270 // |extension_id|.
284 void RemoveAllUsedRuleIdentifiers(const std::string& extension_id); 271 void RemoveAllUsedRuleIdentifiers(const std::string& extension_id);
285 272
286 typedef std::string RuleIdentifier; 273 typedef std::string RuleIdentifier;
287 typedef std::map<ExtensionId, std::set<RuleIdentifier> > RuleIdentifiersMap; 274 typedef std::map<ExtensionId, std::set<RuleIdentifier> > RuleIdentifiersMap;
288 RuleIdentifiersMap used_rule_identifiers_; 275 RuleIdentifiersMap used_rule_identifiers_;
289 int last_generated_rule_identifier_id_; 276 int last_generated_rule_identifier_id_;
290 277
278 // The factory needs to be declared before |cache_delegate_|, so that it can
279 // produce a pointer as a construction argument for |cache_delegate_|.
280 base::WeakPtrFactory<RulesRegistry> weak_ptr_factory_;
281
282 // |cache_delegate_| is owned by the registry service. If |cache_delegate_| is
283 // NULL, then the storage functionality is disabled (this is used in tests).
284 // This registry cannot own |cache_delegate_| because during the time after
285 // rules registry service shuts down on UI thread, and the registry is
286 // destroyed on its thread, the use of the |cache_delegate_| would not be
287 // safe. The registry only ever associates with one RulesCacheDelegate
288 // instance.
289 base::WeakPtr<RulesCacheDelegate> cache_delegate_;
290
291 DISALLOW_COPY_AND_ASSIGN(RulesRegistry); 291 DISALLOW_COPY_AND_ASSIGN(RulesRegistry);
292 }; 292 };
293 293
294 } // namespace extensions 294 } // namespace extensions
295 295
296 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__ 296 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_REGISTRY_H__
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/api/declarative/rules_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698