// Copyright 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ #define COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. // // The V4GetHashProtocolManager handles formatting and making requests of, and // handling responses from, Google's SafeBrowsing servers. The purpose of this // class is to get full hash matches from the SB server for the given set of // hash prefixes. // // Design doc: go/design-doc-v4-full-hash-manager #include <memory> #include <string> #include <unordered_map> #include <utility> #include <vector> #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/sequence_checker.h" #include "base/time/default_clock.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "components/safe_browsing/core/browser/db/safebrowsing.pb.h" #include "components/safe_browsing/core/browser/db/util.h" #include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h" #include "components/safe_browsing/core/common/proto/webui.pb.h" class GURL; namespace network { class SimpleURLLoader; class SharedURLLoaderFactory; } // namespace network namespace safe_browsing { class V4GetHashProtocolManagerFuzzer; // ---------------------------------------------------------------- // All information about a particular full hash i.e. negative TTL, store for // which it is valid, and metadata associated with that store. struct FullHashInfo { … }; // Caches individual response from GETHASH response. struct CachedHashPrefixInfo { … }; // Cached full hashes received from the server for the corresponding hash // prefixes. FullHashCache; // FullHashCallback is invoked when GetFullHashes completes. The parameter is // the vector of full hash results. If empty, indicates that there were no // matches, and that the resource is safe. FullHashCallback; // Information needed to update the cache and call the callback to post the // results. struct FullHashCallbackInfo { … }; // ---------------------------------------------------------------- class V4GetHashProtocolManagerFactory; class V4GetHashProtocolManager { … }; // Interface of a factory to create V4GetHashProtocolManager. Useful for tests. class V4GetHashProtocolManagerFactory { … }; #ifndef NDEBUG std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); #endif } // namespace safe_browsing #endif // COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_