OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class SBProtocolManagerFactory; | 52 class SBProtocolManagerFactory; |
53 class SafeBrowsingProtocolManagerDelegate; | 53 class SafeBrowsingProtocolManagerDelegate; |
54 | 54 |
55 class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, | 55 class SafeBrowsingProtocolManager : public net::URLFetcherDelegate, |
56 public base::NonThreadSafe { | 56 public base::NonThreadSafe { |
57 public: | 57 public: |
58 // FullHashCallback is invoked when GetFullHash completes. | 58 // FullHashCallback is invoked when GetFullHash completes. |
59 // Parameters: | 59 // Parameters: |
60 // - The vector of full hash results. If empty, indicates that there | 60 // - The vector of full hash results. If empty, indicates that there |
61 // were no matches, and that the resource is safe. | 61 // were no matches, and that the resource is safe. |
62 // - Whether the result can be cached. This may not be the case when | 62 // - The cache lifetime of the result. A lifetime of 0 indicates the results |
63 // the result did not come from the SB server, for example. | 63 // should not be cached. |
64 typedef base::Callback<void(const std::vector<SBFullHashResult>&, | 64 typedef base::Callback<void(const std::vector<SBFullHashResult>&, |
65 bool)> FullHashCallback; | 65 const base::TimeDelta&)> FullHashCallback; |
66 | 66 |
67 virtual ~SafeBrowsingProtocolManager(); | 67 virtual ~SafeBrowsingProtocolManager(); |
68 | 68 |
69 // Makes the passed |factory| the factory used to instantiate | 69 // Makes the passed |factory| the factory used to instantiate |
70 // a SafeBrowsingService. Useful for tests. | 70 // a SafeBrowsingService. Useful for tests. |
71 static void RegisterFactory(SBProtocolManagerFactory* factory) { | 71 static void RegisterFactory(SBProtocolManagerFactory* factory) { |
72 factory_ = factory; | 72 factory_ = factory; |
73 } | 73 } |
74 | 74 |
75 // Create an instance of the safe browsing protocol manager. | 75 // Create an instance of the safe browsing protocol manager. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 // Subset of successful responses for which one or more of the | 136 // Subset of successful responses for which one or more of the |
137 // full hashes matched (should lead to an interstitial). | 137 // full hashes matched (should lead to an interstitial). |
138 GET_HASH_FULL_HASH_HIT, | 138 GET_HASH_FULL_HASH_HIT, |
139 | 139 |
140 // Subset of successful responses which weren't empty and have no | 140 // Subset of successful responses which weren't empty and have no |
141 // matches. It means that there was a prefix collision which was | 141 // matches. It means that there was a prefix collision which was |
142 // cleared up by the full hashes. | 142 // cleared up by the full hashes. |
143 GET_HASH_FULL_HASH_MISS, | 143 GET_HASH_FULL_HASH_MISS, |
144 | 144 |
| 145 // Subset of successful responses where the response body wasn't parsable. |
| 146 GET_HASH_PARSE_ERROR, |
| 147 |
| 148 // Gethash request failed (network error). |
| 149 GET_HASH_NETWORK_ERROR, |
| 150 |
| 151 // Gethash request returned HTTP result code other than 200 or 204. |
| 152 GET_HASH_HTTP_ERROR, |
| 153 |
145 // Memory space for histograms is determined by the max. ALWAYS | 154 // Memory space for histograms is determined by the max. ALWAYS |
146 // ADD NEW VALUES BEFORE THIS ONE. | 155 // ADD NEW VALUES BEFORE THIS ONE. |
147 GET_HASH_RESULT_MAX | 156 GET_HASH_RESULT_MAX |
148 }; | 157 }; |
149 | 158 |
150 // Record a GetHash result. |is_download| indicates if the get | 159 // Record a GetHash result. |is_download| indicates if the get |
151 // hash is triggered by download related lookup. | 160 // hash is triggered by download related lookup. |
152 static void RecordGetHashResult(bool is_download, | 161 static void RecordGetHashResult(bool is_download, |
153 ResultType result_type); | 162 ResultType result_type); |
154 | 163 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // call at a later time. | 432 // call at a later time. |
424 virtual void AddChunks(const std::string& list, SBChunkList* chunks, | 433 virtual void AddChunks(const std::string& list, SBChunkList* chunks, |
425 AddChunksCallback callback) = 0; | 434 AddChunksCallback callback) = 0; |
426 | 435 |
427 // Delete chunks from the database. | 436 // Delete chunks from the database. |
428 virtual void DeleteChunks( | 437 virtual void DeleteChunks( |
429 std::vector<SBChunkDelete>* delete_chunks) = 0; | 438 std::vector<SBChunkDelete>* delete_chunks) = 0; |
430 }; | 439 }; |
431 | 440 |
432 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 441 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |