| 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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
| 6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
| 7 // service. | 7 // service. |
| 8 | 8 |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 10 | 10 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ~TestProtocolManager() override { delete_count_++; } | 384 ~TestProtocolManager() override { delete_count_++; } |
| 385 | 385 |
| 386 // This function is called when there is a prefix hit in local safebrowsing | 386 // This function is called when there is a prefix hit in local safebrowsing |
| 387 // database and safebrowsing service issues a get hash request to backends. | 387 // database and safebrowsing service issues a get hash request to backends. |
| 388 // We return a result from the prefilled full_hashes_ hash_map to simulate | 388 // We return a result from the prefilled full_hashes_ hash_map to simulate |
| 389 // server's response. At the same time, latency is added to simulate real | 389 // server's response. At the same time, latency is added to simulate real |
| 390 // life network issues. | 390 // life network issues. |
| 391 void GetFullHash(const std::vector<SBPrefix>& prefixes, | 391 void GetFullHash(const std::vector<SBPrefix>& prefixes, |
| 392 SafeBrowsingProtocolManager::FullHashCallback callback, | 392 SafeBrowsingProtocolManager::FullHashCallback callback, |
| 393 bool is_download, | 393 bool is_download, |
| 394 bool is_extended_reporting) override { | 394 ExtendedReportingLevel reporting_level) override { |
| 395 BrowserThread::PostDelayedTask( | 395 BrowserThread::PostDelayedTask( |
| 396 BrowserThread::IO, FROM_HERE, | 396 BrowserThread::IO, FROM_HERE, |
| 397 base::Bind(InvokeFullHashCallback, callback, full_hashes_), delay_); | 397 base::Bind(InvokeFullHashCallback, callback, full_hashes_), delay_); |
| 398 } | 398 } |
| 399 | 399 |
| 400 // Prepare the GetFullHash results for the next request. | 400 // Prepare the GetFullHash results for the next request. |
| 401 void AddGetFullHashResponse(const SBFullHashResult& full_hash_result) { | 401 void AddGetFullHashResponse(const SBFullHashResult& full_hash_result) { |
| 402 full_hashes_.push_back(full_hash_result); | 402 full_hashes_.push_back(full_hash_result); |
| 403 } | 403 } |
| 404 | 404 |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 content::Source<SafeBrowsingDatabaseManager>( | 1775 content::Source<SafeBrowsingDatabaseManager>( |
| 1776 sb_factory_->test_safe_browsing_service()->database_manager().get())); | 1776 sb_factory_->test_safe_browsing_service()->database_manager().get())); |
| 1777 BrowserThread::PostTask( | 1777 BrowserThread::PostTask( |
| 1778 BrowserThread::IO, FROM_HERE, | 1778 BrowserThread::IO, FROM_HERE, |
| 1779 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, | 1779 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, |
| 1780 base::Unretained(this))); | 1780 base::Unretained(this))); |
| 1781 observer.Wait(); | 1781 observer.Wait(); |
| 1782 } | 1782 } |
| 1783 | 1783 |
| 1784 } // namespace safe_browsing | 1784 } // namespace safe_browsing |
| OLD | NEW |