OLD | NEW |
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_GET_HASH_PROTOCOL_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. |
9 // | 9 // |
10 // The V4GetHashProtocolManager handles formatting and making requests of, and | 10 // The V4GetHashProtocolManager handles formatting and making requests of, and |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // Information needed to update the cache and call the callback to post the | 100 // Information needed to update the cache and call the callback to post the |
101 // results. | 101 // results. |
102 struct FullHashCallbackInfo { | 102 struct FullHashCallbackInfo { |
103 FullHashCallbackInfo(); | 103 FullHashCallbackInfo(); |
104 FullHashCallbackInfo(const std::vector<FullHashInfo>& cached_full_hash_infos, | 104 FullHashCallbackInfo(const std::vector<FullHashInfo>& cached_full_hash_infos, |
105 const std::vector<HashPrefix>& prefixes_requested, | 105 const std::vector<HashPrefix>& prefixes_requested, |
106 std::unique_ptr<net::URLFetcher> fetcher, | 106 std::unique_ptr<net::URLFetcher> fetcher, |
107 const FullHashToStoreAndHashPrefixesMap& | 107 const FullHashToStoreAndHashPrefixesMap& |
108 full_hash_to_store_and_hash_prefixes, | 108 full_hash_to_store_and_hash_prefixes, |
109 const FullHashCallback& callback); | 109 const FullHashCallback& callback, |
| 110 const base::Time& network_start_time); |
110 ~FullHashCallbackInfo(); | 111 ~FullHashCallbackInfo(); |
111 | 112 |
112 // The FullHashInfo objects retrieved from cache. These are merged with the | 113 // The FullHashInfo objects retrieved from cache. These are merged with the |
113 // results received from the server before invoking the callback. | 114 // results received from the server before invoking the callback. |
114 std::vector<FullHashInfo> cached_full_hash_infos; | 115 std::vector<FullHashInfo> cached_full_hash_infos; |
115 | 116 |
116 // The callback method to call after collecting the full hashes for given | 117 // The callback method to call after collecting the full hashes for given |
117 // hash prefixes. | 118 // hash prefixes. |
118 FullHashCallback callback; | 119 FullHashCallback callback; |
119 | 120 |
120 // The fetcher that will return the response from the server. This is stored | 121 // The fetcher that will return the response from the server. This is stored |
121 // here as a unique pointer to be able to reason about its lifetime easily. | 122 // here as a unique pointer to be able to reason about its lifetime easily. |
122 std::unique_ptr<net::URLFetcher> fetcher; | 123 std::unique_ptr<net::URLFetcher> fetcher; |
123 | 124 |
124 // The generated full hashes and the corresponding prefixes and the stores in | 125 // The generated full hashes and the corresponding prefixes and the stores in |
125 // which to look for a full hash match. | 126 // which to look for a full hash match. |
126 FullHashToStoreAndHashPrefixesMap full_hash_to_store_and_hash_prefixes; | 127 FullHashToStoreAndHashPrefixesMap full_hash_to_store_and_hash_prefixes; |
127 | 128 |
| 129 // Used to measure how long did it take to fetch the full hash response from |
| 130 // the server. |
| 131 base::Time network_start_time; |
| 132 |
128 // The prefixes that were requested from the server. | 133 // The prefixes that were requested from the server. |
129 std::vector<HashPrefix> prefixes_requested; | 134 std::vector<HashPrefix> prefixes_requested; |
130 }; | 135 }; |
131 | 136 |
132 // ---------------------------------------------------------------- | 137 // ---------------------------------------------------------------- |
133 | 138 |
134 class V4GetHashProtocolManagerFactory; | 139 class V4GetHashProtocolManagerFactory; |
135 | 140 |
136 class V4GetHashProtocolManager : public net::URLFetcherDelegate, | 141 class V4GetHashProtocolManager : public net::URLFetcherDelegate, |
137 public base::NonThreadSafe { | 142 public base::NonThreadSafe { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); | 356 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); |
352 }; | 357 }; |
353 | 358 |
354 #ifndef NDEBUG | 359 #ifndef NDEBUG |
355 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); | 360 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); |
356 #endif | 361 #endif |
357 | 362 |
358 } // namespace safe_browsing | 363 } // namespace safe_browsing |
359 | 364 |
360 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ | 365 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ |
OLD | NEW |