| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 514 |
| 515 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { | 515 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { |
| 516 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 516 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 517 | 517 |
| 518 DoStopOnIOThread(); | 518 DoStopOnIOThread(); |
| 519 if (shutdown) { | 519 if (shutdown) { |
| 520 sb_service_ = NULL; | 520 sb_service_ = NULL; |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 void SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( |
| 525 bool update_succeeded) { |
| 526 content::NotificationService::current()->Notify( |
| 527 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 528 content::Source<SafeBrowsingDatabaseManager>(this), |
| 529 content::Details<bool>(&update_succeeded)); |
| 530 } |
| 531 |
| 524 SafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( | 532 SafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( |
| 525 const safe_browsing_util::ListType check_type, | 533 const safe_browsing_util::ListType check_type, |
| 526 Client* client, | 534 Client* client, |
| 527 const GURL& url, | 535 const GURL& url, |
| 528 const std::vector<SBThreatType>& expected_threats, | 536 const std::vector<SBThreatType>& expected_threats, |
| 529 const base::TimeTicks& start) | 537 const base::TimeTicks& start) |
| 530 : check_type(check_type), | 538 : check_type(check_type), |
| 531 client(client), | 539 client(client), |
| 532 url(url), | 540 url(url), |
| 533 expected_threats(expected_threats), | 541 expected_threats(expected_threats), |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 safe_browsing_thread_->message_loop()); | 860 safe_browsing_thread_->message_loop()); |
| 853 GetDatabase()->UpdateFinished(update_succeeded); | 861 GetDatabase()->UpdateFinished(update_succeeded); |
| 854 DCHECK(database_update_in_progress_); | 862 DCHECK(database_update_in_progress_); |
| 855 database_update_in_progress_ = false; | 863 database_update_in_progress_ = false; |
| 856 BrowserThread::PostTask( | 864 BrowserThread::PostTask( |
| 857 BrowserThread::UI, FROM_HERE, | 865 BrowserThread::UI, FROM_HERE, |
| 858 base::Bind(&SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished, | 866 base::Bind(&SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished, |
| 859 this, update_succeeded)); | 867 this, update_succeeded)); |
| 860 } | 868 } |
| 861 | 869 |
| 862 void SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( | |
| 863 bool update_succeeded) { | |
| 864 content::NotificationService::current()->Notify( | |
| 865 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | |
| 866 content::Source<SafeBrowsingDatabaseManager>(this), | |
| 867 content::Details<bool>(&update_succeeded)); | |
| 868 } | |
| 869 | |
| 870 void SafeBrowsingDatabaseManager::OnCloseDatabase() { | 870 void SafeBrowsingDatabaseManager::OnCloseDatabase() { |
| 871 DCHECK_EQ(base::MessageLoop::current(), | 871 DCHECK_EQ(base::MessageLoop::current(), |
| 872 safe_browsing_thread_->message_loop()); | 872 safe_browsing_thread_->message_loop()); |
| 873 DCHECK(closing_database_); | 873 DCHECK(closing_database_); |
| 874 | 874 |
| 875 // Because |closing_database_| is true, nothing on the IO thread will be | 875 // Because |closing_database_| is true, nothing on the IO thread will be |
| 876 // accessing the database, so it's safe to delete and then NULL the pointer. | 876 // accessing the database, so it's safe to delete and then NULL the pointer. |
| 877 delete database_; | 877 delete database_; |
| 878 database_ = NULL; | 878 database_ = NULL; |
| 879 | 879 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); | 1094 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); |
| 1095 checks_.insert(check); | 1095 checks_.insert(check); |
| 1096 | 1096 |
| 1097 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1097 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
| 1098 | 1098 |
| 1099 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1099 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1100 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, | 1100 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, |
| 1101 check->timeout_factory_->GetWeakPtr(), check), | 1101 check->timeout_factory_->GetWeakPtr(), check), |
| 1102 check_timeout_); | 1102 check_timeout_); |
| 1103 } | 1103 } |
| OLD | NEW |