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

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

Issue 1983603002: Revert of Initialize and reset V4LocalDBManager. Instantiate V4Stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v4_01_db_realz
Patch Set: 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 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 12
13 #include "components/safe_browsing_db/database_manager.h" 13 #include "components/safe_browsing_db/database_manager.h"
14 #include "components/safe_browsing_db/hit_report.h" 14 #include "components/safe_browsing_db/hit_report.h"
15 #include "components/safe_browsing_db/v4_database.h" 15 #include "components/safe_browsing_db/v4_database.h"
16 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 16 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
17 #include "components/safe_browsing_db/v4_update_protocol_manager.h" 17 #include "components/safe_browsing_db/v4_update_protocol_manager.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 using content::ResourceType; 20 using content::ResourceType;
21 21
22 namespace safe_browsing { 22 namespace safe_browsing {
23 23
24 // Manages the local, on-disk database of updates downloaded from the 24 // Manages the local, on-disk database of updates downloaded from the
25 // SafeBrowsing service and interfaces with the protocol manager. 25 // SafeBrowsing service and interfaces with the protocol manager.
26 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { 26 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
27 public: 27 public:
28 // Construct V4LocalDatabaseManager. 28 // Construct V4LocalDatabaseManager.
29 // Must be initialized by calling StartOnIOThread() before using. 29 // Must be initialized by calling StartOnIOThread() before using.
30 V4LocalDatabaseManager(const base::FilePath& base_path); 30 V4LocalDatabaseManager();
31 31
32 // 32 //
33 // SafeBrowsingDatabaseManager implementation 33 // SafeBrowsingDatabaseManager implementation
34 // 34 //
35 35
36 bool IsSupported() const override; 36 bool IsSupported() const override;
37 safe_browsing::ThreatSource GetThreatSource() const override; 37 safe_browsing::ThreatSource GetThreatSource() const override;
38 bool ChecksAreAlwaysAsync() const override; 38 bool ChecksAreAlwaysAsync() const override;
39 bool CanCheckResourceType(content::ResourceType resource_type) const override; 39 bool CanCheckResourceType(content::ResourceType resource_type) const override;
40 bool CanCheckUrl(const GURL& url) const override; 40 bool CanCheckUrl(const GURL& url) const override;
41 bool IsDownloadProtectionEnabled() const override; 41 bool IsDownloadProtectionEnabled() const override;
42 bool CheckBrowseUrl(const GURL& url, Client* client) override; 42 bool CheckBrowseUrl(const GURL& url, Client* client) override;
43 void CancelCheck(Client* client) override; 43 void CancelCheck(Client* client) override;
44 void StartOnIOThread(net::URLRequestContextGetter* request_context_getter, 44 void StartOnIOThread(
45 const V4ProtocolConfig& config) override; 45 net::URLRequestContextGetter* request_context_getter,
46 const V4ProtocolConfig& config) override;
46 void StopOnIOThread(bool shutdown) override; 47 void StopOnIOThread(bool shutdown) override;
47 bool CheckDownloadUrl(const std::vector<GURL>& url_chain, 48 bool CheckDownloadUrl(const std::vector<GURL>& url_chain,
48 Client* client) override; 49 Client* client) override;
49 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, 50 bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
50 Client* client) override; 51 Client* client) override;
51 bool MatchCsdWhitelistUrl(const GURL& url) override; 52 bool MatchCsdWhitelistUrl(const GURL& url) override;
52 bool MatchMalwareIP(const std::string& ip_address) override; 53 bool MatchMalwareIP(const std::string& ip_address) override;
53 bool MatchDownloadWhitelistUrl(const GURL& url) override; 54 bool MatchDownloadWhitelistUrl(const GURL& url) override;
54 bool MatchDownloadWhitelistString(const std::string& str) override; 55 bool MatchDownloadWhitelistString(const std::string& str) override;
55 bool MatchInclusionWhitelistUrl(const GURL& url) override; 56 bool MatchInclusionWhitelistUrl(const GURL& url) override;
56 bool MatchModuleWhitelistString(const std::string& str) override; 57 bool MatchModuleWhitelistString(const std::string& str) override;
57 bool CheckResourceUrl(const GURL& url, Client* client) override; 58 bool CheckResourceUrl(const GURL& url, Client* client) override;
58 bool IsMalwareKillSwitchOn() override; 59 bool IsMalwareKillSwitchOn() override;
59 bool IsCsdWhitelistKillSwitchOn() override; 60 bool IsCsdWhitelistKillSwitchOn() override;
60 61
61 private: 62 private:
62 ~V4LocalDatabaseManager() override; 63 ~V4LocalDatabaseManager() override;
63 64
64 // The callback called each time the protocol manager downloads updates 65 // The callback called each time the protocol manager downloads updates
65 // successfully. 66 // successfully.
66 void UpdateRequestCompleted(const std::vector<ListUpdateResponse>& responses); 67 void UpdateRequestCompleted(const std::vector<ListUpdateResponse>& responses);
67 68
68 void SetupUpdateProtocolManager(
69 net::URLRequestContextGetter* request_context_getter,
70 const V4ProtocolConfig& config);
71
72 void SetupDatabase();
73
74 void DatabaseReady(std::unique_ptr<V4Database> v4_database);
75
76 void OnCloseDatabase();
77
78 // The base directory under which to create the files that contain hashes.
79 const base::FilePath base_path_;
80
81 // Whether the service is running.
82 bool enabled_; 69 bool enabled_;
83 70
84 // Stores the current status of the lists to download from the SafeBrowsing 71 // Stores the current status of the lists to download from the SafeBrowsing
85 // servers. 72 // servers.
86 // TODO(vakh): current_list_states_ doesn't really belong here. 73 // TODO(vakh): current_list_states_ doesn't really belong here.
87 // It should come through the database, from the various V4Stores. 74 // It should come through the database, from the various V4Stores.
88 base::hash_map<UpdateListIdentifier, std::string> current_list_states_; 75 base::hash_map<UpdateListIdentifier, std::string> current_list_states_;
89 76
90 // The protocol manager that downloads the hash prefix updates. 77 // The protocol manager that downloads the hash prefix updates.
91 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; 78 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_;
92 79
93 // The database that manages the stores containing the hash prefix updates. 80 // The database that manages the stores containing the hash prefix updates.
94 // All writes to this variable must happen on the IO thread only.
95 std::unique_ptr<V4Database> v4_database_; 81 std::unique_ptr<V4Database> v4_database_;
96 82
97 // The sequenced task runner for running safe browsing database operations.
98 scoped_refptr<base::SequencedTaskRunner> task_runner_;
99
100 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; 83 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>;
101 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); 84 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager);
102 }; // class V4LocalDatabaseManager 85 }; // class V4LocalDatabaseManager
103 86
104 } // namespace safe_browsing 87 } // namespace safe_browsing
105 88
106 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 89 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_database.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