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

Side by Side Diff: components/safe_browsing_db/v4_get_hash_protocol_manager.h

Issue 2057433002: Replace the old URL format for PVer4 requests with the new format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback: nparker. GetRequestUrlAndUpdateHeaders -> GetRequestUrlAndHeaders Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_get_hash_protocol_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // handling responses from, Google's SafeBrowsing servers. The purpose of this 11 // handling responses from, Google's SafeBrowsing servers. The purpose of this
12 // class is to get full hash matches from the SB server for the given set of 12 // class is to get full hash matches from the SB server for the given set of
13 // hash prefixes. 13 // hash prefixes.
14 14
15 #include <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/gtest_prod_util.h" 19 #include "base/gtest_prod_util.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/threading/non_thread_safe.h" 21 #include "base/threading/non_thread_safe.h"
22 #include "base/time/default_clock.h" 22 #include "base/time/default_clock.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
25 #include "components/safe_browsing_db/safebrowsing.pb.h" 25 #include "components/safe_browsing_db/safebrowsing.pb.h"
26 #include "components/safe_browsing_db/util.h" 26 #include "components/safe_browsing_db/util.h"
27 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 27 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
28 #include "net/url_request/url_fetcher_delegate.h" 28 #include "net/url_request/url_fetcher_delegate.h"
29 #include "url/gurl.h" 29
30 class GURL;
30 31
31 namespace net { 32 namespace net {
32 class URLFetcher; 33 class URLFetcher;
33 class URLRequestContextGetter; 34 class URLRequestContextGetter;
34 } // namespace net 35 } // namespace net
35 36
36 namespace safe_browsing { 37 namespace safe_browsing {
37 38
38 class V4GetHashProtocolManagerFactory; 39 class V4GetHashProtocolManagerFactory;
39 40
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // invoked synchronously. 79 // invoked synchronously.
79 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes, 80 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes,
80 FullHashCallback callback); 81 FullHashCallback callback);
81 82
82 // Overrides the clock used to check the time. 83 // Overrides the clock used to check the time.
83 void SetClockForTests(std::unique_ptr<base::Clock> clock); 84 void SetClockForTests(std::unique_ptr<base::Clock> clock);
84 85
85 protected: 86 protected:
86 // Constructs a V4GetHashProtocolManager that issues 87 // Constructs a V4GetHashProtocolManager that issues
87 // network requests using |request_context_getter|. 88 // network requests using |request_context_getter|.
88 V4GetHashProtocolManager( 89 V4GetHashProtocolManager(net::URLRequestContextGetter* request_context_getter,
89 net::URLRequestContextGetter* request_context_getter, 90 const V4ProtocolConfig& config);
90 const V4ProtocolConfig& config);
91 91
92 private: 92 private:
93 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 93 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
94 TestGetHashRequest); 94 TestGetHashRequest);
95 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 95 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
96 TestParseHashResponse); 96 TestParseHashResponse);
97 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 97 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
98 TestParseHashResponseWrongThreatEntryType); 98 TestParseHashResponseWrongThreatEntryType);
99 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 99 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
100 TestParseHashThreatPatternType); 100 TestParseHashThreatPatternType);
101 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 101 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
102 TestParseHashResponseNonPermissionMetadata); 102 TestParseHashResponseNonPermissionMetadata);
103 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 103 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
104 TestParseHashResponseInconsistentThreatTypes); 104 TestParseHashResponseInconsistentThreatTypes);
105 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 105 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
106 TestGetHashErrorHandlingOK); 106 TestGetHashErrorHandlingOK);
107 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 107 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
108 TestGetHashErrorHandlingNetwork); 108 TestGetHashErrorHandlingNetwork);
109 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 109 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
110 TestGetHashErrorHandlingResponseCode); 110 TestGetHashErrorHandlingResponseCode);
111 friend class V4GetHashProtocolManagerFactoryImpl; 111 friend class V4GetHashProtocolManagerFactoryImpl;
112 112
113 GURL GetHashUrl(const std::string& request_base64) const; 113 void GetHashUrlAndHeaders(const std::string& request_base64,
114 GURL* gurl,
115 net::HttpRequestHeaders* headers) const;
114 116
115 // Fills a FindFullHashesRequest protocol buffer for a request. 117 // Fills a FindFullHashesRequest protocol buffer for a request.
116 // Returns the serialized and base 64 encoded request as a string. 118 // Returns the serialized and base 64 encoded request as a string.
117 std::string GetHashRequest(const std::vector<SBPrefix>& prefixes, 119 std::string GetHashRequest(const std::vector<SBPrefix>& prefixes,
118 const std::vector<PlatformType>& platforms, 120 const std::vector<PlatformType>& platforms,
119 ThreatType threat_type); 121 ThreatType threat_type);
120 122
121 // Parses a FindFullHashesResponse protocol buffer and fills the results in 123 // Parses a FindFullHashesResponse protocol buffer and fills the results in
122 // |full_hashes| and |negative_cache_expire|. |data| is a serialized 124 // |full_hashes| and |negative_cache_expire|. |data| is a serialized
123 // FindFullHashes protocol buffer. |negative_cache_expire| is the cache expiry 125 // FindFullHashes protocol buffer. |negative_cache_expire| is the cache expiry
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 net::URLRequestContextGetter* request_context_getter, 187 net::URLRequestContextGetter* request_context_getter,
186 const V4ProtocolConfig& config) = 0; 188 const V4ProtocolConfig& config) = 0;
187 189
188 private: 190 private:
189 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); 191 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory);
190 }; 192 };
191 193
192 } // namespace safe_browsing 194 } // namespace safe_browsing
193 195
194 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ 196 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_get_hash_protocol_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698