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

Side by Side Diff: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle.h

Issue 2834543003: [subresource_filter] SB throttle can send multiple speculative requests. (Closed)
Patch Set: rebase on #468982 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_ACTIVATION_THROTTLE_H_
7 7
8 #include <stddef.h>
9
10 #include <memory>
11 #include <vector>
12
8 #include "base/macros.h" 13 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
11 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/time/time.h"
12 #include "components/safe_browsing_db/database_manager.h" 18 #include "components/safe_browsing_db/database_manager.h"
19 #include "components/subresource_filter/content/browser/subresource_filter_safe_ browsing_client.h"
13 #include "content/public/browser/navigation_throttle.h" 20 #include "content/public/browser/navigation_throttle.h"
14 #include "url/gurl.h"
15 21
16 namespace subresource_filter { 22 namespace subresource_filter {
17 23
18 // Navigation throttle responsible for activating subresource filtering on page 24 // Navigation throttle responsible for activating subresource filtering on page
19 // loads that match the SUBRESOURCE_FILTER Safe Browsing list. 25 // loads that match the SUBRESOURCE_FILTER Safe Browsing list.
20 class SubresourceFilterSafeBrowsingActivationThrottle 26 class SubresourceFilterSafeBrowsingActivationThrottle
21 : public content::NavigationThrottle, 27 : public content::NavigationThrottle,
22 public base::SupportsWeakPtr< 28 public base::SupportsWeakPtr<
23 SubresourceFilterSafeBrowsingActivationThrottle> { 29 SubresourceFilterSafeBrowsingActivationThrottle> {
24 public: 30 public:
25 SubresourceFilterSafeBrowsingActivationThrottle( 31 SubresourceFilterSafeBrowsingActivationThrottle(
26 content::NavigationHandle* handle, 32 content::NavigationHandle* handle,
33 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
27 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> 34 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
28 database_manager); 35 database_manager);
29 36
30 ~SubresourceFilterSafeBrowsingActivationThrottle() override; 37 ~SubresourceFilterSafeBrowsingActivationThrottle() override;
31 38
32 // content::NavigationThrottle: 39 // content::NavigationThrottle:
40 content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
41 content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest()
42 override;
33 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() 43 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
34 override; 44 override;
35 const char* GetNameForLogging() override; 45 const char* GetNameForLogging() override;
36 46
37 void OnCheckUrlResultOnUI(const GURL& url, 47 void OnCheckUrlResultOnUI(
38 safe_browsing::SBThreatType threat_type, 48 const SubresourceFilterSafeBrowsingClient::CheckResult& result);
39 safe_browsing::ThreatPatternType pattern_type);
40 49
41 private: 50 private:
42 class SBDatabaseClient; 51 void CheckCurrentUrl();
52 void NotifyResult();
53 std::vector<SubresourceFilterSafeBrowsingClient::CheckResult> check_results_;
43 54
55 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
44 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 56 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
45 std::unique_ptr<SBDatabaseClient, base::OnTaskRunnerDeleter> database_client_; 57
58 std::unique_ptr<SubresourceFilterSafeBrowsingClient,
59 base::OnTaskRunnerDeleter>
60 database_client_;
61
62 // Set to TimeTicks::Now() when the navigation is deferred in
63 // WillProcessResponse. If deferral was not necessary, will remain null.
64 base::TimeTicks defer_time_;
46 65
47 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottle); 66 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottle);
48 }; 67 };
49 68
50 } // namespace subresource_filter 69 } // namespace subresource_filter
51 70
52 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_ACTIVATION_THROTTLE_H_ 71 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_ACTIVATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698