Chromium Code Reviews| Index: components/safe_browsing_db/v4_local_database_manager.cc |
| diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc |
| index 5798bf2af85f7031247620061388d09ce9695088..a16ddd7e87e37b264b14f94de2cfc6cc3b63655f 100644 |
| --- a/components/safe_browsing_db/v4_local_database_manager.cc |
| +++ b/components/safe_browsing_db/v4_local_database_manager.cc |
| @@ -13,10 +13,12 @@ |
| #include "base/callback.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "components/safe_browsing_db/v4_feature_list.h" |
| #include "content/public/browser/browser_thread.h" |
| using content::BrowserThread; |
| +using base::TimeTicks; |
| namespace safe_browsing { |
| @@ -337,7 +339,9 @@ bool V4LocalDatabaseManager::GetPrefixMatches( |
| DCHECK(enabled_); |
| DCHECK(v4_database_); |
| DCHECK_GT(ClientCallbackType::CHECK_MAX, check->client_callback_type); |
| + full_hash_to_store_and_hash_prefixes->clear(); |
| + const base::TimeTicks before = TimeTicks::Now(); |
| if (check->client_callback_type == ClientCallbackType::CHECK_BROWSE_URL) { |
| std::unordered_set<FullHash> full_hashes; |
| V4ProtocolManagerUtil::UrlToFullHashes(check->url, &full_hashes); |
| @@ -352,14 +356,18 @@ bool V4LocalDatabaseManager::GetPrefixMatches( |
| matched_store_and_hash_prefixes; |
| } |
| } |
| - |
| - // No hash prefixes found in the local database so that resource must be |
| - // safe. |
| - return !full_hash_to_store_and_hash_prefixes->empty(); |
| + } else { |
| + NOTREACHED() << "Unexpected client_callback_type encountered"; |
| } |
| - NOTREACHED() << "Unexpected client_callback_type encountered"; |
| - return false; |
| + // TODO(vakh): only log SafeBrowsing.V4GetPrefixMatches.Time once PVer3 code |
| + // is removed. |
| + base::TimeDelta diff = TimeTicks::Now() - before; |
| + UMA_HISTOGRAM_TIMES("SB2.FilterCheck", diff); |
| + UMA_HISTOGRAM_CUSTOM_TIMES("SafeBrowsing.V4GetPrefixMatches.Time", diff, |
| + base::TimeDelta::FromMicroseconds(100), |
|
Nathan Parker
2016/10/22 00:24:55
Does this generate a log or linear scale of bucket
vakh (use Gerrit instead)
2016/10/22 01:34:34
Done. The comments for UMA_HISTOGRAM_CUSTOM_TIMES
Scott Hess - ex-Googler
2016/10/24 19:24:22
Log scale unless you're doing something special.
|
| + base::TimeDelta::FromSeconds(20), 50); |
| + return !full_hash_to_store_and_hash_prefixes->empty(); |
| } |
| void V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata( |
| @@ -409,6 +417,10 @@ void V4LocalDatabaseManager::OnFullHashResponse( |
| return; |
| } |
| + // TODO(vakh): Consider changing the following histogram name to be |
| + // SafeBrowsing.V4GetFullHashOverNetwork.Time once PVer3 code is removed. |
| + UMA_HISTOGRAM_LONG_TIMES( |
| + "SB2.Network", TimeTicks::Now() - pending_check->full_hash_check_start); |
| auto it = pending_clients_.find(pending_check->client); |
| if (it == pending_clients_.end()) { |
| // The check has since been cancelled. |
| @@ -434,6 +446,9 @@ void V4LocalDatabaseManager::PerformFullHashCheck( |
| pending_clients_.insert(check->client); |
| + // Set the start time for the network request (or the response from cache). |
| + check->full_hash_check_start = TimeTicks::Now(); |
|
Nathan Parker
2016/10/22 00:24:55
Ah, so this will won't distinguish network calls v
vakh (use Gerrit instead)
2016/10/22 01:34:34
Done.
|
| + |
| v4_get_hash_protocol_manager_->GetFullHashes( |
| full_hash_to_store_and_hash_prefixes, |
| base::Bind(&V4LocalDatabaseManager::OnFullHashResponse, |