Chromium Code Reviews| Index: chrome/browser/extensions/api/declarative/rules_registry.h |
| diff --git a/chrome/browser/extensions/api/declarative/rules_registry.h b/chrome/browser/extensions/api/declarative/rules_registry.h |
| index c8546cc52659f6d5eb7b33b99554e3895f70b90e..f6ec6ea924160d3ac5632ad79696e94e99abd3cf 100644 |
| --- a/chrome/browser/extensions/api/declarative/rules_registry.h |
| +++ b/chrome/browser/extensions/api/declarative/rules_registry.h |
| @@ -44,21 +44,22 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { |
| enum Defaults { DEFAULT_PRIORITY = 100 }; |
| // After the RulesCacheDelegate object (the part of the registry which runs on |
| // the UI thread) is created, a pointer to it is passed to |*ui_part|. |
| - // If |log_storage_init_delay| is set, the delay caused by loading and |
| - // registering rules on initialization will be logged with UMA. |
| // In tests, |profile| and |ui_part| can be NULL (at the same time). In that |
| // case the storage functionality disabled (no RulesCacheDelegate object |
| - // created) and the |log_storage_init_delay| flag is ignored. |
| + // created). |
| RulesRegistry(Profile* profile, |
| const std::string& event_name, |
| - content::BrowserThread::ID owner_thread, |
| - bool log_storage_init_delay, |
| - scoped_ptr<RulesCacheDelegate>* ui_part); |
| + content::BrowserThread::ID owner_thread); |
| const OneShotEvent& ready() const { |
| return ready_; |
| } |
| + base::WeakPtr<RulesRegistry> GetWeakPtr() { |
|
Jeffrey Yasskin
2013/11/01 00:15:09
It's good to avoid passing WeakPtrs out of the cla
Fady Samuel
2013/11/01 15:13:39
I'll take care of this in a subsequent CL. Thanks!
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| + return weak_ptr_factory_.GetWeakPtr(); |
| + } |
| + |
| // RulesRegistry implementation: |
| // Registers |rules|, owned by |extension_id| to this RulesRegistry. |
| @@ -119,10 +120,17 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { |
| // and all rules of this extension need to be removed. |
| void OnExtensionUnloaded(const std::string& extension_id); |
| + // Assigns a RulesCacheDelegate to this RulesRegistry. This delegate is |
| + // responsible for storing the rules and retreiving them. |
| + bool SetCacheDelegate(base::WeakPtr<RulesCacheDelegate> cache_delegate); |
|
Jeffrey Yasskin
2013/11/01 00:15:09
I think it's safe to pass WeakPtrs by reference, w
Jeffrey Yasskin
2013/11/01 00:15:09
For functions that return bool, you need to say wh
Fady Samuel
2013/11/01 15:13:39
Done.
Fady Samuel
2013/11/01 15:13:39
Done.
|
| + |
| // Returns the number of entries in used_rule_identifiers_ for leak detection. |
| // Every ExtensionId counts as one entry, even if it contains no rules. |
| size_t GetNumberOfUsedRuleIdentifiersForTesting() const; |
| + // Returns the profile where the rules registry lives. |
| + Profile* profile() const { return profile_; } |
| + |
| // Returns the ID of the thread on which the rules registry lives. |
| // It is safe to call this function from any thread. |
| content::BrowserThread::ID owner_thread() const { return owner_thread_; } |
| @@ -174,11 +182,8 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { |
| // Process the callbacks once the registry gets ready. |
| void MarkReady(base::Time storage_init_time); |
| - // Deserialize the rules from the given Value object and add them to the |
| - // RulesRegistry. |
| - void DeserializeAndAddRules(const std::string& extension_id, |
| - scoped_ptr<base::Value> rules); |
| - |
| + // The profile to which this rules registry belongs. |
| + Profile* profile_; |
| // The ID of the thread on which the rules registry lives. |
| const content::BrowserThread::ID owner_thread_; |
| @@ -203,7 +208,7 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> { |
| // destroyed on its thread, the use of the |cache_delegate_| would not be |
| // safe. The registry only ever associates with one RulesCacheDelegate |
| // instance. |
| - const base::WeakPtr<RulesCacheDelegate> cache_delegate_; |
| + base::WeakPtr<RulesCacheDelegate> cache_delegate_; |
| ProcessChangedRulesState process_changed_rules_requested_; |