OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "components/safe_browsing_db/remote_database_manager.h" | 5 #include "components/safe_browsing_db/remote_database_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // CancelCheck() will delete *this. | 92 // CancelCheck() will delete *this. |
93 db_manager_->CancelCheck(client_); | 93 db_manager_->CancelCheck(client_); |
94 } | 94 } |
95 | 95 |
96 // | 96 // |
97 // RemoteSafeBrowsingDatabaseManager methods | 97 // RemoteSafeBrowsingDatabaseManager methods |
98 // | 98 // |
99 | 99 |
100 // TODO(nparker): Add more tests for this class | 100 // TODO(nparker): Add more tests for this class |
101 RemoteSafeBrowsingDatabaseManager::RemoteSafeBrowsingDatabaseManager() { | 101 RemoteSafeBrowsingDatabaseManager::RemoteSafeBrowsingDatabaseManager() { |
| 102 // Avoid memory allocations growing the underlying vector. Although this |
| 103 // usually wastes a bit of memory, it will still be less than the default |
| 104 // vector allocation strategy. |
| 105 resource_types_to_check_.reserve(content::RESOURCE_TYPE_LAST_TYPE + 1); |
102 // Decide which resource types to check. These two are the minimum. | 106 // Decide which resource types to check. These two are the minimum. |
103 resource_types_to_check_.insert(content::RESOURCE_TYPE_MAIN_FRAME); | 107 resource_types_to_check_.insert(content::RESOURCE_TYPE_MAIN_FRAME); |
104 resource_types_to_check_.insert(content::RESOURCE_TYPE_SUB_FRAME); | 108 resource_types_to_check_.insert(content::RESOURCE_TYPE_SUB_FRAME); |
105 | 109 |
106 // The param is expected to be a comma-separated list of ints | 110 // The param is expected to be a comma-separated list of ints |
107 // corresponding to the enum types. We're keeping this finch | 111 // corresponding to the enum types. We're keeping this finch |
108 // control around so we can add back types if they later become dangerous. | 112 // control around so we can add back types if they later become dangerous. |
109 const std::string ints_str = variations::GetVariationParamValue( | 113 const std::string ints_str = variations::GetVariationParamValue( |
110 kAndroidFieldExperiment, kAndroidTypesToCheckParam); | 114 kAndroidFieldExperiment, kAndroidTypesToCheckParam); |
111 if (ints_str.empty()) { | 115 if (ints_str.empty()) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 for (auto* req : to_callback) { | 304 for (auto* req : to_callback) { |
301 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url(); | 305 DVLOG(1) << "Stopping: Invoking unfinished req for URL " << req->url(); |
302 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata()); | 306 req->OnRequestDone(SB_THREAT_TYPE_SAFE, ThreatMetadata()); |
303 } | 307 } |
304 enabled_ = false; | 308 enabled_ = false; |
305 | 309 |
306 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown); | 310 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown); |
307 } | 311 } |
308 | 312 |
309 } // namespace safe_browsing | 313 } // namespace safe_browsing |
OLD | NEW |