OLD | NEW |
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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for | 9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for |
10 // protocol details. | 10 // protocol details. |
11 // | 11 // |
12 // The SafeBrowsingProtocolManager handles formatting and making requests of, | 12 // The SafeBrowsingProtocolManager handles formatting and making requests of, |
13 // and handling responses from, Google's SafeBrowsing servers. This class uses | 13 // and handling responses from, Google's SafeBrowsing servers. This class uses |
14 // The SafeBrowsingProtocolParser class to do the actual parsing. | 14 // The SafeBrowsingProtocolParser class to do the actual parsing. |
15 | 15 |
| 16 #include <stddef.h> |
| 17 |
16 #include <deque> | 18 #include <deque> |
| 19 #include <memory> |
17 #include <set> | 20 #include <set> |
18 #include <string> | 21 #include <string> |
19 #include <vector> | 22 #include <vector> |
20 | 23 |
21 #include <stddef.h> | |
22 | |
23 #include "base/containers/hash_tables.h" | 24 #include "base/containers/hash_tables.h" |
24 #include "base/gtest_prod_util.h" | 25 #include "base/gtest_prod_util.h" |
25 #include "base/macros.h" | 26 #include "base/macros.h" |
26 #include "base/memory/scoped_ptr.h" | |
27 #include "base/threading/non_thread_safe.h" | 27 #include "base/threading/non_thread_safe.h" |
28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
29 #include "base/timer/timer.h" | 29 #include "base/timer/timer.h" |
30 #include "chrome/browser/safe_browsing/chunk_range.h" | 30 #include "chrome/browser/safe_browsing/chunk_range.h" |
31 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" | 31 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" |
32 #include "chrome/browser/safe_browsing/protocol_parser.h" | 32 #include "chrome/browser/safe_browsing/protocol_parser.h" |
33 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 33 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
34 #include "components/safe_browsing_db/safebrowsing.pb.h" | 34 #include "components/safe_browsing_db/safebrowsing.pb.h" |
35 #include "components/safe_browsing_db/util.h" | 35 #include "components/safe_browsing_db/util.h" |
36 #include "net/url_request/url_fetcher_delegate.h" | 36 #include "net/url_request/url_fetcher_delegate.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // The factory that controls the creation of SafeBrowsingProtocolManager. | 295 // The factory that controls the creation of SafeBrowsingProtocolManager. |
296 // This is used by tests. | 296 // This is used by tests. |
297 static SBProtocolManagerFactory* factory_; | 297 static SBProtocolManagerFactory* factory_; |
298 | 298 |
299 // Our delegate. | 299 // Our delegate. |
300 SafeBrowsingProtocolManagerDelegate* delegate_; | 300 SafeBrowsingProtocolManagerDelegate* delegate_; |
301 | 301 |
302 // Current active request (in case we need to cancel) for updates or chunks | 302 // Current active request (in case we need to cancel) for updates or chunks |
303 // from the SafeBrowsing service. We can only have one of these outstanding | 303 // from the SafeBrowsing service. We can only have one of these outstanding |
304 // at any given time unlike GetHash requests, which are tracked separately. | 304 // at any given time unlike GetHash requests, which are tracked separately. |
305 scoped_ptr<net::URLFetcher> request_; | 305 std::unique_ptr<net::URLFetcher> request_; |
306 | 306 |
307 // The kind of request that is currently in progress. | 307 // The kind of request that is currently in progress. |
308 SafeBrowsingRequestType request_type_; | 308 SafeBrowsingRequestType request_type_; |
309 | 309 |
310 // The number of HTTP response errors since the the last successful HTTP | 310 // The number of HTTP response errors since the the last successful HTTP |
311 // response, used for request backoff timing. | 311 // response, used for request backoff timing. |
312 size_t update_error_count_; | 312 size_t update_error_count_; |
313 size_t gethash_error_count_; | 313 size_t gethash_error_count_; |
314 | 314 |
315 // Multipliers which double (max == 8) for each error after the second. | 315 // Multipliers which double (max == 8) for each error after the second. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Retrieve all the local database chunks, and invoke |callback| with the | 426 // Retrieve all the local database chunks, and invoke |callback| with the |
427 // results. The SafeBrowsingProtocolManagerDelegate must only invoke the | 427 // results. The SafeBrowsingProtocolManagerDelegate must only invoke the |
428 // callback if the SafeBrowsingProtocolManager is still alive. Only one call | 428 // callback if the SafeBrowsingProtocolManager is still alive. Only one call |
429 // may be made to GetChunks at a time. | 429 // may be made to GetChunks at a time. |
430 virtual void GetChunks(GetChunksCallback callback) = 0; | 430 virtual void GetChunks(GetChunksCallback callback) = 0; |
431 | 431 |
432 // Add new chunks to the database. Invokes |callback| when complete, but must | 432 // Add new chunks to the database. Invokes |callback| when complete, but must |
433 // call at a later time. | 433 // call at a later time. |
434 virtual void AddChunks( | 434 virtual void AddChunks( |
435 const std::string& list, | 435 const std::string& list, |
436 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks, | 436 std::unique_ptr<std::vector<std::unique_ptr<SBChunkData>>> chunks, |
437 AddChunksCallback callback) = 0; | 437 AddChunksCallback callback) = 0; |
438 | 438 |
439 // Delete chunks from the database. | 439 // Delete chunks from the database. |
440 virtual void DeleteChunks( | 440 virtual void DeleteChunks( |
441 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) = 0; | 441 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes) = 0; |
442 }; | 442 }; |
443 | 443 |
444 } // namespace safe_browsing | 444 } // namespace safe_browsing |
445 | 445 |
446 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 446 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |