OLD | NEW |
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_GET_HASH_PROTOCOL_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. |
9 // | 9 // |
10 // The V4GetHashProtocolManager handles formatting and making requests of, and | 10 // The V4GetHashProtocolManager handles formatting and making requests of, and |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 // Overrides the clock used to check the time. | 282 // Overrides the clock used to check the time. |
283 void SetClockForTests(std::unique_ptr<base::Clock> clock); | 283 void SetClockForTests(std::unique_ptr<base::Clock> clock); |
284 | 284 |
285 // Updates the state of the full hash cache upon receiving a valid response | 285 // Updates the state of the full hash cache upon receiving a valid response |
286 // from the server. | 286 // from the server. |
287 void UpdateCache(const std::vector<HashPrefix>& prefixes_requested, | 287 void UpdateCache(const std::vector<HashPrefix>& prefixes_requested, |
288 const std::vector<FullHashInfo>& full_hash_infos, | 288 const std::vector<FullHashInfo>& full_hash_infos, |
289 const base::Time& negative_cache_expire); | 289 const base::Time& negative_cache_expire); |
290 | 290 |
| 291 protected: |
| 292 // A cache of full hash results. |
| 293 FullHashCache full_hash_cache_; |
| 294 |
291 private: | 295 private: |
292 // Map of GetHash requests to parameters which created it. | 296 // Map of GetHash requests to parameters which created it. |
293 using PendingHashRequests = | 297 using PendingHashRequests = |
294 base::hash_map<const net::URLFetcher*, | 298 base::hash_map<const net::URLFetcher*, |
295 std::unique_ptr<FullHashCallbackInfo>>; | 299 std::unique_ptr<FullHashCallbackInfo>>; |
296 | 300 |
297 // The factory that controls the creation of V4GetHashProtocolManager. | 301 // The factory that controls the creation of V4GetHashProtocolManager. |
298 // This is used by tests. | 302 // This is used by tests. |
299 static V4GetHashProtocolManagerFactory* factory_; | 303 static V4GetHashProtocolManagerFactory* factory_; |
300 | 304 |
(...skipping 21 matching lines...) Expand all Loading... |
322 | 326 |
323 // The context we use to issue network requests. | 327 // The context we use to issue network requests. |
324 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 328 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
325 | 329 |
326 // ID for URLFetchers for testing. | 330 // ID for URLFetchers for testing. |
327 int url_fetcher_id_; | 331 int url_fetcher_id_; |
328 | 332 |
329 // The clock used to vend times. | 333 // The clock used to vend times. |
330 std::unique_ptr<base::Clock> clock_; | 334 std::unique_ptr<base::Clock> clock_; |
331 | 335 |
332 // A cache of full hash results. | |
333 FullHashCache full_hash_cache_; | |
334 | |
335 // The following sets represent the combination of lists that we would always | 336 // The following sets represent the combination of lists that we would always |
336 // request from the server, irrespective of which list we found the hash | 337 // request from the server, irrespective of which list we found the hash |
337 // prefix match in. | 338 // prefix match in. |
338 std::vector<PlatformType> platform_types_; | 339 std::vector<PlatformType> platform_types_; |
339 std::vector<ThreatEntryType> threat_entry_types_; | 340 std::vector<ThreatEntryType> threat_entry_types_; |
340 std::vector<ThreatType> threat_types_; | 341 std::vector<ThreatType> threat_types_; |
341 | 342 |
342 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManager); | 343 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManager); |
343 }; | 344 }; |
344 | 345 |
(...skipping 11 matching lines...) Expand all Loading... |
356 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); | 357 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); |
357 }; | 358 }; |
358 | 359 |
359 #ifndef NDEBUG | 360 #ifndef NDEBUG |
360 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); | 361 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); |
361 #endif | 362 #endif |
362 | 363 |
363 } // namespace safe_browsing | 364 } // namespace safe_browsing |
364 | 365 |
365 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ | 366 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
OLD | NEW |