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

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

Issue 2616653002: Have a list of pending checks instead of pending clients (Closed)
Patch Set: Don't care about timing out of SB check for redirect loops. 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 154
154 // The stores/lists to always get full hashes for, regardless of which store 155 // The stores/lists to always get full hashes for, regardless of which store
155 // the hash prefix matched. 156 // the hash prefix matched.
156 StoresToCheck GetStoresForFullHashRequests() override; 157 StoresToCheck GetStoresForFullHashRequests() override;
157 158
158 private: 159 private:
159 friend class V4LocalDatabaseManagerTest; 160 friend class V4LocalDatabaseManagerTest;
160 FRIEND_TEST_ALL_PREFIXES(V4LocalDatabaseManagerTest, 161 FRIEND_TEST_ALL_PREFIXES(V4LocalDatabaseManagerTest,
161 TestGetSeverestThreatTypeAndMetadata); 162 TestGetSeverestThreatTypeAndMetadata);
162 163
163 // The set of clients awaiting a full hash response. It is used for tracking 164 // The checks awaiting a full hash response from SafeBrowsing service.
164 // which clients have cancelled their outstanding request. 165 typedef std::unordered_set<const PendingCheck*> PendingChecks;
165 typedef std::unordered_set<const Client*> PendingClients;
166 166
167 // Called when all the stores managed by the database have been read from 167 // Called when all the stores managed by the database have been read from
168 // disk after startup and the database is ready for checking resource 168 // disk after startup and the database is ready for checking resource
169 // reputation. 169 // reputation.
170 void DatabaseReadyForChecks(std::unique_ptr<V4Database> v4_database); 170 void DatabaseReadyForChecks(std::unique_ptr<V4Database> v4_database);
171 171
172 // Called when all the stores managed by the database have been verified for 172 // Called when all the stores managed by the database have been verified for
173 // checksum correctness after startup and the database is ready for applying 173 // checksum correctness after startup and the database is ready for applying
174 // updates. 174 // updates.
175 void DatabaseReadyForUpdates( 175 void DatabaseReadyForUpdates(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 // Whether the service is running. 263 // Whether the service is running.
264 bool enabled_; 264 bool enabled_;
265 265
266 // The list of stores to manage (for hash prefixes and full hashes). Each 266 // The list of stores to manage (for hash prefixes and full hashes). Each
267 // element contains the identifier for the store, the corresponding 267 // element contains the identifier for the store, the corresponding
268 // SBThreatType, whether to fetch hash prefixes for that store, and the 268 // SBThreatType, whether to fetch hash prefixes for that store, and the
269 // name of the file on disk that would contain the prefixes, if applicable. 269 // name of the file on disk that would contain the prefixes, if applicable.
270 ListInfos list_infos_; 270 ListInfos list_infos_;
271 271
272 // The set of clients that are waiting for a full hash response from the 272 // The checks awaiting for a full hash response from the SafeBrowsing service.
273 // SafeBrowsing service. 273 PendingChecks pending_checks_;
274 PendingClients pending_clients_;
275 274
276 // The checks that need to be scheduled when the database becomes ready for 275 // The checks that need to be scheduled when the database becomes ready for
277 // use. 276 // use.
278 QueuedChecks queued_checks_; 277 QueuedChecks queued_checks_;
279 278
280 // The sequenced task runner for running safe browsing database operations. 279 // The sequenced task runner for running safe browsing database operations.
281 scoped_refptr<base::SequencedTaskRunner> task_runner_; 280 scoped_refptr<base::SequencedTaskRunner> task_runner_;
282 281
283 // The database that manages the stores containing the hash prefix updates. 282 // The database that manages the stores containing the hash prefix updates.
284 // All writes to this variable must happen on the IO thread only. 283 // All writes to this variable must happen on the IO thread only.
285 std::unique_ptr<V4Database> v4_database_; 284 std::unique_ptr<V4Database> v4_database_;
286 285
287 // The protocol manager that downloads the hash prefix updates. 286 // The protocol manager that downloads the hash prefix updates.
288 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; 287 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_;
289 288
290 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; 289 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_;
291 290
292 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; 291 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>;
293 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); 292 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager);
294 }; // class V4LocalDatabaseManager 293 }; // class V4LocalDatabaseManager
295 294
296 } // namespace safe_browsing 295 } // namespace safe_browsing
297 296
298 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 297 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698