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

Side by Side Diff: chrome/browser/safe_browsing/database_manager.cc

Issue 11785014: Record metrics for slow startups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android/Linux Aurora compile failure Created 7 years, 11 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 | Annotate | Revision Log
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/database_manager.h" 5 #include "chrome/browser/safe_browsing/database_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/leak_tracker.h" 11 #include "base/debug/leak_tracker.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/metrics/metrics_service.h" 18 #include "chrome/browser/metrics/metrics_service.h"
19 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 19 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
20 #include "chrome/browser/safe_browsing/download_protection_service.h" 20 #include "chrome/browser/safe_browsing/download_protection_service.h"
21 #include "chrome/browser/safe_browsing/malware_details.h" 21 #include "chrome/browser/safe_browsing/malware_details.h"
22 #include "chrome/browser/safe_browsing/protocol_manager.h" 22 #include "chrome/browser/safe_browsing/protocol_manager.h"
23 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 23 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
25 #include "chrome/browser/safe_browsing/ui_manager.h" 25 #include "chrome/browser/safe_browsing/ui_manager.h"
26 #include "chrome/common/chrome_constants.h" 26 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/startup_metric_utils.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
33 34
34 using content::BrowserThread; 35 using content::BrowserThread;
35 36
36 namespace { 37 namespace {
37 38
38 // When download url check takes this long, client's callback will be called 39 // When download url check takes this long, client's callback will be called
39 // without waiting for the result. 40 // without waiting for the result.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (safe_browsing_thread_.get()) { 494 if (safe_browsing_thread_.get()) {
494 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, 495 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE,
495 base::Bind(&SafeBrowsingDatabaseManager::OnCloseDatabase, this)); 496 base::Bind(&SafeBrowsingDatabaseManager::OnCloseDatabase, this));
496 } 497 }
497 } 498 }
498 499
499 SafeBrowsingDatabase* SafeBrowsingDatabaseManager::GetDatabase() { 500 SafeBrowsingDatabase* SafeBrowsingDatabaseManager::GetDatabase() {
500 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); 501 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop());
501 if (database_) 502 if (database_)
502 return database_; 503 return database_;
504 startup_metric_utils::ScopedSlowStartupUMA
505 scoped_timer("Startup.SlowStartupSafeBrowsingGetDatabase");
503 const base::TimeTicks before = base::TimeTicks::Now(); 506 const base::TimeTicks before = base::TimeTicks::Now();
504 507
505 SafeBrowsingDatabase* database = 508 SafeBrowsingDatabase* database =
506 SafeBrowsingDatabase::Create(enable_download_protection_, 509 SafeBrowsingDatabase::Create(enable_download_protection_,
507 enable_csd_whitelist_, 510 enable_csd_whitelist_,
508 enable_download_whitelist_); 511 enable_download_whitelist_);
509 512
510 database->Init(SafeBrowsingService::GetBaseFilename()); 513 database->Init(SafeBrowsingService::GetBaseFilename());
511 { 514 {
512 // Acquiring the lock here guarantees correct ordering between the writes to 515 // Acquiring the lock here guarantees correct ordering between the writes to
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); 896 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this));
894 checks_.insert(check); 897 checks_.insert(check);
895 898
896 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); 899 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task);
897 900
898 MessageLoop::current()->PostDelayedTask(FROM_HERE, 901 MessageLoop::current()->PostDelayedTask(FROM_HERE,
899 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, 902 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback,
900 check->timeout_factory_->GetWeakPtr(), check), 903 check->timeout_factory_->GetWeakPtr(), check),
901 base::TimeDelta::FromMilliseconds(timeout_ms)); 904 base::TimeDelta::FromMilliseconds(timeout_ms));
902 } 905 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698