OLD | NEW |
1 // Copyright (c) 2010 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/scoped_ptr.h" | 21 #include "base/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 "chrome/common/net/url_fetcher.h" | 28 #include "chrome/common/net/url_fetcher.h" |
29 | 29 |
| 30 namespace net { |
30 class URLRequestStatus; | 31 class URLRequestStatus; |
| 32 } // namespace net |
31 | 33 |
32 #if defined(COMPILER_GCC) | 34 #if defined(COMPILER_GCC) |
33 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without | 35 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without |
34 // specifying this). | 36 // specifying this). |
35 namespace __gnu_cxx { | 37 namespace __gnu_cxx { |
36 template<> | 38 template<> |
37 struct hash<const URLFetcher*> { | 39 struct hash<const URLFetcher*> { |
38 size_t operator()(const URLFetcher* fetcher) const { | 40 size_t operator()(const URLFetcher* fetcher) const { |
39 return reinterpret_cast<size_t>(fetcher); | 41 return reinterpret_cast<size_t>(fetcher); |
40 } | 42 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const std::string& mackey_url_prefix, | 98 const std::string& mackey_url_prefix, |
97 bool disable_auto_update); | 99 bool disable_auto_update); |
98 | 100 |
99 // Sets up the update schedule and internal state for making periodic requests | 101 // Sets up the update schedule and internal state for making periodic requests |
100 // of the SafeBrowsing service. | 102 // of the SafeBrowsing service. |
101 virtual void Initialize(); | 103 virtual void Initialize(); |
102 | 104 |
103 // URLFetcher::Delegate interface. | 105 // URLFetcher::Delegate interface. |
104 virtual void OnURLFetchComplete(const URLFetcher* source, | 106 virtual void OnURLFetchComplete(const URLFetcher* source, |
105 const GURL& url, | 107 const GURL& url, |
106 const URLRequestStatus& status, | 108 const net::URLRequestStatus& status, |
107 int response_code, | 109 int response_code, |
108 const ResponseCookies& cookies, | 110 const ResponseCookies& cookies, |
109 const std::string& data); | 111 const std::string& data); |
110 | 112 |
111 // API used by the SafeBrowsingService for issuing queries. When the results | 113 // API used by the SafeBrowsingService for issuing queries. When the results |
112 // are available, SafeBrowsingService::HandleGetHashResults is called. | 114 // are available, SafeBrowsingService::HandleGetHashResults is called. |
113 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check, | 115 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check, |
114 const std::vector<SBPrefix>& prefixes); | 116 const std::vector<SBPrefix>& prefixes); |
115 | 117 |
116 // Forces the start of next update after |next_update_msec| in msec. | 118 // Forces the start of next update after |next_update_msec| in msec. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 std::string https_url_prefix_; | 403 std::string https_url_prefix_; |
402 | 404 |
403 // When true, protocol manager will not start an update unless | 405 // When true, protocol manager will not start an update unless |
404 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 406 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
405 bool disable_auto_update_; | 407 bool disable_auto_update_; |
406 | 408 |
407 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 409 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
408 }; | 410 }; |
409 | 411 |
410 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 412 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |