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

Unified Diff: components/subresource_filter/content/common/ruleset_dealer.h

Issue 2661433002: Introduce VerifiedRulesetDealer and its async Handle. (Closed)
Patch Set: Refactor tests. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/content/common/ruleset_dealer.h
diff --git a/components/subresource_filter/content/common/ruleset_dealer.h b/components/subresource_filter/content/common/ruleset_dealer.h
index a467fcd97049555f3b51eb62903a977d96df5daa..593415418c53a0150990a566e78fb42eb7a0e08f 100644
--- a/components/subresource_filter/content/common/ruleset_dealer.h
+++ b/components/subresource_filter/content/common/ruleset_dealer.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/threading/non_thread_safe.h"
namespace subresource_filter {
@@ -29,29 +30,29 @@ class MemoryMappedRuleset;
// they will use the same, cached, MemoryMappedRuleset instance, and will
// not call mmap() multiple times.
//
-class RulesetDealer {
+class RulesetDealer : protected base::NonThreadSafe {
public:
RulesetDealer();
virtual ~RulesetDealer();
// Sets the |ruleset_file| to memory map and distribute from now on.
- void SetRulesetFile(base::File ruleset_file);
+ virtual void SetRulesetFile(base::File ruleset_file);
- // Returns whether a subsequent call to GetRuleset() would return a non-null
- // ruleset, but without memory mapping the ruleset.
- bool IsRulesetAvailable() const;
+ // Returns whether |this| dealer has a ruleset file to read from. Does not
+ // interact with the file system.
+ bool IsRulesetFileAvailable() const;
// Returns the set |ruleset_file|. Normally, the same instance is used by all
// call sites in a given process. That intance is mapped lazily and umapped
// eagerly as soon as the last reference to it is dropped.
- scoped_refptr<const MemoryMappedRuleset> GetRuleset();
+ virtual scoped_refptr<const MemoryMappedRuleset> GetRuleset();
+
+ // For testing only.
+ bool has_cached_ruleset() const { return !!weak_cached_ruleset_.get(); }
private:
friend class SubresourceFilterRulesetDealerTest;
- // Exposed for testing only.
- bool has_cached_ruleset() const { return !!weak_cached_ruleset_.get(); }
-
base::File ruleset_file_;
base::WeakPtr<MemoryMappedRuleset> weak_cached_ruleset_;

Powered by Google App Engine
This is Rietveld 408576698