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

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

Issue 2915443002: Deprecate NonThreadSafe in components/safe_browsing_db in favor of SequenceChecker. (Closed)
Patch Set: Created 3 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/sequence_checker.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/common/safe_browsing_prefs.h" 24 #include "components/safe_browsing/common/safe_browsing_prefs.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 29
30 class GURL; 30 class GURL;
31 31
32 namespace net { 32 namespace net {
33 class URLFetcher; 33 class URLFetcher;
34 class URLRequestContextGetter; 34 class URLRequestContextGetter;
35 } // namespace net 35 } // namespace net
36 36
37 namespace safe_browsing { 37 namespace safe_browsing {
38 38
39 class V4UpdateProtocolManagerFactory; 39 class V4UpdateProtocolManagerFactory;
40 40
41 // V4UpdateCallback is invoked when a scheduled update completes. 41 // V4UpdateCallback is invoked when a scheduled update completes.
42 // Parameters: 42 // Parameters:
43 // - The vector of update response protobufs received from the server for 43 // - The vector of update response protobufs received from the server for
44 // each list type. 44 // each list type.
45 typedef base::Callback<void(std::unique_ptr<ParsedServerResponse>)> 45 typedef base::Callback<void(std::unique_ptr<ParsedServerResponse>)>
46 V4UpdateCallback; 46 V4UpdateCallback;
47 47
48 typedef base::Callback<ExtendedReportingLevel()> ExtendedReportingLevelCallback; 48 typedef base::Callback<ExtendedReportingLevel()> ExtendedReportingLevelCallback;
49 49
50 class V4UpdateProtocolManager : public net::URLFetcherDelegate, 50 class V4UpdateProtocolManager : public net::URLFetcherDelegate {
51 public base::NonThreadSafe {
52 public: 51 public:
53 ~V4UpdateProtocolManager() override; 52 ~V4UpdateProtocolManager() override;
54 53
55 // Makes the passed |factory| the factory used to instantiate 54 // Makes the passed |factory| the factory used to instantiate
56 // a V4UpdateProtocolManager. Useful for tests. 55 // a V4UpdateProtocolManager. Useful for tests.
57 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) { 56 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) {
58 factory_ = factory; 57 factory_ = factory;
59 } 58 }
60 59
61 // Create an instance of the safe browsing v4 protocol manager. 60 // Create an instance of the safe browsing v4 protocol manager.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 base::OneShotTimer update_timer_; 184 base::OneShotTimer update_timer_;
186 185
187 base::Time last_response_time_; 186 base::Time last_response_time_;
188 187
189 // Used to interrupt and re-schedule update requests that take too long to 188 // Used to interrupt and re-schedule update requests that take too long to
190 // complete. 189 // complete.
191 base::OneShotTimer timeout_timer_; 190 base::OneShotTimer timeout_timer_;
192 191
193 ExtendedReportingLevelCallback extended_reporting_level_callback_; 192 ExtendedReportingLevelCallback extended_reporting_level_callback_;
194 193
194 SEQUENCE_CHECKER(sequence_checker_);
195
195 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManager); 196 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManager);
196 }; 197 };
197 198
198 // Interface of a factory to create V4UpdateProtocolManager. Useful for tests. 199 // Interface of a factory to create V4UpdateProtocolManager. Useful for tests.
199 class V4UpdateProtocolManagerFactory { 200 class V4UpdateProtocolManagerFactory {
200 public: 201 public:
201 V4UpdateProtocolManagerFactory() {} 202 V4UpdateProtocolManagerFactory() {}
202 virtual ~V4UpdateProtocolManagerFactory() {} 203 virtual ~V4UpdateProtocolManagerFactory() {}
203 virtual std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager( 204 virtual std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
204 net::URLRequestContextGetter* request_context_getter, 205 net::URLRequestContextGetter* request_context_getter,
205 const V4ProtocolConfig& config, 206 const V4ProtocolConfig& config,
206 V4UpdateCallback update_callback, 207 V4UpdateCallback update_callback,
207 ExtendedReportingLevelCallback extended_reporting_level_callback) = 0; 208 ExtendedReportingLevelCallback extended_reporting_level_callback) = 0;
208 209
209 private: 210 private:
210 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); 211 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory);
211 }; 212 };
212 213
213 } // namespace safe_browsing 214 } // namespace safe_browsing
214 215
215 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ 216 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_get_hash_protocol_manager.cc ('k') | components/safe_browsing_db/v4_update_protocol_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698