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

Side by Side Diff: components/safe_browsing_db/v4_update_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
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_UPDATE_PROTOCOL_MANAGER_H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_
7 7
8 // A class that implements Chrome's interface with the SafeBrowsing V4 update 8 // A class that implements Chrome's interface with the SafeBrowsing V4 update
9 // protocol. 9 // protocol.
10 // 10 //
11 // The V4UpdateProtocolManager handles formatting and making requests of, and 11 // The V4UpdateProtocolManager handles formatting and making requests of, and
12 // handling responses from, Google's SafeBrowsing servers. The purpose of this 12 // handling responses from, Google's SafeBrowsing servers. The purpose of this
13 // class is to get hash prefixes from the SB server for the given set of lists. 13 // class is to get hash prefixes from the SB server for the given set of lists.
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/time.h" 22 #include "base/time/time.h"
23 #include "base/timer/timer.h" 23 #include "base/timer/timer.h"
24 #include "components/safe_browsing_db/safebrowsing.pb.h" 24 #include "components/safe_browsing_db/safebrowsing.pb.h"
25 #include "components/safe_browsing_db/util.h" 25 #include "components/safe_browsing_db/util.h"
26 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 26 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
27 #include "net/url_request/url_fetcher_delegate.h" 27 #include "net/url_request/url_fetcher_delegate.h"
28 #include "url/gurl.h" 28
29 class GURL;
29 30
30 namespace net { 31 namespace net {
31 class URLFetcher; 32 class URLFetcher;
32 class URLRequestContextGetter; 33 class URLRequestContextGetter;
33 } // namespace net 34 } // namespace net
34 35
35 namespace safe_browsing { 36 namespace safe_browsing {
36 37
37 class V4UpdateProtocolManagerFactory; 38 class V4UpdateProtocolManagerFactory;
38 39
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 private: 88 private:
88 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest, 89 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest,
89 TestGetUpdatesErrorHandlingNetwork); 90 TestGetUpdatesErrorHandlingNetwork);
90 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest, 91 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest,
91 TestGetUpdatesErrorHandlingResponseCode); 92 TestGetUpdatesErrorHandlingResponseCode);
92 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest, TestGetUpdatesNoError); 93 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest, TestGetUpdatesNoError);
93 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest, 94 FRIEND_TEST_ALL_PREFIXES(V4UpdateProtocolManagerTest,
94 TestGetUpdatesWithOneBackoff); 95 TestGetUpdatesWithOneBackoff);
95 friend class V4UpdateProtocolManagerFactoryImpl; 96 friend class V4UpdateProtocolManagerFactoryImpl;
96 97
97 // The method to generate the URL for the request to be sent to the server. 98 // The method to populate |gurl| with the URL to be sent to the server.
98 // |request_base64| is the base64 encoded form of an instance of the protobuf 99 // |request_base64| is the base64 encoded form of an instance of the protobuf
99 // FetchThreatListUpdatesRequest. 100 // FetchThreatListUpdatesRequest. Also sets the appropriate header values for
100 GURL GetUpdateUrl(const std::string& request_base64) const; 101 // sending PVer4 requests in |headers|.
102 void GetUpdateUrlAndHeaders(const std::string& request_base64,
103 GURL* gurl,
104 net::HttpRequestHeaders* headers) const;
101 105
102 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request. 106 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request.
103 // Returns the serialized and base 64 encoded request as a string. 107 // Returns the serialized and base 64 encoded request as a string.
104 std::string GetBase64SerializedUpdateRequestProto( 108 std::string GetBase64SerializedUpdateRequestProto(
105 const base::hash_map<UpdateListIdentifier, std::string>& 109 const base::hash_map<UpdateListIdentifier, std::string>&
106 current_list_states); 110 current_list_states);
107 111
108 // Parses the base64 encoded response received from the server as a 112 // Parses the base64 encoded response received from the server as a
109 // FetchThreatListUpdatesResponse protobuf and returns each of the 113 // FetchThreatListUpdatesResponse protobuf and returns each of the
110 // ListUpdateResponse protobufs contained in it as a vector. 114 // ListUpdateResponse protobufs contained in it as a vector.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 current_list_states, 198 current_list_states,
195 V4UpdateCallback callback) = 0; 199 V4UpdateCallback callback) = 0;
196 200
197 private: 201 private:
198 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); 202 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory);
199 }; 203 };
200 204
201 } // namespace safe_browsing 205 } // namespace safe_browsing
202 206
203 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ 207 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698