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

Side by Side Diff: chrome/browser/safe_browsing/local_database_manager.h

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Safe Browsing Database Manager implementation that manages a local 5 // Safe Browsing Database Manager implementation that manages a local
6 // database. This is used by Desktop Chromium. 6 // database. This is used by Desktop Chromium.
7 7
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_
10 10
11 #include <stddef.h> 11 #include <stddef.h>
12 12
13 #include <deque> 13 #include <deque>
14 #include <map> 14 #include <map>
15 #include <memory>
15 #include <set> 16 #include <set>
16 #include <string> 17 #include <string>
17 #include <vector> 18 #include <vector>
18 19
19 #include "base/callback.h" 20 #include "base/callback.h"
20 #include "base/containers/hash_tables.h" 21 #include "base/containers/hash_tables.h"
21 #include "base/gtest_prod_util.h" 22 #include "base/gtest_prod_util.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
24 #include "base/memory/scoped_ptr.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "chrome/browser/safe_browsing/protocol_manager.h" 28 #include "chrome/browser/safe_browsing/protocol_manager.h"
29 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 29 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
30 #include "components/safe_browsing_db/database_manager.h" 30 #include "components/safe_browsing_db/database_manager.h"
31 #include "components/safe_browsing_db/safebrowsing.pb.h" 31 #include "components/safe_browsing_db/safebrowsing.pb.h"
32 #include "components/safe_browsing_db/util.h" 32 #include "components/safe_browsing_db/util.h"
33 #include "url/gurl.h" 33 #include "url/gurl.h"
34 34
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 std::vector<SBFullHashResult> cache_hits; 89 std::vector<SBFullHashResult> cache_hits;
90 90
91 // Invoke one of client's callbacks with these results. 91 // Invoke one of client's callbacks with these results.
92 void OnSafeBrowsingResult(); 92 void OnSafeBrowsingResult();
93 93
94 // Vends weak pointers for async callbacks on the IO thread, such as 94 // Vends weak pointers for async callbacks on the IO thread, such as
95 // timeout checks and replies from checks performed on the SB task runner. 95 // timeout checks and replies from checks performed on the SB task runner.
96 // TODO(lzheng): We should consider to use this time out check 96 // TODO(lzheng): We should consider to use this time out check
97 // for browsing too (instead of implementing in 97 // for browsing too (instead of implementing in
98 // safe_browsing_resource_handler.cc). 98 // safe_browsing_resource_handler.cc).
99 scoped_ptr<base::WeakPtrFactory<LocalSafeBrowsingDatabaseManager>> 99 std::unique_ptr<base::WeakPtrFactory<LocalSafeBrowsingDatabaseManager>>
100 weak_ptr_factory_; 100 weak_ptr_factory_;
101 101
102 private: 102 private:
103 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); 103 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck);
104 }; 104 };
105 105
106 // Creates the safe browsing service. Need to initialize before using. 106 // Creates the safe browsing service. Need to initialize before using.
107 LocalSafeBrowsingDatabaseManager( 107 LocalSafeBrowsingDatabaseManager(
108 const scoped_refptr<SafeBrowsingService>& service); 108 const scoped_refptr<SafeBrowsingService>& service);
109 109
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void OnAddChunksComplete(AddChunksCallback callback); 244 void OnAddChunksComplete(AddChunksCallback callback);
245 245
246 // Notification that the database is done loading its bloom filter. We may 246 // Notification that the database is done loading its bloom filter. We may
247 // have had to queue checks until the database is ready, and if so, this 247 // have had to queue checks until the database is ready, and if so, this
248 // checks them. 248 // checks them.
249 void DatabaseLoadComplete(); 249 void DatabaseLoadComplete();
250 250
251 // Called on the database thread to add/remove chunks and host keys. 251 // Called on the database thread to add/remove chunks and host keys.
252 void AddDatabaseChunks( 252 void AddDatabaseChunks(
253 const std::string& list, 253 const std::string& list,
254 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks, 254 std::unique_ptr<std::vector<std::unique_ptr<SBChunkData>>> chunks,
255 AddChunksCallback callback); 255 AddChunksCallback callback);
256 256
257 void DeleteDatabaseChunks( 257 void DeleteDatabaseChunks(
258 scoped_ptr<std::vector<SBChunkDelete>> chunk_deletes); 258 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes);
259 259
260 void NotifyClientBlockingComplete(Client* client, bool proceed); 260 void NotifyClientBlockingComplete(Client* client, bool proceed);
261 261
262 void DatabaseUpdateFinished(bool update_succeeded); 262 void DatabaseUpdateFinished(bool update_succeeded);
263 263
264 // Called on the db thread to close the database. See CloseDatabase(). 264 // Called on the db thread to close the database. See CloseDatabase().
265 void OnCloseDatabase(); 265 void OnCloseDatabase();
266 266
267 // Runs on the db thread to reset the database. We assume that resetting the 267 // Runs on the db thread to reset the database. We assume that resetting the
268 // database is a synchronous operation. 268 // database is a synchronous operation.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // success, otherwise TimeoutCallback will be called. 306 // success, otherwise TimeoutCallback will be called.
307 void StartSafeBrowsingCheck( 307 void StartSafeBrowsingCheck(
308 SafeBrowsingCheck* check, 308 SafeBrowsingCheck* check,
309 const base::Callback<std::vector<SBPrefix>(void)>& task); 309 const base::Callback<std::vector<SBPrefix>(void)>& task);
310 310
311 // SafeBrowsingProtocolManageDelegate override 311 // SafeBrowsingProtocolManageDelegate override
312 void ResetDatabase() override; 312 void ResetDatabase() override;
313 void UpdateStarted() override; 313 void UpdateStarted() override;
314 void UpdateFinished(bool success) override; 314 void UpdateFinished(bool success) override;
315 void GetChunks(GetChunksCallback callback) override; 315 void GetChunks(GetChunksCallback callback) override;
316 void AddChunks(const std::string& list, 316 void AddChunks(
317 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks, 317 const std::string& list,
318 AddChunksCallback callback) override; 318 std::unique_ptr<std::vector<std::unique_ptr<SBChunkData>>> chunks,
319 AddChunksCallback callback) override;
319 void DeleteChunks( 320 void DeleteChunks(
320 scoped_ptr<std::vector<SBChunkDelete>> chunk_deletes) override; 321 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes) override;
321 322
322 scoped_refptr<SafeBrowsingService> sb_service_; 323 scoped_refptr<SafeBrowsingService> sb_service_;
323 324
324 CurrentChecks checks_; 325 CurrentChecks checks_;
325 326
326 // Used for issuing only one GetHash request for a given prefix. 327 // Used for issuing only one GetHash request for a given prefix.
327 GetHashRequests gethash_requests_; 328 GetHashRequests gethash_requests_;
328 329
329 // The persistent database. We don't use a scoped_ptr because it 330 // The persistent database. We don't use a std::unique_ptr because it
330 // needs to be destroyed on a different thread than this object. 331 // needs to be destroyed on a different thread than this object.
331 SafeBrowsingDatabase* database_; 332 SafeBrowsingDatabase* database_;
332 333
333 // Lock used to prevent possible data races due to compiler optimizations. 334 // Lock used to prevent possible data races due to compiler optimizations.
334 mutable base::Lock database_lock_; 335 mutable base::Lock database_lock_;
335 336
336 // Whether the service is running. 'enabled_' is used by the 337 // Whether the service is running. 'enabled_' is used by the
337 // SafeBrowsingDatabaseManager on the IO thread during normal operations. 338 // SafeBrowsingDatabaseManager on the IO thread during normal operations.
338 bool enabled_; 339 bool enabled_;
339 340
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 379
379 // Timeout to use for safe browsing checks. 380 // Timeout to use for safe browsing checks.
380 base::TimeDelta check_timeout_; 381 base::TimeDelta check_timeout_;
381 382
382 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); 383 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager);
383 }; // class LocalSafeBrowsingDatabaseManager 384 }; // class LocalSafeBrowsingDatabaseManager
384 385
385 } // namespace safe_browsing 386 } // namespace safe_browsing
386 387
387 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ 388 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698