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

Side by Side Diff: components/safe_browsing_db/v4_local_database_manager.h

Issue 2626153003: [M56] Have a list of pending checks instead of pending clients (Closed)
Patch Set: Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
7 7
8 // A class that provides the interface between the SafeBrowsing protocol manager 8 // A class that provides the interface between the SafeBrowsing protocol manager
9 // and database that holds the downloaded updates. 9 // and database that holds the downloaded updates.
10 10
11 #include <memory> 11 #include <memory>
12 #include <unordered_set>
12 13
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "components/safe_browsing_db/database_manager.h" 15 #include "components/safe_browsing_db/database_manager.h"
15 #include "components/safe_browsing_db/hit_report.h" 16 #include "components/safe_browsing_db/hit_report.h"
16 #include "components/safe_browsing_db/v4_database.h" 17 #include "components/safe_browsing_db/v4_database.h"
17 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" 18 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h"
18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 19 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
19 #include "components/safe_browsing_db/v4_update_protocol_manager.h" 20 #include "components/safe_browsing_db/v4_update_protocol_manager.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 // The stores/lists to always get full hashes for, regardless of which store 157 // The stores/lists to always get full hashes for, regardless of which store
157 // the hash prefix matched. 158 // the hash prefix matched.
158 StoresToCheck GetStoresForFullHashRequests() override; 159 StoresToCheck GetStoresForFullHashRequests() override;
159 160
160 private: 161 private:
161 friend class V4LocalDatabaseManagerTest; 162 friend class V4LocalDatabaseManagerTest;
162 FRIEND_TEST_ALL_PREFIXES(V4LocalDatabaseManagerTest, 163 FRIEND_TEST_ALL_PREFIXES(V4LocalDatabaseManagerTest,
163 TestGetSeverestThreatTypeAndMetadata); 164 TestGetSeverestThreatTypeAndMetadata);
164 165
165 // The set of clients awaiting a full hash response. It is used for tracking 166 // The checks awaiting a full hash response from SafeBrowsing service.
166 // which clients have cancelled their outstanding request. 167 typedef std::unordered_set<const PendingCheck*> PendingChecks;
167 typedef std::unordered_set<const Client*> PendingClients;
168 168
169 // Called when all the stores managed by the database have been read from 169 // Called when all the stores managed by the database have been read from
170 // disk after startup and the database is ready for checking resource 170 // disk after startup and the database is ready for checking resource
171 // reputation. 171 // reputation.
172 void DatabaseReadyForChecks(std::unique_ptr<V4Database> v4_database); 172 void DatabaseReadyForChecks(std::unique_ptr<V4Database> v4_database);
173 173
174 // Called when all the stores managed by the database have been verified for 174 // Called when all the stores managed by the database have been verified for
175 // checksum correctness after startup and the database is ready for applying 175 // checksum correctness after startup and the database is ready for applying
176 // updates. 176 // updates.
177 void DatabaseReadyForUpdates( 177 void DatabaseReadyForUpdates(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 // Whether the service is running. 265 // Whether the service is running.
266 bool enabled_; 266 bool enabled_;
267 267
268 // The list of stores to manage (for hash prefixes and full hashes). Each 268 // The list of stores to manage (for hash prefixes and full hashes). Each
269 // element contains the identifier for the store, the corresponding 269 // element contains the identifier for the store, the corresponding
270 // SBThreatType, whether to fetch hash prefixes for that store, and the 270 // SBThreatType, whether to fetch hash prefixes for that store, and the
271 // name of the file on disk that would contain the prefixes, if applicable. 271 // name of the file on disk that would contain the prefixes, if applicable.
272 ListInfos list_infos_; 272 ListInfos list_infos_;
273 273
274 // The set of clients that are waiting for a full hash response from the 274 // The checks awaiting for a full hash response from the SafeBrowsing service.
275 // SafeBrowsing service. 275 PendingChecks pending_checks_;
276 PendingClients pending_clients_;
277 276
278 // The checks that need to be scheduled when the database becomes ready for 277 // The checks that need to be scheduled when the database becomes ready for
279 // use. 278 // use.
280 QueuedChecks queued_checks_; 279 QueuedChecks queued_checks_;
281 280
282 // The sequenced task runner for running safe browsing database operations. 281 // The sequenced task runner for running safe browsing database operations.
283 scoped_refptr<base::SequencedTaskRunner> task_runner_; 282 scoped_refptr<base::SequencedTaskRunner> task_runner_;
284 283
285 // The database that manages the stores containing the hash prefix updates. 284 // The database that manages the stores containing the hash prefix updates.
286 // All writes to this variable must happen on the IO thread only. 285 // All writes to this variable must happen on the IO thread only.
287 std::unique_ptr<V4Database> v4_database_; 286 std::unique_ptr<V4Database> v4_database_;
288 287
289 // The protocol manager that downloads the hash prefix updates. 288 // The protocol manager that downloads the hash prefix updates.
290 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; 289 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_;
291 290
292 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; 291 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_;
293 292
294 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; 293 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>;
295 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); 294 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager);
296 }; // class V4LocalDatabaseManager 295 }; // class V4LocalDatabaseManager
297 296
298 } // namespace safe_browsing 297 } // namespace safe_browsing
299 298
300 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 299 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.cc ('k') | components/safe_browsing_db/v4_local_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698