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

Unified Diff: chrome/browser/safe_browsing/protocol_manager.h

Issue 11347005: Change SafeBrowsingProtocolManager::GetFullHash signature. (Closed) Base URL: http://git.chromium.org/chromium/src.git@in_progress
Patch Set: Fix rebase with browser_test Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
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 f29f84248fab414361016a23b5cba1f4880c9c7a..1c157f8ad241efd1bab1ae0ddd118993b136691b 100644
--- a/chrome/browser/safe_browsing/protocol_manager.h
+++ b/chrome/browser/safe_browsing/protocol_manager.h
@@ -61,6 +61,15 @@ class SBProtocolManagerFactory {
class SafeBrowsingProtocolManager : public net::URLFetcherDelegate {
public:
+ // FullHashCallback is invoked when GetFullHash completes.
+ // Parameters:
+ // - The vector of full hash results. If empty, indicates that there
+ // were no matches, and that the resource is safe.
+ // - Whether the result can be cached. This may not be the case when
+ // the result did not come from the SB server, for example.
+ typedef base::Callback<void(const std::vector<SBFullHashResult>&,
+ bool)> FullHashCallback;
+
virtual ~SafeBrowsingProtocolManager();
// Makes the passed |factory| the factory used to instantiate
@@ -84,10 +93,12 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate {
// net::URLFetcherDelegate interface.
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
- // API used by the SafeBrowsingService for issuing queries. When the results
- // are available, SafeBrowsingService::HandleGetHashResults is called.
- virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check,
- const std::vector<SBPrefix>& prefixes);
+ // Retrieve the full hash for a set of prefixes, and invoke the callback
+ // argument when the results are retrieved. The callback may be invoked
+ // synchronously.
+ virtual void GetFullHash(const std::vector<SBPrefix>& prefixes,
+ FullHashCallback callback,
+ bool is_download);
// Forces the start of next update after |interval| time.
void ForceScheduleNextUpdate(base::TimeDelta interval);
@@ -275,6 +286,16 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate {
void UpdateResponseTimeout();
private:
+ // Map of GetHash requests to parameters which created it.
+ struct FullHashDetails {
+ FullHashDetails();
+ FullHashDetails(FullHashCallback callback, bool is_download);
+ ~FullHashDetails();
mattm 2012/10/29 23:57:09 Maybe put a blank line between the methods and the
cbentzel 2012/10/30 11:34:03 Done.
+ FullHashCallback callback;
+ bool is_download;
+ };
+ typedef base::hash_map<const net::URLFetcher*, FullHashDetails> HashRequests;
+
// The factory that controls the creation of SafeBrowsingProtocolManager.
// This is used by tests.
static SBProtocolManagerFactory* factory_;
@@ -312,9 +333,6 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate {
// All chunk requests that need to be made.
std::deque<ChunkUrl> chunk_request_urls_;
- // Map of GetHash requests.
- typedef base::hash_map<const net::URLFetcher*,
- SafeBrowsingService::SafeBrowsingCheck*> HashRequests;
HashRequests hash_requests_;
// The next scheduled update has special behavior for the first 2 requests.
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/protocol_manager.cc » ('j') | chrome/browser/safe_browsing/protocol_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698