OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 9 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
10 // The SafeBrowsingProtocolManager handles formatting and making requests of, | 10 // The SafeBrowsingProtocolManager handles formatting and making requests of, |
11 // and handling responses from, Google's SafeBrowsing servers. This class uses | 11 // and handling responses from, Google's SafeBrowsing servers. This class uses |
12 // The SafeBrowsingProtocolParser class to do the actual parsing. | 12 // The SafeBrowsingProtocolParser class to do the actual parsing. |
13 | 13 |
14 #include <deque> | 14 #include <deque> |
15 #include <set> | 15 #include <set> |
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/hash_tables.h" | 20 #include "base/hash_tables.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/timer.h" | 23 #include "base/timer.h" |
24 #include "chrome/browser/safe_browsing/chunk_range.h" | 24 #include "chrome/browser/safe_browsing/chunk_range.h" |
25 #include "chrome/browser/safe_browsing/protocol_parser.h" | 25 #include "chrome/browser/safe_browsing/protocol_parser.h" |
26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
27 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
28 #include "content/public/common/url_fetcher_delegate.h" | 28 #include "content/public/common/url_fetcher_delegate.h" |
29 | 29 |
30 namespace net { | |
31 class URLRequestStatus; | |
32 } // namespace net | |
33 | |
34 #if defined(COMPILER_GCC) | 30 #if defined(COMPILER_GCC) |
35 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without | 31 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without |
36 // specifying this). | 32 // specifying this). |
37 namespace __gnu_cxx { | 33 namespace __gnu_cxx { |
38 template<> | 34 template<> |
39 struct hash<const content::URLFetcher*> { | 35 struct hash<const content::URLFetcher*> { |
40 size_t operator()(const content::URLFetcher* fetcher) const { | 36 size_t operator()(const content::URLFetcher* fetcher) const { |
41 return reinterpret_cast<size_t>(fetcher); | 37 return reinterpret_cast<size_t>(fetcher); |
42 } | 38 } |
43 }; | 39 }; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // ForceScheduleNextUpdate is called. | 192 // ForceScheduleNextUpdate is called. |
197 SafeBrowsingProtocolManager( | 193 SafeBrowsingProtocolManager( |
198 SafeBrowsingService* sb_service, | 194 SafeBrowsingService* sb_service, |
199 const std::string& client_name, | 195 const std::string& client_name, |
200 const std::string& client_key, | 196 const std::string& client_key, |
201 const std::string& wrapped_key, | 197 const std::string& wrapped_key, |
202 net::URLRequestContextGetter* request_context_getter, | 198 net::URLRequestContextGetter* request_context_getter, |
203 const std::string& http_url_prefix, | 199 const std::string& http_url_prefix, |
204 const std::string& https_url_prefix, | 200 const std::string& https_url_prefix, |
205 bool disable_auto_update); | 201 bool disable_auto_update); |
| 202 |
206 private: | 203 private: |
207 friend class SBProtocolManagerFactoryImpl; | 204 friend class SBProtocolManagerFactoryImpl; |
208 | 205 |
209 // Internal API for fetching information from the SafeBrowsing servers. The | 206 // Internal API for fetching information from the SafeBrowsing servers. The |
210 // GetHash requests are higher priority since they can block user requests | 207 // GetHash requests are higher priority since they can block user requests |
211 // so are handled separately. | 208 // so are handled separately. |
212 enum SafeBrowsingRequestType { | 209 enum SafeBrowsingRequestType { |
213 NO_REQUEST = 0, // No requests in progress | 210 NO_REQUEST = 0, // No requests in progress |
214 UPDATE_REQUEST, // Request for redirect URLs | 211 UPDATE_REQUEST, // Request for redirect URLs |
215 CHUNK_REQUEST, // Request for a specific chunk | 212 CHUNK_REQUEST, // Request for a specific chunk |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 std::string https_url_prefix_; | 399 std::string https_url_prefix_; |
403 | 400 |
404 // When true, protocol manager will not start an update unless | 401 // When true, protocol manager will not start an update unless |
405 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 402 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
406 bool disable_auto_update_; | 403 bool disable_auto_update_; |
407 | 404 |
408 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 405 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
409 }; | 406 }; |
410 | 407 |
411 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 408 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |