OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.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" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 bool SafeBrowsingService::DatabaseAvailable() const { | 650 bool SafeBrowsingService::DatabaseAvailable() const { |
651 base::AutoLock lock(database_lock_); | 651 base::AutoLock lock(database_lock_); |
652 return !closing_database_ && (database_ != NULL); | 652 return !closing_database_ && (database_ != NULL); |
653 } | 653 } |
654 | 654 |
655 bool SafeBrowsingService::MakeDatabaseAvailable() { | 655 bool SafeBrowsingService::MakeDatabaseAvailable() { |
656 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 656 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
657 DCHECK(enabled_); | 657 DCHECK(enabled_); |
658 if (DatabaseAvailable()) | 658 if (DatabaseAvailable()) |
659 return true; | 659 return true; |
660 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, | 660 safe_browsing_thread_->message_loop()->PostTask( |
661 base::IgnoreReturn<SafeBrowsingDatabase*>( | 661 FROM_HERE, |
662 base::Bind(&SafeBrowsingService::GetDatabase, this))); | 662 base::Bind(base::IgnoreResult(&SafeBrowsingService::GetDatabase), this)); |
663 return false; | 663 return false; |
664 } | 664 } |
665 | 665 |
666 void SafeBrowsingService::CloseDatabase() { | 666 void SafeBrowsingService::CloseDatabase() { |
667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
668 | 668 |
669 // Cases to avoid: | 669 // Cases to avoid: |
670 // * If |closing_database_| is true, continuing will queue up a second | 670 // * If |closing_database_| is true, continuing will queue up a second |
671 // request, |closing_database_| will be reset after handling the first | 671 // request, |closing_database_| will be reset after handling the first |
672 // request, and if any functions on the db thread recreate the database, we | 672 // request, and if any functions on the db thread recreate the database, we |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 Stop(); | 1355 Stop(); |
1356 | 1356 |
1357 if (csd_service_.get()) | 1357 if (csd_service_.get()) |
1358 csd_service_->SetEnabledAndRefreshState(enable); | 1358 csd_service_->SetEnabledAndRefreshState(enable); |
1359 if (download_service_.get()) { | 1359 if (download_service_.get()) { |
1360 download_service_->SetEnabled( | 1360 download_service_->SetEnabled( |
1361 enable && !CommandLine::ForCurrentProcess()->HasSwitch( | 1361 enable && !CommandLine::ForCurrentProcess()->HasSwitch( |
1362 switches::kDisableImprovedDownloadProtection)); | 1362 switches::kDisableImprovedDownloadProtection)); |
1363 } | 1363 } |
1364 } | 1364 } |
OLD | NEW |