Index: components/subresource_filter/content/browser/verified_ruleset_dealer.cc |
diff --git a/components/subresource_filter/content/browser/verified_ruleset_dealer.cc b/components/subresource_filter/content/browser/verified_ruleset_dealer.cc |
index cb6b79d72d7bf828f5bbb0a94c87120b57822c3f..fab4ae86807b277106d083aee981b5909efcbdc7 100644 |
--- a/components/subresource_filter/content/browser/verified_ruleset_dealer.cc |
+++ b/components/subresource_filter/content/browser/verified_ruleset_dealer.cc |
@@ -14,6 +14,8 @@ |
namespace subresource_filter { |
+// VerifiedRulesetDealer and its Handle. --------------------------------------- |
+ |
VerifiedRulesetDealer::VerifiedRulesetDealer() = default; |
VerifiedRulesetDealer::~VerifiedRulesetDealer() = default; |
@@ -78,4 +80,37 @@ void VerifiedRulesetDealer::Handle::SetRulesetFile(base::File file) { |
base::Unretained(dealer_.get()), base::Passed(&file))); |
} |
+// VerifiedRuleset and its Handle. --------------------------------------------- |
+ |
+VerifiedRuleset::VerifiedRuleset() { |
+ thread_checker_.DetachFromThread(); |
+} |
+ |
+VerifiedRuleset::~VerifiedRuleset() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+} |
+ |
+void VerifiedRuleset::Initialize(VerifiedRulesetDealer* dealer) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK(dealer); |
+ ruleset_ = dealer->GetRuleset(); |
+} |
+ |
+VerifiedRuleset::Handle::Handle(VerifiedRulesetDealer::Handle* dealer_handle) |
+ : task_runner_(dealer_handle->task_runner()), |
+ ruleset_(new VerifiedRuleset, base::OnTaskRunnerDeleter(task_runner_)) { |
+ dealer_handle->GetDealerAsync(base::Bind(&VerifiedRuleset::Initialize, |
+ base::Unretained(ruleset_.get()))); |
+} |
+ |
+VerifiedRuleset::Handle::~Handle() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+} |
+ |
+void VerifiedRuleset::Handle::GetRulesetAsync( |
+ base::Callback<void(VerifiedRuleset*)> callback) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ task_runner_->PostTask(FROM_HERE, base::Bind(callback, ruleset_.get())); |
+} |
+ |
} // namespace subresource_filter |