Chromium Code Reviews| Index: chrome/browser/safe_browsing/protocol_manager.h |
| diff --git a/chrome/browser/safe_browsing/protocol_manager.h b/chrome/browser/safe_browsing/protocol_manager.h |
| index 0d597ccb62aa487112988068da7bd492567cb4d0..cafc7be32f7e327cf28a4d23b2292f3b0e2957f2 100644 |
| --- a/chrome/browser/safe_browsing/protocol_manager.h |
| +++ b/chrome/browser/safe_browsing/protocol_manager.h |
| @@ -6,6 +6,9 @@ |
| #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| // A class that implements Chrome's interface with the SafeBrowsing protocol. |
| +// See https://developers.google.com/safe-browsing/developers_guide_v2 for |
| +// protocol details. |
| +// |
| // The SafeBrowsingProtocolManager handles formatting and making requests of, |
| // and handling responses from, Google's SafeBrowsing servers. This class uses |
| // The SafeBrowsingProtocolParser class to do the actual parsing. |
| @@ -102,9 +105,6 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, |
| void OnGetChunksComplete(const std::vector<SBListChunkRanges>& list, |
| bool database_error); |
| - // Called after the chunks that were parsed were inserted in the database. |
| - void OnChunkInserted(); |
| - |
| // The last time we received an update. |
| base::Time last_update() const { return last_update_; } |
| @@ -152,6 +152,9 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, |
| static void RecordGetHashResult(bool is_download, |
| ResultType result_type); |
| + // Returns whether another update is currently scheduled. |
| + bool IsUpdateScheduled() const; |
| + |
| protected: |
| // Constructs a SafeBrowsingProtocolManager for |delegate| that issues |
| // network requests using |request_context_getter|. |
| @@ -232,11 +235,15 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, |
| // Helper function for update completion. |
| void UpdateFinished(bool success); |
| + void UpdateFinished(bool success, bool back_off); |
| // A callback that runs if we timeout waiting for a response to an update |
| // request. We use this to properly set our update state. |
| void UpdateResponseTimeout(); |
| + // Called after the chunks are added to the database. |
| + void OnAddChunksComplete(); |
| + |
| private: |
| // Map of GetHash requests to parameters which created it. |
| struct FullHashDetails { |
| @@ -283,6 +290,10 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, |
| base::TimeDelta next_update_interval_; |
| base::OneShotTimer<SafeBrowsingProtocolManager> update_timer_; |
| + // update_timeout_timer_ is used to prevent update requests from taking too |
|
mattm
2012/12/05 23:58:10
Comment doesn't match variable name.
|
| + // long. |
| + base::OneShotTimer<SafeBrowsingProtocolManager> timeout_timer_; |
| + |
| // All chunk requests that need to be made. |
| std::deque<ChunkUrl> chunk_request_urls_; |
| @@ -356,6 +367,7 @@ class SafeBrowsingProtocolManagerDelegate { |
| public: |
| typedef base::Callback<void(const std::vector<SBListChunkRanges>&, bool)> |
| GetChunksCallback; |
| + typedef base::Callback<void(void)> AddChunksCallback; |
| virtual ~SafeBrowsingProtocolManagerDelegate(); |
| @@ -376,8 +388,10 @@ class SafeBrowsingProtocolManagerDelegate { |
| // may be made to GetChunks at a time. |
| virtual void GetChunks(GetChunksCallback callback) = 0; |
| - // Add new chunks to the database. |
| - virtual void AddChunks(const std::string& list, SBChunkList* chunks) = 0; |
| + // Add new chunks to the database. Invokes |callback| when complete, but must |
| + // call at a later time. |
| + virtual void AddChunks(const std::string& list, SBChunkList* chunks, |
| + AddChunksCallback callback) = 0; |
| // Delete chunks from the database. |
| virtual void DeleteChunks( |