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

Side by Side Diff: components/safe_browsing_db/remote_database_manager.cc

Issue 2838163002: Use base::flat_set<> rather than std::set<> for ResourceType set (Closed)
Patch Set: Reserve the vector size upfront to reduce allocations Created 3 years, 8 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
« no previous file with comments | « components/safe_browsing_db/remote_database_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/safe_browsing_db/remote_database_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698