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

Unified Diff: components/subresource_filter/content/browser/async_document_subresource_filter.h

Issue 2691423006: Introduce the ThrottleManager (Closed)
Patch Set: engedy review Created 3 years, 9 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/browser/async_document_subresource_filter.h
diff --git a/components/subresource_filter/content/browser/async_document_subresource_filter.h b/components/subresource_filter/content/browser/async_document_subresource_filter.h
index 3d4c9dd3f33ed745269e7be226707cc94ea2b57a..b406077544178825b8105a5bfb2526a655a6f263 100644
--- a/components/subresource_filter/content/browser/async_document_subresource_filter.h
+++ b/components/subresource_filter/content/browser/async_document_subresource_filter.h
@@ -82,14 +82,10 @@ class AsyncDocumentSubresourceFilter {
// with the current thread. If MemoryMappedRuleset is not present or
// malformed, then a default ActivationState is reported (with ActivationLevel
// equal to DISABLED).
- //
- // The |first_disallowed_load_callback|, if it is non-null, is invoked on the
- // first ReportDisallowedLoad() call.
AsyncDocumentSubresourceFilter(
VerifiedRuleset::Handle* ruleset_handle,
InitializationParams params,
- base::Callback<void(ActivationState)> activation_state_callback,
- base::OnceClosure first_disallowed_load_callback);
+ base::Callback<void(ActivationState)> activation_state_callback);
~AsyncDocumentSubresourceFilter();
@@ -104,14 +100,33 @@ class AsyncDocumentSubresourceFilter {
// |task_runner|.
void ReportDisallowedLoad();
+ // Must be called after activation state computation is finished.
+ const ActivationState& activation_state() const {
+ return activation_state_.value();
+ }
+
+ // The |first_disallowed_load_callback|, if it is non-null, is invoked on the
+ // first ReportDisallowedLoad() call.
+ void set_first_disallowed_load_callback(base::OnceClosure callback) {
+ first_disallowed_load_callback_ = std::move(callback);
+ }
+
private:
+ void OnActivateStateCalculated(
+ base::Callback<void(ActivationState)> activation_state_callback,
+ ActivationState activation_state);
+
// Note: Raw pointer, |core_| already holds a reference to |task_runner_|.
base::SequencedTaskRunner* task_runner_;
std::unique_ptr<Core, base::OnTaskRunnerDeleter> core_;
base::OnceClosure first_disallowed_load_callback_;
+ base::Optional<ActivationState> activation_state_;
+
base::ThreadChecker thread_checker_;
+ base::WeakPtrFactory<AsyncDocumentSubresourceFilter> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AsyncDocumentSubresourceFilter);
};

Powered by Google App Engine
This is Rietveld 408576698