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

Unified Diff: components/safe_browsing_db/v4_local_database_manager.h

Issue 1954393002: Initialize and reset V4LocalDBManager. Instantiate V4Stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v4_01_db_realz
Patch Set: Add v4_store.cc to gypi and update a comment Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_local_database_manager.h
diff --git a/components/safe_browsing_db/v4_local_database_manager.h b/components/safe_browsing_db/v4_local_database_manager.h
index ac8900c8822da87700609303c6cbb442978a57ff..4a19b511befa27ca310a2b3f5d9bf6587ff94392 100644
--- a/components/safe_browsing_db/v4_local_database_manager.h
+++ b/components/safe_browsing_db/v4_local_database_manager.h
@@ -27,7 +27,7 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
public:
// Construct V4LocalDatabaseManager.
// Must be initialized by calling StartOnIOThread() before using.
- V4LocalDatabaseManager();
+ V4LocalDatabaseManager(const base::FilePath& base_path);
//
// SafeBrowsingDatabaseManager implementation
@@ -41,9 +41,8 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
bool IsDownloadProtectionEnabled() const override;
bool CheckBrowseUrl(const GURL& url, Client* client) override;
void CancelCheck(Client* client) override;
- void StartOnIOThread(
- net::URLRequestContextGetter* request_context_getter,
- const V4ProtocolConfig& config) override;
+ void StartOnIOThread(net::URLRequestContextGetter* request_context_getter,
+ const V4ProtocolConfig& config) override;
void StopOnIOThread(bool shutdown) override;
bool CheckDownloadUrl(const std::vector<GURL>& url_chain,
Client* client) override;
@@ -66,8 +65,26 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
// successfully.
void UpdateRequestCompleted(const std::vector<ListUpdateResponse>& responses);
+ void SetupUpdateProtocolManager(
+ net::URLRequestContextGetter* request_context_getter,
+ const V4ProtocolConfig& config);
+
+ bool DatabaseAvailable() const;
+
+ void SetupDatabase();
+
+ void OnCloseDatabase();
+
+ // The base directory under which to create the files that contain hashes.
+ const base::FilePath& base_path_;
+
+ // Whether the service is running.
bool enabled_;
+ // Indicates if we're in the midst of trying to close the database. If this
+ // is true, nothing on the IO thread should access the database.
+ bool closing_database_;
+
// Stores the current status of the lists to download from the SafeBrowsing
// servers.
// TODO(vakh): current_list_states_ doesn't really belong here.
@@ -80,6 +97,12 @@ class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
// The database that manages the stores containing the hash prefix updates.
std::unique_ptr<V4Database> v4_database_;
+ // Lock used to prevent possible data races due to compiler optimizations.
+ mutable base::Lock database_lock_;
+
+ // The sequenced task runner for running safe browsing database operations.
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>;
DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager);
}; // class V4LocalDatabaseManager

Powered by Google App Engine
This is Rietveld 408576698