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

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

Issue 2261603002: PVer4: Re-use the PVer3 implementation to get full hashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_check_browse_url
Patch Set: BUILD: v4_local_database_manager depends on :v4_get_hash_protocol_manager Created 4 years, 4 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 "base/sequenced_task_runner.h"
13 #include "components/safe_browsing_db/database_manager.h" 14 #include "components/safe_browsing_db/database_manager.h"
14 #include "components/safe_browsing_db/hit_report.h" 15 #include "components/safe_browsing_db/hit_report.h"
15 #include "components/safe_browsing_db/v4_database.h" 16 #include "components/safe_browsing_db/v4_database.h"
16 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 17 #include "components/safe_browsing_db/v4_protocol_manager_util.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 class V4GetHashProtocolManager;
25 class V4UpdateProtocolManager;
26
24 // Manages the local, on-disk database of updates downloaded from the 27 // Manages the local, on-disk database of updates downloaded from the
25 // SafeBrowsing service and interfaces with the protocol manager. 28 // SafeBrowsing service and interfaces with the protocol manager.
26 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { 29 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager {
27 public: 30 public:
28 // Construct V4LocalDatabaseManager. 31 // Construct V4LocalDatabaseManager.
29 // Must be initialized by calling StartOnIOThread() before using. 32 // Must be initialized by calling StartOnIOThread() before using.
30 V4LocalDatabaseManager(const base::FilePath& base_path); 33 V4LocalDatabaseManager(const base::FilePath& base_path);
31 34
32 // 35 //
33 // SafeBrowsingDatabaseManager implementation 36 // SafeBrowsingDatabaseManager implementation
(...skipping 25 matching lines...) Expand all
59 62
60 private: 63 private:
61 friend class V4LocalDatabaseManagerTest; 64 friend class V4LocalDatabaseManagerTest;
62 void SetTaskRunnerForTest( 65 void SetTaskRunnerForTest(
63 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { 66 const scoped_refptr<base::SequencedTaskRunner>& task_runner) {
64 task_runner_ = task_runner; 67 task_runner_ = task_runner;
65 } 68 }
66 69
67 ~V4LocalDatabaseManager() override; 70 ~V4LocalDatabaseManager() override;
68 71
72 // Called back by V4GetHashProtocolManager when the full hashes response has
73 // been received from the server.
74 void HandleGetHashes(const std::vector<SBFullHashResult>& full_hash_results,
75 const base::Time& negative_cache_expire);
76
69 // The callback called each time the protocol manager downloads updates 77 // The callback called each time the protocol manager downloads updates
70 // successfully. 78 // successfully.
71 void UpdateRequestCompleted( 79 void UpdateRequestCompleted(
72 std::unique_ptr<ParsedServerResponse> parsed_server_response); 80 std::unique_ptr<ParsedServerResponse> parsed_server_response);
73 81
82 void SetupGetHashProtocolManager(
83 net::URLRequestContextGetter* request_context_getter,
84 const V4ProtocolConfig& config);
85
74 void SetupUpdateProtocolManager( 86 void SetupUpdateProtocolManager(
75 net::URLRequestContextGetter* request_context_getter, 87 net::URLRequestContextGetter* request_context_getter,
76 const V4ProtocolConfig& config); 88 const V4ProtocolConfig& config);
77 89
78 void SetupDatabase(); 90 void SetupDatabase();
79 91
80 void DatabaseReady(std::unique_ptr<V4Database> v4_database); 92 void DatabaseReady(std::unique_ptr<V4Database> v4_database);
81 93
82 // Called when the database has been updated and schedules the next update. 94 // Called when the database has been updated and schedules the next update.
83 void DatabaseUpdated(); 95 void DatabaseUpdated();
84 96
85 // The base directory under which to create the files that contain hashes. 97 // The base directory under which to create the files that contain hashes.
86 const base::FilePath base_path_; 98 const base::FilePath base_path_;
87 99
88 // Whether the service is running. 100 // Whether the service is running.
89 bool enabled_; 101 bool enabled_;
90 102
91 // Stores the current status of the lists to download from the SafeBrowsing 103 // Stores the current status of the lists to download from the SafeBrowsing
92 // servers. 104 // servers.
93 // TODO(vakh): current_list_states_ doesn't really belong here. 105 // TODO(vakh): current_list_states_ doesn't really belong here.
94 // It should come through the database, from the various V4Stores. 106 // It should come through the database, from the various V4Stores.
95 base::hash_map<UpdateListIdentifier, std::string> current_list_states_; 107 base::hash_map<UpdateListIdentifier, std::string> current_list_states_;
96 108
109 // The protocol manager that downloads the full hashes for given hash
110 // prefixes.
111 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_;
112
97 // The protocol manager that downloads the hash prefix updates. 113 // The protocol manager that downloads the hash prefix updates.
98 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; 114 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_;
99 115
100 // The database that manages the stores containing the hash prefix updates. 116 // The database that manages the stores containing the hash prefix updates.
101 // All writes to this variable must happen on the IO thread only. 117 // All writes to this variable must happen on the IO thread only.
102 std::unique_ptr<V4Database> v4_database_; 118 std::unique_ptr<V4Database> v4_database_;
103 119
104 // Called when the V4Database has finished applying the latest update and is 120 // Called when the V4Database has finished applying the latest update and is
105 // ready to process next update. 121 // ready to process next update.
106 DatabaseUpdatedCallback db_updated_callback_; 122 DatabaseUpdatedCallback db_updated_callback_;
107 123
108 // The sequenced task runner for running safe browsing database operations. 124 // The sequenced task runner for running safe browsing database operations.
109 scoped_refptr<base::SequencedTaskRunner> task_runner_; 125 scoped_refptr<base::SequencedTaskRunner> task_runner_;
110 126
111 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; 127 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>;
112 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); 128 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager);
113 }; // class V4LocalDatabaseManager 129 }; // class V4LocalDatabaseManager
114 130
115 } // namespace safe_browsing 131 } // namespace safe_browsing
116 132
117 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ 133 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698