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

Side by Side Diff: components/subresource_filter/content/browser/subresource_filter_safe_browsing_client.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_CLIENT_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BR OWSING_CLIENT_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11
12 #include "base/containers/flat_map.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h"
17 #include "components/safe_browsing_db/util.h"
18 #include "components/safe_browsing_db/v4_local_database_manager.h"
19
20 class GURL;
21
22 namespace base {
23 class SingleThreadTaskRunner;
24 } // namespace base
25
26 namespace subresource_filter {
27
28 class SubresourceFilterSafeBrowsingActivationThrottle;
29 class SubresourceFilterSafeBrowsingClientRequest;
30
31 // Created on the UI thread but used on the IO thread to communicate with the
32 // safe browsing service.
33 //
34 // The class is expected to accompany a single navigation, and can maintain many
35 // database requests. It will cancel any outgoing requests when it is destroyed.
36 class SubresourceFilterSafeBrowsingClient {
37 public:
38 struct CheckResult {
39 size_t request_id = 0;
40 safe_browsing::SBThreatType threat_type =
41 safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE;
42 safe_browsing::ThreatPatternType pattern_type =
43 safe_browsing::ThreatPatternType::NONE;
44 base::TimeDelta check_time;
45 bool finished = false;
46 };
47
48 SubresourceFilterSafeBrowsingClient(
49 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
50 database_manager,
51 base::WeakPtr<SubresourceFilterSafeBrowsingActivationThrottle> throttle,
52 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
53 scoped_refptr<base::SingleThreadTaskRunner> throttle_task_runner);
54
55 ~SubresourceFilterSafeBrowsingClient();
56
57 void CheckUrlOnIO(const GURL& url, size_t request_id);
58
59 void OnCheckBrowseUrlResult(
60 SubresourceFilterSafeBrowsingClientRequest* request,
61 const CheckResult& check_result);
62
63 private:
64 // This is stored as a map to allow for ergonomic deletion.
65 base::flat_map<SubresourceFilterSafeBrowsingClientRequest*,
66 std::unique_ptr<SubresourceFilterSafeBrowsingClientRequest>>
67 requests_;
68
69 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
70
71 base::WeakPtr<SubresourceFilterSafeBrowsingActivationThrottle> throttle_;
72 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
73 scoped_refptr<base::SingleThreadTaskRunner> throttle_task_runner_;
74
75 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingClient);
76 };
77
78 } // namespace subresource_filter
79
80 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698