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

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

Issue 10958: reverting changelist to see if it effects vista (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/renderer/renderer_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 5
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_thread.h"
16 #include "chrome/browser/profile_manager.h" 15 #include "chrome/browser/profile_manager.h"
17 #include "chrome/browser/safe_browsing/protocol_manager.h" 16 #include "chrome/browser/safe_browsing/protocol_manager.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 17 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 18 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
20 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
24 #include "chrome/common/pref_service.h" 23 #include "chrome/common/pref_service.h"
25 #include "net/base/registry_controlled_domain.h" 24 #include "net/base/registry_controlled_domain.h"
26 25
27 using base::Time; 26 using base::Time;
28 using base::TimeDelta; 27 using base::TimeDelta;
29 28
30 SafeBrowsingService::SafeBrowsingService() 29 SafeBrowsingService::SafeBrowsingService()
31 : io_loop_(NULL), 30 : io_loop_(NULL),
32 database_(NULL), 31 database_(NULL),
33 protocol_manager_(NULL), 32 protocol_manager_(NULL),
34 enabled_(false), 33 enabled_(false),
35 resetting_(false), 34 resetting_(false),
36 database_loaded_(false) { 35 database_loaded_(false) {
37 new_safe_browsing_ = CommandLine().HasSwitch(switches::kUseNewSafeBrowsing); 36 new_safe_browsing_ = CommandLine().HasSwitch(switches::kUseNewSafeBrowsing);
38 base::SystemMonitor* monitor = base::SystemMonitor::Get();
39 DCHECK(monitor);
40 if (monitor)
41 monitor->AddObserver(this);
42 } 37 }
43 38
44 SafeBrowsingService::~SafeBrowsingService() { 39 SafeBrowsingService::~SafeBrowsingService() {
45 base::SystemMonitor* monitor = base::SystemMonitor::Get();
46 if (monitor)
47 monitor->RemoveObserver(this);
48 } 40 }
49 41
50 // Only called on the UI thread. 42 // Only called on the UI thread.
51 void SafeBrowsingService::Initialize(MessageLoop* io_loop) { 43 void SafeBrowsingService::Initialize(MessageLoop* io_loop) {
52 io_loop_ = io_loop; 44 io_loop_ = io_loop;
53 45
54 // Get the profile's preference for SafeBrowsing. 46 // Get the profile's preference for SafeBrowsing.
55 std::wstring user_data_dir; 47 std::wstring user_data_dir;
56 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 48 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
57 ProfileManager* profile_manager = g_browser_process->profile_manager(); 49 ProfileManager* profile_manager = g_browser_process->profile_manager();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 UMA_HISTOGRAM_LONG_TIMES(L"SB.Delay", time); 648 UMA_HISTOGRAM_LONG_TIMES(L"SB.Delay", time);
657 } 649 }
658 650
659 void SafeBrowsingService::CacheHashResults( 651 void SafeBrowsingService::CacheHashResults(
660 const std::vector<SBPrefix>& prefixes, 652 const std::vector<SBPrefix>& prefixes,
661 const std::vector<SBFullHashResult>& full_hashes) { 653 const std::vector<SBFullHashResult>& full_hashes) {
662 DCHECK(MessageLoop::current() == db_thread_->message_loop()); 654 DCHECK(MessageLoop::current() == db_thread_->message_loop());
663 GetDatabase()->CacheHashResults(prefixes, full_hashes); 655 GetDatabase()->CacheHashResults(prefixes, full_hashes);
664 } 656 }
665 657
666 void SafeBrowsingService::OnSuspend(base::SystemMonitor*) { 658 void SafeBrowsingService::OnSuspend() {
667 } 659 }
668 660
669 // Tell the SafeBrowsing database not to do expensive disk operations for a few 661 // Tell the SafeBrowsing database not to do expensive disk operations for a few
670 // minutes after waking up. It's quite likely that the act of resuming from a 662 // minutes after waking up. It's quite likely that the act of resuming from a
671 // low power state will involve much disk activity, which we don't want to 663 // low power state will involve much disk activity, which we don't want to
672 // exacerbate. 664 // exacerbate.
673 void SafeBrowsingService::OnResume(base::SystemMonitor*) { 665 void SafeBrowsingService::OnResume() {
666 DCHECK(MessageLoop::current() == io_loop_);
674 if (enabled_) { 667 if (enabled_) {
675 ChromeThread::GetMessageLoop(ChromeThread::DB)->PostTask(FROM_HERE, 668 db_thread_->message_loop()->PostTask(FROM_HERE,
676 NewRunnableMethod(this, &SafeBrowsingService::HandleResume)); 669 NewRunnableMethod(this, &SafeBrowsingService::HandleResume));
677 } 670 }
678 } 671 }
679 672
680 void SafeBrowsingService::HandleResume() { 673 void SafeBrowsingService::HandleResume() {
681 DCHECK(MessageLoop::current() == db_thread_->message_loop()); 674 DCHECK(MessageLoop::current() == db_thread_->message_loop());
682 // We don't call GetDatabase() here, since we want to avoid unnecessary calls 675 // We don't call GetDatabase() here, since we want to avoid unnecessary calls
683 // to Open, Reset, etc, or reload the bloom filter while we're coming out of 676 // to Open, Reset, etc, or reload the bloom filter while we're coming out of
684 // a suspended state. 677 // a suspended state.
685 if (database_) 678 if (database_)
686 database_->HandleResume(); 679 database_->HandleResume();
687 } 680 }
688 681
689 void SafeBrowsingService::RunQueuedClients() { 682 void SafeBrowsingService::RunQueuedClients() {
690 DCHECK(MessageLoop::current() == io_loop_); 683 DCHECK(MessageLoop::current() == io_loop_);
691 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size()); 684 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size());
692 while (!queued_checks_.empty()) { 685 while (!queued_checks_.empty()) {
693 QueuedCheck check = queued_checks_.front(); 686 QueuedCheck check = queued_checks_.front();
694 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start); 687 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start);
695 CheckUrl(check.url, check.client); 688 CheckUrl(check.url, check.client);
696 queued_checks_.pop_front(); 689 queued_checks_.pop_front();
697 } 690 }
698 } 691 }
699 692
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698