| 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 803 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 804 if (enabled_) | 804 if (enabled_) |
| 805 callback.Run(); | 805 callback.Run(); |
| 806 } | 806 } |
| 807 | 807 |
| 808 void SafeBrowsingDatabaseManager::DatabaseLoadComplete() { | 808 void SafeBrowsingDatabaseManager::DatabaseLoadComplete() { |
| 809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 810 if (!enabled_) | 810 if (!enabled_) |
| 811 return; | 811 return; |
| 812 | 812 |
| 813 HISTOGRAM_COUNTS("SB.QueueDepth", queued_checks_.size()); | 813 LOCAL_HISTOGRAM_COUNTS("SB.QueueDepth", queued_checks_.size()); |
| 814 if (queued_checks_.empty()) | 814 if (queued_checks_.empty()) |
| 815 return; | 815 return; |
| 816 | 816 |
| 817 // If the database isn't already available, calling CheckUrl() in the loop | 817 // If the database isn't already available, calling CheckUrl() in the loop |
| 818 // below will add the check back to the queue, and we'll infinite-loop. | 818 // below will add the check back to the queue, and we'll infinite-loop. |
| 819 DCHECK(DatabaseAvailable()); | 819 DCHECK(DatabaseAvailable()); |
| 820 while (!queued_checks_.empty()) { | 820 while (!queued_checks_.empty()) { |
| 821 QueuedCheck check = queued_checks_.front(); | 821 QueuedCheck check = queued_checks_.front(); |
| 822 DCHECK(!check.start.is_null()); | 822 DCHECK(!check.start.is_null()); |
| 823 HISTOGRAM_TIMES("SB.QueueDelay", base::TimeTicks::Now() - check.start); | 823 LOCAL_HISTOGRAM_TIMES("SB.QueueDelay", |
| 824 base::TimeTicks::Now() - check.start); |
| 824 // If CheckUrl() determines the URL is safe immediately, it doesn't call the | 825 // If CheckUrl() determines the URL is safe immediately, it doesn't call the |
| 825 // client's handler function (because normally it's being directly called by | 826 // client's handler function (because normally it's being directly called by |
| 826 // the client). Since we're not the client, we have to convey this result. | 827 // the client). Since we're not the client, we have to convey this result. |
| 827 if (check.client && CheckBrowseUrl(check.url, check.client)) { | 828 if (check.client && CheckBrowseUrl(check.url, check.client)) { |
| 828 SafeBrowsingCheck sb_check(std::vector<GURL>(1, check.url), | 829 SafeBrowsingCheck sb_check(std::vector<GURL>(1, check.url), |
| 829 std::vector<SBFullHash>(), | 830 std::vector<SBFullHash>(), |
| 830 check.client, | 831 check.client, |
| 831 check.check_type, | 832 check.check_type, |
| 832 check.expected_threats); | 833 check.expected_threats); |
| 833 check.client->OnSafeBrowsingResult(sb_check); | 834 check.client->OnSafeBrowsingResult(sb_check); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); | 1061 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); |
| 1061 checks_.insert(check); | 1062 checks_.insert(check); |
| 1062 | 1063 |
| 1063 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1064 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
| 1064 | 1065 |
| 1065 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1066 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1066 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, | 1067 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, |
| 1067 check->timeout_factory_->GetWeakPtr(), check), | 1068 check->timeout_factory_->GetWeakPtr(), check), |
| 1068 check_timeout_); | 1069 check_timeout_); |
| 1069 } | 1070 } |
| OLD | NEW |