Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 1569673002: [NOT FOR LANDING] Detailed loading traces Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_database.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index cd78d766881acbf2879aecf9e7f8f13229c72eba..1bd4519b33544261febed4ca50ca1cfba72dc630 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -10,6 +10,7 @@
#include <iterator>
#include <utility>
+#include "base/trace_event/trace_event.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/macros.h"
@@ -241,6 +242,8 @@ bool GetCachedFullHash(std::map<SBPrefix, SBCachedFullHashResult>* cache,
const SBFullHash& full_hash,
const base::Time& expire_base,
std::vector<SBFullHashResult>* results) {
+ TRACE_EVENT0("toplevel", "SafeBrowsingDatabaseNew::GetCachedFullHash");
+
// First check if there is a valid cached result for this prefix.
std::map<SBPrefix, SBCachedFullHashResult>::iterator citer =
cache->find(full_hash.prefix);
@@ -490,6 +493,9 @@ class SafeBrowsingDatabaseNew::ThreadSafeStateManager::ReadTransaction {
}
PrefixGetHashCache* prefix_gethash_cache() {
+ TRACE_EVENT0("toplevel",
+ "SafeBrowsingDatabaseNew::ThreadSafeStateManager::"
+ "ReadTransaction::prefix_gethash_cache");
// The cache is special: it is read/write on all threads. Access to it
// therefore requires a LOCK'ed transaction (i.e. it can't benefit from
// DONT_LOCK_ON_MAIN_THREAD).
@@ -610,6 +616,9 @@ SafeBrowsingDatabaseNew::DatabaseStateManager::~DatabaseStateManager() {}
scoped_ptr<SafeBrowsingDatabaseNew::ReadTransaction>
SafeBrowsingDatabaseNew::ThreadSafeStateManager::BeginReadTransaction() {
+ TRACE_EVENT0(
+ "toplevel",
+ "SafeBrowsingDatabaseNew::ThreadSafeStateManager::BeginReadTransaction");
return make_scoped_ptr(
new ReadTransaction(this, ReadTransaction::AutoLockRequirement::LOCK));
}
@@ -848,6 +857,7 @@ bool SafeBrowsingDatabaseNew::ContainsBrowseUrl(
const GURL& url,
std::vector<SBPrefix>* prefix_hits,
std::vector<SBFullHashResult>* cache_hits) {
+ TRACE_EVENT0("toplevel", "SafeBrowsingDatabaseNew::ContainsBrowseUrl");
return PrefixSetContainsUrl(url, PrefixSetId::BROWSE, prefix_hits,
cache_hits);
}
@@ -864,6 +874,9 @@ bool SafeBrowsingDatabaseNew::ContainsUnwantedSoftwareUrl(
const GURL& url,
std::vector<SBPrefix>* prefix_hits,
std::vector<SBFullHashResult>* cache_hits) {
+ TRACE_EVENT0("toplevel",
+ "SafeBrowsingDatabaseNew::ContainsUnwantedSoftwareUrl");
+
return PrefixSetContainsUrl(url, PrefixSetId::UNWANTED_SOFTWARE, prefix_hits,
cache_hits);
}
@@ -881,6 +894,7 @@ bool SafeBrowsingDatabaseNew::PrefixSetContainsUrl(
PrefixSetId prefix_set_id,
std::vector<SBPrefix>* prefix_hits,
std::vector<SBFullHashResult>* cache_hits) {
+ TRACE_EVENT0("toplevel", "SafeBrowsingDatabaseNew::PrefixSetContainsUrl");
std::vector<SBFullHash> full_hashes;
UrlToFullHashes(url, false, &full_hashes);
return PrefixSetContainsUrlHashes(full_hashes, prefix_set_id, prefix_hits,
@@ -903,6 +917,8 @@ bool SafeBrowsingDatabaseNew::PrefixSetContainsUrlHashes(
const base::Time now = base::Time::Now();
{
+ TRACE_EVENT0("toplevel",
+ "SafeBrowsingDatabaseNew::PrefixSetContainsUrlHashes");
scoped_ptr<ReadTransaction> txn = state_manager_.BeginReadTransaction();
// |prefix_set| is empty until it is either read from disk, or the first
@@ -911,20 +927,30 @@ bool SafeBrowsingDatabaseNew::PrefixSetContainsUrlHashes(
if (!prefix_set)
return false;
- for (size_t i = 0; i < full_hashes.size(); ++i) {
- if (!GetCachedFullHash(txn->prefix_gethash_cache(), full_hashes[i], now,
- cache_hits)) {
- // No valid cached result, check the database.
- if (prefix_set->Exists(full_hashes[i]))
- prefix_hits->push_back(full_hashes[i].prefix);
+ {
+ TRACE_EVENT0(
+ "toplevel",
+ "SafeBrowsingDatabaseNew::PrefixSetContainsUrlHashes::ForLoop");
+ for (size_t i = 0; i < full_hashes.size(); ++i) {
+ if (!GetCachedFullHash(txn->prefix_gethash_cache(), full_hashes[i], now,
+ cache_hits)) {
+ // No valid cached result, check the database.
+ if (prefix_set->Exists(full_hashes[i]))
+ prefix_hits->push_back(full_hashes[i].prefix);
+ }
}
}
}
- // Multiple full hashes could share prefix, remove duplicates.
- std::sort(prefix_hits->begin(), prefix_hits->end());
- prefix_hits->erase(std::unique(prefix_hits->begin(), prefix_hits->end()),
- prefix_hits->end());
+ {
+ TRACE_EVENT0(
+ "toplevel",
+ "SafeBrowsingDatabaseNew::PrefixSetContainsUrlHashes::SortAndErase");
+ // Multiple full hashes could share prefix, remove duplicates.
+ std::sort(prefix_hits->begin(), prefix_hits->end());
+ prefix_hits->erase(std::unique(prefix_hits->begin(), prefix_hits->end()),
+ prefix_hits->end());
+ }
return !prefix_hits->empty() || !cache_hits->empty();
}
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | components/content_settings/core/browser/cookie_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698