| Index: chrome/browser/safe_browsing/safe_browsing_service.cc
|
| diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| index 657778ac27980382cac04cb3881a7a1877439d70..257a006e7efe187c7a9f4df36d27ada27bbbcc3e 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| @@ -35,23 +35,33 @@
|
| using base::Time;
|
| using base::TimeDelta;
|
|
|
| +namespace {
|
| +
|
| // The default URL prefix where browser fetches chunk updates, hashes,
|
| // and reports safe browsing hits.
|
| -static const char* const kSbDefaultInfoURLPrefix =
|
| +const char* const kSbDefaultInfoURLPrefix =
|
| "http://safebrowsing.clients.google.com/safebrowsing";
|
|
|
| // The default URL prefix where browser fetches MAC client key and reports
|
| // malware details.
|
| -static const char* const kSbDefaultMacKeyURLPrefix =
|
| +const char* const kSbDefaultMacKeyURLPrefix =
|
| "https://sb-ssl.google.com/safebrowsing";
|
|
|
| -static Profile* GetDefaultProfile() {
|
| +Profile* GetDefaultProfile() {
|
| FilePath user_data_dir;
|
| PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
|
| ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| return profile_manager->GetDefaultProfile(user_data_dir);
|
| }
|
|
|
| +// The full call is kind of long...
|
| +void RecordGetHashFullMiss() {
|
| + SafeBrowsingProtocolManager::RecordGetHashResult(
|
| + SafeBrowsingProtocolManager::GET_HASH_NO_HITS);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| // static
|
| SafeBrowsingServiceFactory* SafeBrowsingService::factory_ = NULL;
|
|
|
| @@ -638,7 +648,8 @@ void SafeBrowsingService::OnCheckDone(SafeBrowsingCheck* check) {
|
| check->start = Time::Now();
|
| protocol_manager_->GetFullHash(check, check->prefix_hits);
|
| } else {
|
| - // We may have cached results for previous GetHash queries.
|
| + // We may have cached results for previous GetHash queries. Since
|
| + // this data comes from cache, don't histogram any misses.
|
| HandleOneCheck(check, check->full_hits);
|
| }
|
| }
|
| @@ -816,36 +827,42 @@ void SafeBrowsingService::OnHandleGetHashResults(
|
| SBPrefix prefix = check->prefix_hits[0];
|
| GetHashRequests::iterator it = gethash_requests_.find(prefix);
|
| if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) {
|
| - HandleOneCheck(check, full_hashes);
|
| + if (HandleOneCheck(check, full_hashes))
|
| + RecordGetHashFullMiss();
|
| return;
|
| }
|
|
|
| - // Call back all interested parties.
|
| + // Call back all interested parties, counting the total number of
|
| + // clients with no hits.
|
| GetHashRequestors& requestors = it->second;
|
| + size_t misses = 0;
|
| for (GetHashRequestors::iterator r = requestors.begin();
|
| r != requestors.end(); ++r) {
|
| - HandleOneCheck(*r, full_hashes);
|
| + if (HandleOneCheck(*r, full_hashes))
|
| + ++ misses;
|
| }
|
|
|
| + // None of the requests matched a full hash.
|
| + if (misses == requestors.size())
|
| + RecordGetHashFullMiss();
|
| +
|
| gethash_requests_.erase(it);
|
| }
|
|
|
| -void SafeBrowsingService::HandleOneCheck(
|
| +bool SafeBrowsingService::HandleOneCheck(
|
| SafeBrowsingCheck* check,
|
| const std::vector<SBFullHashResult>& full_hashes) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| +
|
| + // Always calculate the index for purposes of detecting requests
|
| + // with no hits.
|
| + int index = safe_browsing_util::CompareFullHashes(check->url, full_hashes);
|
| +
|
| + // |client| is NULL if the request was cancelled.
|
| if (check->client) {
|
| UrlCheckResult result = URL_SAFE;
|
| - int index = safe_browsing_util::CompareFullHashes(check->url, full_hashes);
|
| - if (index != -1) {
|
| + if (index != -1)
|
| result = GetResultFromListname(full_hashes[index].list_name);
|
| - } else {
|
| - // Log the case where the SafeBrowsing servers return full hashes in the
|
| - // GetHash response that match the prefix we're looking up, but don't
|
| - // match the full hash of the URL.
|
| - if (!full_hashes.empty())
|
| - UMA_HISTOGRAM_COUNTS("SB2.GetHashServerMiss", 1);
|
| - }
|
|
|
| // Let the client continue handling the original request.
|
| check->client->OnSafeBrowsingResult(check->url, result);
|
| @@ -853,6 +870,8 @@ void SafeBrowsingService::HandleOneCheck(
|
|
|
| checks_.erase(check);
|
| delete check;
|
| +
|
| + return (index == -1);
|
| }
|
|
|
| void SafeBrowsingService::DoDisplayBlockingPage(
|
|
|