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

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: nparker review 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 cancel any outgoing requests when it is
shivanisha 2017/05/03 14:33:11 nit: 'cancel' mentioned twice
Charlie Harrison 2017/05/03 15:08:49 Done.
36 // destroyed.
37 class SubresourceFilterSafeBrowsingClient {
38 public:
39 struct CheckResult {
40 size_t request_id = 0;
41 safe_browsing::SBThreatType threat_type =
42 safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE;
43 safe_browsing::ThreatPatternType pattern_type =
44 safe_browsing::ThreatPatternType::NONE;
45 base::TimeDelta check_time;
46 bool finished = false;
47 };
48
49 SubresourceFilterSafeBrowsingClient(
50 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
51 database_manager,
52 base::WeakPtr<SubresourceFilterSafeBrowsingActivationThrottle> throttle,
53 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
54 scoped_refptr<base::SingleThreadTaskRunner> throttle_task_runner);
55
56 ~SubresourceFilterSafeBrowsingClient();
57
58 void CheckUrlOnIO(const GURL& url, size_t request_id);
59
60 void OnCheckBrowseUrlResult(
61 SubresourceFilterSafeBrowsingClientRequest* request,
62 const CheckResult& check_result);
63
64 private:
65 // This is stored as a map to allow for ergonomic deletion.
66 base::flat_map<SubresourceFilterSafeBrowsingClientRequest*,
67 std::unique_ptr<SubresourceFilterSafeBrowsingClientRequest>>
68 requests_;
69
70 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
71
72 base::WeakPtr<SubresourceFilterSafeBrowsingActivationThrottle> throttle_;
73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
74 scoped_refptr<base::SingleThreadTaskRunner> throttle_task_runner_;
75
76 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingClient);
77 };
78
79 } // namespace subresource_filter
80
81 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE _BROWSING_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698