Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <map> | |
| 11 #include <memory> | |
| 12 | |
| 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 | |
| 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> ui_task_runner); | |
|
Nathan Parker
2017/05/03 00:00:42
The args here are different than in the .cc file.
Charlie Harrison
2017/05/03 01:20:30
Renamed the task runner to throttle_task_runner. A
| |
| 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 std::map<SubresourceFilterSafeBrowsingClientRequest*, | |
|
Nathan Parker
2017/05/03 00:00:42
nit: flat_map would likely have better RAM/CPU per
Charlie Harrison
2017/05/03 01:20:30
Good call, done.
| |
| 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_ | |
| OLD | NEW |