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

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

Issue 2691423006: Introduce the ThrottleManager (Closed)
Patch Set: rebase 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.cc
diff --git a/components/subresource_filter/content/browser/async_document_subresource_filter.cc b/components/subresource_filter/content/browser/async_document_subresource_filter.cc
index 099eec14aae030b3777a73cb64bcdb274ad11387..04aa69a5bfeb7071895e8cf37e71b568d686ec75 100644
--- a/components/subresource_filter/content/browser/async_document_subresource_filter.cc
+++ b/components/subresource_filter/content/browser/async_document_subresource_filter.cc
@@ -58,7 +58,8 @@ AsyncDocumentSubresourceFilter::AsyncDocumentSubresourceFilter(
: task_runner_(ruleset_handle->task_runner()),
core_(new Core(), base::OnTaskRunnerDeleter(task_runner_)),
first_disallowed_load_callback_(
- std::move(first_disallowed_load_callback)) {
+ std::move(first_disallowed_load_callback)),
+ weak_ptr_factory_(this) {
DCHECK_NE(ActivationLevel::DISABLED,
params.parent_activation_state.activation_level);
@@ -70,13 +71,22 @@ AsyncDocumentSubresourceFilter::AsyncDocumentSubresourceFilter(
task_runner_, FROM_HERE,
base::Bind(&Core::Initialize, base::Unretained(core_.get()),
base::Passed(&params), ruleset_handle->ruleset_.get()),
- std::move(activation_state_callback));
+ base::Bind(&AsyncDocumentSubresourceFilter::OnActivateStateCalculated,
+ weak_ptr_factory_.GetWeakPtr(),
+ std::move(activation_state_callback)));
}
AsyncDocumentSubresourceFilter::~AsyncDocumentSubresourceFilter() {
DCHECK(thread_checker_.CalledOnValidThread());
}
+void AsyncDocumentSubresourceFilter::OnActivateStateCalculated(
+ base::Callback<void(ActivationState)> activation_state_callback,
+ ActivationState activation_state) {
+ activation_state_.emplace(activation_state);
engedy 2017/03/10 17:36:20 nit: Looks like this is equivalent to: activation
Charlie Harrison 2017/03/14 23:18:31 Done.
+ activation_state_callback.Run(activation_state);
+}
+
void AsyncDocumentSubresourceFilter::GetLoadPolicyForSubdocument(
const GURL& subdocument_url,
LoadPolicyCallback result_callback) {

Powered by Google App Engine
This is Rietveld 408576698