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

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: rebase Created 3 years, 8 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/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 4d728239ced8a6a02b0dd5b64e52c2020a1896e8..9650b4a71a0e60f6cf8c99f4f350940fab175328 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
@@ -102,18 +102,27 @@ SubresourceFilterSafeBrowsingActivationThrottle::
: NavigationThrottle(handle),
io_task_runner_(content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO)),
- database_client_(
- new SubresourceFilterSafeBrowsingActivationThrottle::SBDatabaseClient(
- std::move(database_manager),
- AsWeakPtr(),
- base::ThreadTaskRunnerHandle::Get()),
- base::OnTaskRunnerDeleter(io_task_runner_)) {}
+ database_client_(nullptr, base::OnTaskRunnerDeleter(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.
+ if (database_manager) {
+ std::unique_ptr<SBDatabaseClient, base::OnTaskRunnerDeleter>
+ database_client(
+ new SubresourceFilterSafeBrowsingActivationThrottle::
+ SBDatabaseClient(std::move(database_manager), AsWeakPtr(),
+ base::ThreadTaskRunnerHandle::Get()),
+ base::OnTaskRunnerDeleter(io_task_runner_));
+ database_client_ = std::move(database_client);
engedy 2017/05/02 18:21:54 nit: Does .reset() work for unique_ptr's with cust
Charlie Harrison 2017/05/02 20:08:49 Nope, but you can use the move equality operator.
+ }
+}
SubresourceFilterSafeBrowsingActivationThrottle::
~SubresourceFilterSafeBrowsingActivationThrottle() {}
content::NavigationThrottle::ThrottleCheckResult
SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() {
+ if (!database_client_)
+ return content::NavigationThrottle::PROCEED;
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&SubresourceFilterSafeBrowsingActivationThrottle::
SBDatabaseClient::CheckUrlOnIO,

Powered by Google App Engine
This is Rietveld 408576698