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

Side by Side Diff: chrome/browser/safe_browsing/local_database_manager.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, 9 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/safe_browsing/local_database_manager.h" 5 #include "chrome/browser/safe_browsing/local_database_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/leak_tracker.h" 14 #include "base/debug/leak_tracker.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "base/trace_event/trace_event.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/prerender/prerender_field_trial.h" 24 #include "chrome/browser/prerender/prerender_field_trial.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 26 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
26 #include "chrome/browser/safe_browsing/download_protection_service.h" 27 #include "chrome/browser/safe_browsing/download_protection_service.h"
27 #include "chrome/browser/safe_browsing/protocol_manager.h" 28 #include "chrome/browser/safe_browsing/protocol_manager.h"
28 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 29 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
29 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 30 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
30 #include "chrome/browser/safe_browsing/ui_manager.h" 31 #include "chrome/browser/safe_browsing/ui_manager.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // TODO(kalman): there really shouldn't be a flag for this. 309 // TODO(kalman): there really shouldn't be a flag for this.
309 enable_extension_blacklist_ = 310 enable_extension_blacklist_ =
310 !cmdline->HasSwitch(switches::kSbDisableExtensionBlacklist); 311 !cmdline->HasSwitch(switches::kSbDisableExtensionBlacklist);
311 312
312 // The client-side IP blacklist feature is tightly integrated with client-side 313 // The client-side IP blacklist feature is tightly integrated with client-side
313 // phishing protection for now. 314 // phishing protection for now.
314 enable_ip_blacklist_ = enable_csd_whitelist_; 315 enable_ip_blacklist_ = enable_csd_whitelist_;
315 } 316 }
316 317
317 LocalSafeBrowsingDatabaseManager::~LocalSafeBrowsingDatabaseManager() { 318 LocalSafeBrowsingDatabaseManager::~LocalSafeBrowsingDatabaseManager() {
319 TRACE_EVENT0(
320 "toplevel",
321 "LocalSafeBrowsingDatabaseManager::~LocalSafeBrowsingDatabaseManager");
322
318 // The DCHECK is disabled due to crbug.com/438754. 323 // The DCHECK is disabled due to crbug.com/438754.
319 // DCHECK_CURRENTLY_ON(BrowserThread::UI); 324 // DCHECK_CURRENTLY_ON(BrowserThread::UI);
320 325
321 // We should have already been shut down. If we're still enabled, then the 326 // We should have already been shut down. If we're still enabled, then the
322 // database isn't going to be closed properly, which could lead to corruption. 327 // database isn't going to be closed properly, which could lead to corruption.
323 DCHECK(!enabled_); 328 DCHECK(!enabled_);
324 } 329 }
325 330
326 bool LocalSafeBrowsingDatabaseManager::IsSupported() const { 331 bool LocalSafeBrowsingDatabaseManager::IsSupported() const {
327 return true; 332 return true;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 bool LocalSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { 503 bool LocalSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() {
499 DCHECK_CURRENTLY_ON(BrowserThread::IO); 504 DCHECK_CURRENTLY_ON(BrowserThread::IO);
500 if (!enabled_ || !MakeDatabaseAvailable()) { 505 if (!enabled_ || !MakeDatabaseAvailable()) {
501 return true; 506 return true;
502 } 507 }
503 return database_->IsCsdWhitelistKillSwitchOn(); 508 return database_->IsCsdWhitelistKillSwitchOn();
504 } 509 }
505 510
506 bool LocalSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, 511 bool LocalSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url,
507 Client* client) { 512 Client* client) {
513 TRACE_EVENT0("toplevel", "LocalSafeBrowsingDatabaseManager::CheckBrowseUrl");
508 DCHECK_CURRENTLY_ON(BrowserThread::IO); 514 DCHECK_CURRENTLY_ON(BrowserThread::IO);
509 if (!enabled_) 515 if (!enabled_)
510 return true; 516 return true;
511 517
512 if (!CanCheckUrl(url)) 518 if (!CanCheckUrl(url))
513 return true; 519 return true;
514 520
515 std::vector<SBThreatType> expected_threats; 521 std::vector<SBThreatType> expected_threats;
516 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); 522 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE);
517 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); 523 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING);
(...skipping 26 matching lines...) Expand all
544 std::vector<SBPrefix> unwanted_prefix_hits; 550 std::vector<SBPrefix> unwanted_prefix_hits;
545 std::vector<SBFullHashResult> unused_cache_hits; 551 std::vector<SBFullHashResult> unused_cache_hits;
546 bool unwanted_prefix_match = database_->ContainsUnwantedSoftwareHashes( 552 bool unwanted_prefix_match = database_->ContainsUnwantedSoftwareHashes(
547 full_hashes, &unwanted_prefix_hits, &unused_cache_hits); 553 full_hashes, &unwanted_prefix_hits, &unused_cache_hits);
548 554
549 // Merge the two pre-sorted prefix hits lists. 555 // Merge the two pre-sorted prefix hits lists.
550 // TODO(gab): Refactor SafeBrowsingDatabase for it to return this merged list 556 // TODO(gab): Refactor SafeBrowsingDatabase for it to return this merged list
551 // by default rather than building it here. 557 // by default rather than building it here.
552 std::vector<SBPrefix> prefix_hits(browse_prefix_hits.size() + 558 std::vector<SBPrefix> prefix_hits(browse_prefix_hits.size() +
553 unwanted_prefix_hits.size()); 559 unwanted_prefix_hits.size());
554 std::merge(browse_prefix_hits.begin(), 560 {
555 browse_prefix_hits.end(), 561 TRACE_EVENT0(
556 unwanted_prefix_hits.begin(), 562 "toplevel",
557 unwanted_prefix_hits.end(), 563 "LocalSafeBrowsingDatabaseManager::CheckBrowseUrl::MergeAndErase");
558 prefix_hits.begin()); 564
559 prefix_hits.erase(std::unique(prefix_hits.begin(), prefix_hits.end()), 565 std::merge(browse_prefix_hits.begin(), browse_prefix_hits.end(),
560 prefix_hits.end()); 566 unwanted_prefix_hits.begin(), unwanted_prefix_hits.end(),
567 prefix_hits.begin());
568 prefix_hits.erase(std::unique(prefix_hits.begin(), prefix_hits.end()),
569 prefix_hits.end());
570 }
561 571
562 UMA_HISTOGRAM_TIMES("SB2.FilterCheck", base::TimeTicks::Now() - start); 572 UMA_HISTOGRAM_TIMES("SB2.FilterCheck", base::TimeTicks::Now() - start);
563 573
564 if (!browse_prefix_match && !unwanted_prefix_match) 574 if (!browse_prefix_match && !unwanted_prefix_match)
565 return true; // URL is okay. 575 return true; // URL is okay.
566 576
567 // Needs to be asynchronous, since we could be in the constructor of a 577 // Needs to be asynchronous, since we could be in the constructor of a
568 // ResourceDispatcherHost event handler which can't pause there. 578 // ResourceDispatcherHost event handler which can't pause there.
569 // This check will ping the Safe Browsing servers and get all lists which it 579 // This check will ping the Safe Browsing servers and get all lists which it
570 // matches. These lists will then be filtered against the |expected_threats| 580 // matches. These lists will then be filtered against the |expected_threats|
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, 1289 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback,
1280 check->weak_ptr_factory_->GetWeakPtr(), check), 1290 check->weak_ptr_factory_->GetWeakPtr(), check),
1281 check_timeout_); 1291 check_timeout_);
1282 } 1292 }
1283 1293
1284 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { 1294 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const {
1285 return enable_download_protection_; 1295 return enable_download_protection_;
1286 } 1296 }
1287 1297
1288 } // namespace safe_browsing 1298 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698