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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.h

Issue 2505153002: Add support for scout to 'ext' param when creating SafeBrowsing ping URLs. (Closed)
Patch Set: Add missing dep Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
7 7
8 // A class that implements Chrome's interface with the SafeBrowsing protocol. 8 // A class that implements Chrome's interface with the SafeBrowsing protocol.
9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for 9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for
10 // protocol details. 10 // protocol details.
(...skipping 13 matching lines...) Expand all
24 24
25 #include "base/containers/hash_tables.h" 25 #include "base/containers/hash_tables.h"
26 #include "base/gtest_prod_util.h" 26 #include "base/gtest_prod_util.h"
27 #include "base/macros.h" 27 #include "base/macros.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "base/timer/timer.h" 29 #include "base/timer/timer.h"
30 #include "chrome/browser/safe_browsing/chunk_range.h" 30 #include "chrome/browser/safe_browsing/chunk_range.h"
31 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" 31 #include "chrome/browser/safe_browsing/protocol_manager_helper.h"
32 #include "chrome/browser/safe_browsing/protocol_parser.h" 32 #include "chrome/browser/safe_browsing/protocol_parser.h"
33 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 33 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
34 #include "components/safe_browsing_db/safe_browsing_prefs.h"
34 #include "components/safe_browsing_db/safebrowsing.pb.h" 35 #include "components/safe_browsing_db/safebrowsing.pb.h"
35 #include "components/safe_browsing_db/util.h" 36 #include "components/safe_browsing_db/util.h"
36 #include "net/url_request/url_fetcher_delegate.h" 37 #include "net/url_request/url_fetcher_delegate.h"
37 #include "net/url_request/url_request_status.h" 38 #include "net/url_request/url_request_status.h"
38 #include "url/gurl.h" 39 #include "url/gurl.h"
39 40
40 namespace net { 41 namespace net {
41 class URLFetcher; 42 class URLFetcher;
42 class URLRequestContextGetter; 43 class URLRequestContextGetter;
43 } // namespace net 44 } // namespace net
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 // net::URLFetcherDelegate interface. 82 // net::URLFetcherDelegate interface.
82 void OnURLFetchComplete(const net::URLFetcher* source) override; 83 void OnURLFetchComplete(const net::URLFetcher* source) override;
83 84
84 // Retrieve the full hash for a set of prefixes, and invoke the callback 85 // Retrieve the full hash for a set of prefixes, and invoke the callback
85 // argument when the results are retrieved. The callback may be invoked 86 // argument when the results are retrieved. The callback may be invoked
86 // synchronously. 87 // synchronously.
87 virtual void GetFullHash(const std::vector<SBPrefix>& prefixes, 88 virtual void GetFullHash(const std::vector<SBPrefix>& prefixes,
88 FullHashCallback callback, 89 FullHashCallback callback,
89 bool is_download, 90 bool is_download,
90 bool is_extended_reporting); 91 ExtendedReportingLevel reporting_level);
91 92
92 // Forces the start of next update after |interval| time. 93 // Forces the start of next update after |interval| time.
93 void ForceScheduleNextUpdate(base::TimeDelta interval); 94 void ForceScheduleNextUpdate(base::TimeDelta interval);
94 95
95 // Scheduled update callback. 96 // Scheduled update callback.
96 void GetNextUpdate(); 97 void GetNextUpdate();
97 98
98 // Called by the SafeBrowsingService when our request for a list of all chunks 99 // Called by the SafeBrowsingService when our request for a list of all chunks
99 // for each list is done. If database_error is true, that means the protocol 100 // for each list is done. If database_error is true, that means the protocol
100 // manager shouldn't fetch updates since they can't be written to disk. It 101 // manager shouldn't fetch updates since they can't be written to disk. It
101 // should try again later to open the database. 102 // should try again later to open the database.
102 void OnGetChunksComplete(const std::vector<SBListChunkRanges>& list, 103 void OnGetChunksComplete(const std::vector<SBListChunkRanges>& list,
103 bool database_error, 104 bool database_error,
104 bool is_extended_reporting); 105 ExtendedReportingLevel reporting_level);
105 106
106 // The last time we received an update. 107 // The last time we received an update.
107 base::Time last_update() const { return last_update_; } 108 base::Time last_update() const { return last_update_; }
108 109
109 // Setter for additional_query_. To make sure the additional_query_ won't 110 // Setter for additional_query_. To make sure the additional_query_ won't
110 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) 111 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService)
111 // should call this after callbacks triggered in UpdateFinished() or before 112 // should call this after callbacks triggered in UpdateFinished() or before
112 // IssueUpdateRequest(). 113 // IssueUpdateRequest().
113 void set_additional_query(const std::string& query) { 114 void set_additional_query(const std::string& query) {
114 additional_query_ = query; 115 additional_query_ = query;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 // Which type of backup update request is being used. 206 // Which type of backup update request is being used.
206 enum BackupUpdateReason { 207 enum BackupUpdateReason {
207 BACKUP_UPDATE_REASON_CONNECT, 208 BACKUP_UPDATE_REASON_CONNECT,
208 BACKUP_UPDATE_REASON_HTTP, 209 BACKUP_UPDATE_REASON_HTTP,
209 BACKUP_UPDATE_REASON_NETWORK, 210 BACKUP_UPDATE_REASON_NETWORK,
210 BACKUP_UPDATE_REASON_MAX, 211 BACKUP_UPDATE_REASON_MAX,
211 }; 212 };
212 213
213 // Generates Update URL for querying about the latest set of chunk updates. 214 // Generates Update URL for querying about the latest set of chunk updates.
214 GURL UpdateUrl(bool is_extended_reporting) const; 215 GURL UpdateUrl(ExtendedReportingLevel reporting_level) const;
215 216
216 // Generates backup Update URL for querying about the latest set of chunk 217 // Generates backup Update URL for querying about the latest set of chunk
217 // updates. |url_prefix| is the base prefix to use. 218 // updates. |url_prefix| is the base prefix to use.
218 GURL BackupUpdateUrl(BackupUpdateReason reason) const; 219 GURL BackupUpdateUrl(BackupUpdateReason reason) const;
219 220
220 // Generates GetHash request URL for retrieving full hashes. 221 // Generates GetHash request URL for retrieving full hashes.
221 GURL GetHashUrl(bool is_extended_reporting) const; 222 GURL GetHashUrl(ExtendedReportingLevel reporting_level) const;
222 // Generates URL for reporting safe browsing hits for UMA users.
223 223
224 // Composes a ChunkUrl based on input string. 224 // Composes a ChunkUrl based on input string.
225 GURL NextChunkUrl(const std::string& input) const; 225 GURL NextChunkUrl(const std::string& input) const;
226 226
227 // Returns the time for the next update request. If |back_off| is true, 227 // Returns the time for the next update request. If |back_off| is true,
228 // the time returned will increment an error count and return the appriate 228 // the time returned will increment an error count and return the appriate
229 // next time (see ScheduleNextUpdate below). 229 // next time (see ScheduleNextUpdate below).
230 base::TimeDelta GetNextUpdateInterval(bool back_off); 230 base::TimeDelta GetNextUpdateInterval(bool back_off);
231 231
232 // Worker function for calculating GetHash and Update backoff times (in 232 // Worker function for calculating GetHash and Update backoff times (in
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 private: 403 private:
404 DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactory); 404 DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactory);
405 }; 405 };
406 406
407 // Delegate interface for the SafeBrowsingProtocolManager. 407 // Delegate interface for the SafeBrowsingProtocolManager.
408 class SafeBrowsingProtocolManagerDelegate { 408 class SafeBrowsingProtocolManagerDelegate {
409 public: 409 public:
410 using GetChunksCallback = base::Callback<void( 410 using GetChunksCallback = base::Callback<void(
411 const std::vector<SBListChunkRanges>&, /* List of chunks */ 411 const std::vector<SBListChunkRanges>&, /* List of chunks */
412 bool, /* database_error */ 412 bool, /* database_error */
413 bool /* is_extended_reporting */)>; 413 ExtendedReportingLevel /* reporting_level */)>;
Jialiu Lin 2016/11/17 18:47:23 nit: align with the above two comments?
lpz 2016/11/17 19:46:05 Done, although git cl format seems to put this bac
414 using AddChunksCallback = base::Closure; 414 using AddChunksCallback = base::Closure;
415 415
416 virtual ~SafeBrowsingProtocolManagerDelegate(); 416 virtual ~SafeBrowsingProtocolManagerDelegate();
417 417
418 // |UpdateStarted()| is called just before the SafeBrowsing update protocol 418 // |UpdateStarted()| is called just before the SafeBrowsing update protocol
419 // has begun. 419 // has begun.
420 virtual void UpdateStarted() = 0; 420 virtual void UpdateStarted() = 0;
421 421
422 // |UpdateFinished()| is called just after the SafeBrowsing update protocol 422 // |UpdateFinished()| is called just after the SafeBrowsing update protocol
423 // has completed. 423 // has completed.
(...skipping 16 matching lines...) Expand all
440 AddChunksCallback callback) = 0; 440 AddChunksCallback callback) = 0;
441 441
442 // Delete chunks from the database. 442 // Delete chunks from the database.
443 virtual void DeleteChunks( 443 virtual void DeleteChunks(
444 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes) = 0; 444 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes) = 0;
445 }; 445 };
446 446
447 } // namespace safe_browsing 447 } // namespace safe_browsing
448 448
449 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 449 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698