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

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

Issue 2858483003: [subresource_filter] Move throttle insertion into the client (Closed)
Patch Set: fix rebase Created 3 years, 7 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
« no previous file with comments | « chrome/browser/subresource_filter/navigation_throttle_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc
diff --git a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc
index 6b6c4921c73957ce3f701d5a38e56f826e154bbd..a3c3e40bdbbf937074216cb8e089e216f9c52fc3 100644
--- a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc
+++ b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.cc
@@ -24,13 +24,16 @@ SubresourceFilterSafeBrowsingActivationThrottle::
scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
database_manager)
: NavigationThrottle(handle),
- database_manager_(std::move(database_manager)),
- io_task_runner_(io_task_runner),
- database_client_(new SubresourceFilterSafeBrowsingClient(
- database_manager_,
- AsWeakPtr(),
- io_task_runner,
- base::ThreadTaskRunnerHandle::Get()),
+ io_task_runner_(std::move(io_task_runner)),
+ // The throttle can be created without a valid database manager. If so, it
+ // becomes a pass-through throttle and should never defer.
+ database_client_(database_manager
+ ? new SubresourceFilterSafeBrowsingClient(
+ std::move(database_manager),
+ AsWeakPtr(),
+ io_task_runner_,
+ base::ThreadTaskRunnerHandle::Get())
+ : nullptr,
base::OnTaskRunnerDeleter(io_task_runner_)) {}
SubresourceFilterSafeBrowsingActivationThrottle::
@@ -52,6 +55,9 @@ SubresourceFilterSafeBrowsingActivationThrottle::WillRedirectRequest() {
content::NavigationThrottle::ThrottleCheckResult
SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() {
+ if (!database_client_)
+ return content::NavigationThrottle::PROCEED;
+
// No need to defer the navigation if the check already happened.
if (check_results_.back().finished) {
NotifyResult();
@@ -82,6 +88,8 @@ void SubresourceFilterSafeBrowsingActivationThrottle::OnCheckUrlResultOnUI(
}
void SubresourceFilterSafeBrowsingActivationThrottle::CheckCurrentUrl() {
+ if (!database_client_)
+ return;
check_results_.emplace_back();
size_t id = check_results_.size() - 1;
io_task_runner_->PostTask(
« no previous file with comments | « chrome/browser/subresource_filter/navigation_throttle_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698